From 9289605dbae4ec73ef37213626bb2252abeefaf1 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sat, 16 Jan 2010 18:04:32 +0000 Subject: fixed add/remove effect problem git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1504 90c681e8-e032-0410-971d-27865f9a5e38 --- src/qmmp/qmmpaudioengine.cpp | 26 +++++++++++++++----------- src/qmmp/qmmpaudioengine.h | 3 ++- 2 files changed, 17 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/qmmp/qmmpaudioengine.cpp b/src/qmmp/qmmpaudioengine.cpp index 7f385897b..75cc1ca83 100644 --- a/src/qmmp/qmmpaudioengine.cpp +++ b/src/qmmp/qmmpaudioengine.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009 by Ilya Kotov * + * Copyright (C) 2009-2010 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -201,7 +201,10 @@ void QmmpAudioEngine::removeEffect(EffectFactory *factory) if(m_output && m_output->isRunning()) { mutex()->lock(); - m_effects.removeAll(effect); + if(m_blockedEffects.contains(effect)) + qDebug("QmmpAudioEngine: restart required"); + else + m_effects.removeAll(effect); mutex()->unlock(); } } @@ -531,6 +534,7 @@ void QmmpAudioEngine::sendMetaData() Output *QmmpAudioEngine::createOutput(Decoder *d) { + m_blockedEffects.clear(); while(!m_effects.isEmpty()) //delete effects delete m_effects.takeFirst(); @@ -551,20 +555,20 @@ Output *QmmpAudioEngine::createOutput(Decoder *d) return FALSE; } m_effects = Effect::create(); - quint32 srate = m_ap.sampleRate(); - int chan = m_ap.channels(); - Qmmp::AudioFormat format = m_ap.format(); + AudioParameters ap = m_ap; m_replayGain->setSampleSize(m_ap.sampleSize()); foreach(Effect *effect, m_effects) { - effect->configure(srate, chan, format); - srate = effect->sampleRate(); - chan = effect->channels(); - format = effect->format(); + effect->configure(ap.sampleRate(), ap.channels(), ap.format()); + if (ap != effect->audioParameters()) + { + m_blockedEffects << effect; //list of effects which require restart + ap = effect->audioParameters(); + } } - m_chan = chan; - output->configure(srate, chan, format); + m_chan = ap.channels(); + output->configure(ap.sampleRate(), ap.channels(), ap.format()); return output; } diff --git a/src/qmmp/qmmpaudioengine.h b/src/qmmp/qmmpaudioengine.h index 7d19e2917..b785e9d48 100644 --- a/src/qmmp/qmmpaudioengine.h +++ b/src/qmmp/qmmpaudioengine.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009 by Ilya Kotov * + * Copyright (C) 2009-2010 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -71,6 +71,7 @@ private: DecoderFactory *m_factory; QList m_effects; + QList m_blockedEffects; Output *m_output; bool m_eqInited; -- cgit v1.2.3-13-gbd6f