mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 00:24:12 +02:00
Added DSP callback support for VLC phonon
This commit is contained in:
@@ -215,6 +215,7 @@ AudioEngine::AudioEngine()
|
|||||||
d->state = Stopped;
|
d->state = Stopped;
|
||||||
d->coverTempFile = 0;
|
d->coverTempFile = 0;
|
||||||
d->audioEffect = 0;
|
d->audioEffect = 0;
|
||||||
|
d->dspPluginCallback = 0;
|
||||||
|
|
||||||
d->s_instance = this;
|
d->s_instance = this;
|
||||||
tDebug() << "Init AudioEngine";
|
tDebug() << "Init AudioEngine";
|
||||||
@@ -236,7 +237,7 @@ AudioEngine::AudioEngine()
|
|||||||
onVolumeChanged( d->audioOutput->volume() );
|
onVolumeChanged( d->audioOutput->volume() );
|
||||||
setVolume( TomahawkSettings::instance()->volume() );
|
setVolume( TomahawkSettings::instance()->volume() );
|
||||||
|
|
||||||
initEqualizer();
|
d->mediaObject->setCurrentSource(Phonon::MediaSource("PhononDSP::effectCallback=" + QString::number((qulonglong)&AudioEngine::dspCallback, 16)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1384,52 +1385,28 @@ AudioEngine::setCurrentTrackPlaylist( const playlistinterface_ptr& playlist )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioEngine::initEqualizer()
|
AudioEngine::dspCallback( signed short* samples, int nb_channels, int nb_samples )
|
||||||
|
{
|
||||||
|
AudioEngine::instance()->dspCallbackInternal( samples, nb_channels, nb_samples );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AudioEngine::dspCallbackInternal( signed short* samples, int nb_channels, int nb_samples )
|
||||||
{
|
{
|
||||||
Q_D( AudioEngine );
|
Q_D( AudioEngine );
|
||||||
|
|
||||||
QList< Phonon::EffectDescription > effectDescriptions = Phonon::BackendCapabilities::availableAudioEffects();
|
if ( d->dspPluginCallback != 0 )
|
||||||
foreach ( Phonon::EffectDescription effectDesc, effectDescriptions )
|
|
||||||
{
|
{
|
||||||
if ( effectDesc.name().toLower().contains( "eq" ) )
|
d->dspPluginCallback( samples, nb_channels, nb_samples );
|
||||||
{
|
|
||||||
d->audioEffect = new Phonon::Effect( effectDesc );
|
|
||||||
d->audioPath.insertEffect( d->audioEffect );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
void
|
||||||
AudioEngine::equalizerBandCount()
|
AudioEngine::setDspCallback( void ( *cb ) ( signed short*, int, int ) )
|
||||||
{
|
{
|
||||||
Q_D( AudioEngine );
|
Q_D( AudioEngine );
|
||||||
|
|
||||||
if ( d->audioEffect )
|
d->dspPluginCallback = cb;
|
||||||
{
|
|
||||||
QList< Phonon::EffectParameter > params = d->audioEffect->parameters();
|
|
||||||
return params.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
AudioEngine::setEqualizerBand( int band, int value )
|
|
||||||
{
|
|
||||||
Q_D( AudioEngine );
|
|
||||||
|
|
||||||
if ( d->audioEffect )
|
|
||||||
{
|
|
||||||
QList< Phonon::EffectParameter > params = d->audioEffect->parameters();
|
|
||||||
if ( band < params.size() )
|
|
||||||
{
|
|
||||||
d->audioEffect->setParameterValue( params.at( band ), value );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
@@ -109,8 +109,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
qint64 currentTrackTotalTime() const;
|
qint64 currentTrackTotalTime() const;
|
||||||
|
|
||||||
int equalizerBandCount();
|
void setDspCallback( void ( *cb ) ( signed short* samples, int nb_channels, int nb_samples ) );
|
||||||
bool setEqualizerBand( int band, int value );
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void playPause();
|
void playPause();
|
||||||
@@ -200,9 +199,9 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void setState( AudioState state );
|
void setState( AudioState state );
|
||||||
void setCurrentTrackPlaylist( const Tomahawk::playlistinterface_ptr& playlist );
|
void setCurrentTrackPlaylist( const Tomahawk::playlistinterface_ptr& playlist );
|
||||||
void initEqualizer();
|
|
||||||
|
|
||||||
void initEqualizer();
|
static void dspCallback( signed short* samples, int nb_channels, int nb_samples );
|
||||||
|
void dspCallbackInternal( signed short* samples, int nb_channels, int nb_samples );
|
||||||
void audioDataArrived( QMap< AudioEngine::AudioChannel, QVector< qint16 > >& data );
|
void audioDataArrived( QMap< AudioEngine::AudioChannel, QVector< qint16 > >& data );
|
||||||
|
|
||||||
|
|
||||||
|
@@ -43,8 +43,6 @@ private:
|
|||||||
|
|
||||||
Phonon::MediaObject* mediaObject;
|
Phonon::MediaObject* mediaObject;
|
||||||
Phonon::AudioOutput* audioOutput;
|
Phonon::AudioOutput* audioOutput;
|
||||||
Phonon::Path audioPath;
|
|
||||||
Phonon::Effect* audioEffect;
|
|
||||||
|
|
||||||
Phonon::Path audioPath;
|
Phonon::Path audioPath;
|
||||||
Phonon::Effect* audioEffect;
|
Phonon::Effect* audioEffect;
|
||||||
@@ -68,5 +66,7 @@ private:
|
|||||||
|
|
||||||
QTemporaryFile* coverTempFile;
|
QTemporaryFile* coverTempFile;
|
||||||
|
|
||||||
|
void (* dspPluginCallback )( signed short* samples, int nb_channels, int nb_samples );
|
||||||
|
|
||||||
static AudioEngine* s_instance;
|
static AudioEngine* s_instance;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user