From dd3df8317724d7c81ac7067dd8a0aa406ac92ac2 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sun, 23 Nov 2008 11:35:38 +0000 Subject: fixed possible freeze git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@624 90c681e8-e032-0410-971d-27865f9a5e38 --- src/qmmp/output.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qmmp/output.cpp b/src/qmmp/output.cpp index ded4c6e28..f063a509d 100644 --- a/src/qmmp/output.cpp +++ b/src/qmmp/output.cpp @@ -26,6 +26,8 @@ Output::Output (QObject* parent) : QThread (parent), m_recycler (stackSize()) m_totalWritten = 0; m_currentSeconds = -1; m_bytesPerSecond = 0; + m_userStop = FALSE; + m_pause = FALSE; } void Output::configure(quint32 freq, int chan, int prec) @@ -122,14 +124,15 @@ void Output::dispatch(const Qmmp::State &state) void Output::run() { + mutex()->lock (); if (!m_bytesPerSecond) { qWarning("Output: invalid audio parameters"); + mutex()->unlock (); return; } + mutex()->unlock (); - m_userStop = FALSE; - m_pause = FALSE; bool done = FALSE; Buffer *b = 0; qint64 l = 0; @@ -140,9 +143,8 @@ void Output::run() { mutex()->lock (); recycler()->mutex()->lock (); - done = m_userStop; - + while (!done && (recycler()->empty() || m_pause)) { mutex()->unlock(); @@ -152,14 +154,12 @@ void Output::run() done = m_userStop; } status(); - if (!b) { b = recycler()->next(); if (b && b->rate) m_kbps = b->rate; } - recycler()->cond()->wakeOne(); recycler()->mutex()->unlock(); mutex()->unlock(); -- cgit v1.2.3-13-gbd6f