From fcd41290acbb1582f4e463ecaca868e52ec00bfb Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Tue, 18 Apr 2017 18:39:32 +0000 Subject: fixed freezing when using DirectSound output git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@7122 90c681e8-e032-0410-971d-27865f9a5e38 --- src/qmmp/qmmpaudioengine.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/qmmp/qmmpaudioengine.cpp b/src/qmmp/qmmpaudioengine.cpp index 0b7aa8aa5..8b271c255 100644 --- a/src/qmmp/qmmpaudioengine.cpp +++ b/src/qmmp/qmmpaudioengine.cpp @@ -248,7 +248,6 @@ void QmmpAudioEngine::pause() m_output->recycler()->cond()->wakeAll(); m_output->recycler()->mutex()->unlock(); } - } void QmmpAudioEngine::setMuted(bool muted) @@ -276,19 +275,6 @@ void QmmpAudioEngine::stop() if (m_output) { - m_output->mutex()->lock (); - m_output->stop(); - m_output->mutex()->unlock(); - } - - // wake up threads - if (m_output) - { - m_output->mutex()->lock(); - m_output->recycler()->cond()->wakeAll(); - m_output->mutex()->unlock(); - if(m_output->isRunning()) - m_output->wait(); delete m_output; m_output = 0; } @@ -556,6 +542,22 @@ void QmmpAudioEngine::run() m_output->mutex()->unlock(); } mutex()->unlock(); + + if (m_output) + { + if(m_user_stop) + { + m_output->mutex()->lock (); + m_output->stop(); + m_output->recycler()->cond()->wakeAll(); + m_output->mutex()->unlock(); + } + + if((m_user_stop || m_finish) && m_output->isRunning()) + { + m_output->wait(); + } + } } void QmmpAudioEngine::flush(bool final) -- cgit v1.2.3-13-gbd6f