mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-21 00:12:06 +02:00
Merge pull request #198 from saidinesh5/visualizer_plugin
Added support for fetching Audio Data from the AudioEngine.
This commit is contained in:
commit
042beadff7
@ -159,6 +159,39 @@ AudioEnginePrivate::onStateChanged( Phonon::State newState, Phonon::State oldSta
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioEnginePrivate::onAudioDataArrived( QMap<Phonon::AudioDataOutput::Channel, QVector<qint16> > data )
|
||||
{
|
||||
QMap< AudioEngine::AudioChannel, QVector<qint16> > result;
|
||||
|
||||
if(data.contains(Phonon::AudioDataOutput::LeftChannel))
|
||||
{
|
||||
result[AudioEngine::LeftChannel] = QVector<qint16>(data[Phonon::AudioDataOutput::LeftChannel]);
|
||||
}
|
||||
if(data.contains(Phonon::AudioDataOutput::LeftSurroundChannel))
|
||||
{
|
||||
result[AudioEngine::LeftChannel] = QVector<qint16>(data[Phonon::AudioDataOutput::LeftSurroundChannel]);
|
||||
}
|
||||
if(data.contains(Phonon::AudioDataOutput::RightChannel))
|
||||
{
|
||||
result[AudioEngine::RightChannel]= QVector<qint16>(data[Phonon::AudioDataOutput::RightChannel]);
|
||||
}
|
||||
if(data.contains(Phonon::AudioDataOutput::RightSurroundChannel))
|
||||
{
|
||||
result[AudioEngine::LeftChannel] = QVector<qint16>(data[Phonon::AudioDataOutput::RightSurroundChannel]);
|
||||
}
|
||||
if(data.contains(Phonon::AudioDataOutput::CenterChannel))
|
||||
{
|
||||
result[AudioEngine::LeftChannel] = QVector<qint16>(data[Phonon::AudioDataOutput::CenterChannel]);
|
||||
}
|
||||
if(data.contains(Phonon::AudioDataOutput::SubwooferChannel))
|
||||
{
|
||||
result[AudioEngine::LeftChannel] = QVector<qint16>(data[Phonon::AudioDataOutput::SubwooferChannel]);
|
||||
}
|
||||
|
||||
s_instance->audioDataArrived(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
AudioEngine* AudioEnginePrivate::s_instance = 0;
|
||||
@ -192,6 +225,8 @@ AudioEngine::AudioEngine()
|
||||
|
||||
d->mediaObject = new Phonon::MediaObject( this );
|
||||
d->audioOutput = new Phonon::AudioOutput( Phonon::MusicCategory, this );
|
||||
d->audioDataOutput = new Phonon::AudioDataOutput(this);
|
||||
|
||||
d->audioPath = Phonon::createPath( d->mediaObject, d->audioOutput );
|
||||
|
||||
d->mediaObject->setTickInterval( 150 );
|
||||
@ -212,7 +247,6 @@ AudioEngine::AudioEngine()
|
||||
initEqualizer();
|
||||
}
|
||||
|
||||
|
||||
AudioEngine::~AudioEngine()
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
@ -323,6 +357,32 @@ AudioEngine::stop( AudioErrorCode errorCode )
|
||||
}
|
||||
|
||||
|
||||
bool AudioEngine::activateDataOutput()
|
||||
{
|
||||
Q_D(AudioEngine);
|
||||
|
||||
d->audioDataPath = Phonon::createPath(d->mediaObject, d->audioDataOutput);
|
||||
connect(d->audioDataOutput, SIGNAL( dataReady(QMap<Phonon::AudioDataOutput::Channel,QVector<qint16> >) ),
|
||||
d_func(), SLOT(onAudioDataArrived(QMap<Phonon::AudioDataOutput::Channel,QVector<qint16> >)));
|
||||
|
||||
return d->audioDataPath.isValid();
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool AudioEngine::deactivateDataOutput()
|
||||
{
|
||||
Q_D(AudioEngine);
|
||||
|
||||
return d->audioDataPath.disconnect();
|
||||
}
|
||||
|
||||
void AudioEngine::audioDataArrived(QMap< AudioEngine::AudioChannel, QVector< qint16 > >& data)
|
||||
{
|
||||
emit audioDataReady(data);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioEngine::previous()
|
||||
{
|
||||
|
@ -36,6 +36,7 @@ Q_OBJECT
|
||||
public:
|
||||
enum AudioErrorCode { StreamReadError, AudioDeviceError, DecodeError, UnknownError, NoError };
|
||||
enum AudioState { Stopped = 0, Playing = 1, Paused = 2, Error = 3, Loading = 4 };
|
||||
enum AudioChannel { LeftChannel, LeftSurroundChannel, RightChannel , RightSurroundChannel, CenterChannel , SubwooferChannel };
|
||||
|
||||
static AudioEngine* instance();
|
||||
|
||||
@ -71,6 +72,9 @@ public slots:
|
||||
void pause();
|
||||
void stop( AudioErrorCode errorCode = NoError );
|
||||
|
||||
bool activateDataOutput();
|
||||
bool deactivateDataOutput();
|
||||
|
||||
void previous();
|
||||
void next();
|
||||
|
||||
@ -105,6 +109,8 @@ signals:
|
||||
void paused();
|
||||
void resumed();
|
||||
|
||||
void audioDataReady( QMap< AudioEngine::AudioChannel, QVector<qint16> > data );
|
||||
|
||||
void stopAfterTrackChanged();
|
||||
|
||||
void seeked( qint64 ms );
|
||||
@ -147,8 +153,11 @@ private:
|
||||
void checkStateQueue();
|
||||
void queueState( AudioState state );
|
||||
void setState( AudioState state );
|
||||
void setCurrentTrackPlaylist( const Tomahawk::playlistinterface_ptr& playlist );
|
||||
void setCurrentTrackPlaylist( const Tomahawk::playlistinterface_ptr& playlist );\
|
||||
|
||||
void initEqualizer();
|
||||
void audioDataArrived( QMap< AudioEngine::AudioChannel, QVector<qint16> >& data );
|
||||
|
||||
|
||||
Q_DECLARE_PRIVATE( AudioEngine );
|
||||
AudioEnginePrivate* d_ptr;
|
||||
|
@ -1,8 +1,9 @@
|
||||
|
||||
#include <phonon/MediaObject>
|
||||
#include <phonon/AudioOutput>
|
||||
#include <phonon/Path>
|
||||
#include <phonon/AudioDataOutput>
|
||||
#include <phonon/BackendCapabilities>
|
||||
#include <phonon/Path>
|
||||
#include <phonon/Effect>
|
||||
#include <phonon/EffectParameter>
|
||||
|
||||
@ -28,6 +29,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void onStateChanged( Phonon::State newState, Phonon::State oldState );
|
||||
void onAudioDataArrived( QMap< Phonon::AudioDataOutput::Channel, QVector<qint16> > data );
|
||||
|
||||
private:
|
||||
QSharedPointer<QIODevice> input;
|
||||
@ -40,9 +42,14 @@ private:
|
||||
|
||||
Phonon::MediaObject* mediaObject;
|
||||
Phonon::AudioOutput* audioOutput;
|
||||
|
||||
Phonon::Path audioPath;
|
||||
Phonon::Effect* audioEffect;
|
||||
|
||||
Phonon::AudioDataOutput* audioDataOutput;
|
||||
Phonon::Path audioDataPath;
|
||||
|
||||
|
||||
unsigned int timeElapsed;
|
||||
bool expectStop;
|
||||
bool waitingOnNewTrack;
|
||||
|
Loading…
x
Reference in New Issue
Block a user