mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 16:44:05 +02:00
Added DSP callback support for VLC phonon
This commit is contained in:
@@ -215,6 +215,7 @@ AudioEngine::AudioEngine()
|
||||
d->state = Stopped;
|
||||
d->coverTempFile = 0;
|
||||
d->audioEffect = 0;
|
||||
d->dspPluginCallback = 0;
|
||||
|
||||
d->s_instance = this;
|
||||
tDebug() << "Init AudioEngine";
|
||||
@@ -236,7 +237,7 @@ AudioEngine::AudioEngine()
|
||||
onVolumeChanged( d->audioOutput->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
|
||||
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 );
|
||||
|
||||
QList< Phonon::EffectDescription > effectDescriptions = Phonon::BackendCapabilities::availableAudioEffects();
|
||||
foreach ( Phonon::EffectDescription effectDesc, effectDescriptions )
|
||||
if ( d->dspPluginCallback != 0 )
|
||||
{
|
||||
if ( effectDesc.name().toLower().contains( "eq" ) )
|
||||
{
|
||||
d->audioEffect = new Phonon::Effect( effectDesc );
|
||||
d->audioPath.insertEffect( d->audioEffect );
|
||||
break;
|
||||
}
|
||||
d->dspPluginCallback( samples, nb_channels, nb_samples );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
AudioEngine::equalizerBandCount()
|
||||
void
|
||||
AudioEngine::setDspCallback( void ( *cb ) ( signed short*, int, int ) )
|
||||
{
|
||||
Q_D( AudioEngine );
|
||||
|
||||
if ( d->audioEffect )
|
||||
{
|
||||
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;
|
||||
d->dspPluginCallback = cb;
|
||||
}
|
||||
|
@@ -109,8 +109,7 @@ public:
|
||||
*/
|
||||
qint64 currentTrackTotalTime() const;
|
||||
|
||||
int equalizerBandCount();
|
||||
bool setEqualizerBand( int band, int value );
|
||||
void setDspCallback( void ( *cb ) ( signed short* samples, int nb_channels, int nb_samples ) );
|
||||
|
||||
public slots:
|
||||
void playPause();
|
||||
@@ -200,9 +199,9 @@ private slots:
|
||||
private:
|
||||
void setState( AudioState state );
|
||||
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 );
|
||||
|
||||
|
||||
|
@@ -43,8 +43,6 @@ private:
|
||||
|
||||
Phonon::MediaObject* mediaObject;
|
||||
Phonon::AudioOutput* audioOutput;
|
||||
Phonon::Path audioPath;
|
||||
Phonon::Effect* audioEffect;
|
||||
|
||||
Phonon::Path audioPath;
|
||||
Phonon::Effect* audioEffect;
|
||||
@@ -68,5 +66,7 @@ private:
|
||||
|
||||
QTemporaryFile* coverTempFile;
|
||||
|
||||
void (* dspPluginCallback )( signed short* samples, int nb_channels, int nb_samples );
|
||||
|
||||
static AudioEngine* s_instance;
|
||||
};
|
||||
|
Reference in New Issue
Block a user