From 3a36329dd7a6d2ed069c7d9a351c44c1d128db6a Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 11 Apr 2012 21:51:01 +0200 Subject: [PATCH] Fixed: #795 Hang when stopping file stream source that is synchronously waiting for play --- code/nel/src/sound/stream_file_source.cpp | 14 ++++++++++---- code/nel/src/sound/stream_source.cpp | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/code/nel/src/sound/stream_file_source.cpp b/code/nel/src/sound/stream_file_source.cpp index 35377f0db..6a8c6b7d2 100644 --- a/code/nel/src/sound/stream_file_source.cpp +++ b/code/nel/src/sound/stream_file_source.cpp @@ -62,10 +62,10 @@ void CStreamFileSource::play() { // note: CStreamSource will assert crash if already physically playing! - nldebug("play"); if (m_Thread->isRunning() && m_WaitingForPlay) { + nldebug("play waiting %s", getStreamFileSound()->getFilePath().c_str()); if (m_NextBuffer || !m_FreeBuffers) { CStreamSource::play(); @@ -79,6 +79,7 @@ void CStreamFileSource::play() } else if (!_Playing) { + nldebug("play waiting %s", getStreamFileSound()->getFilePath().c_str()); if (!m_WaitingForPlay) { // thread may be stopping from stop call @@ -86,7 +87,7 @@ void CStreamFileSource::play() } else { - nlwarning("Already playing"); + nlwarning("Already waiting for play"); } if (!getStreamFileSound()->getAsync()) prepareDecoder(); @@ -97,7 +98,7 @@ void CStreamFileSource::play() if (!getStreamFileSound()->getAsync()) { // wait until at least one buffer is ready - while (!(m_NextBuffer || !m_FreeBuffers)) + while (!(m_NextBuffer || !m_FreeBuffers) && m_WaitingForPlay) NLMISC::nlSleep(10); CStreamSource::play(); if (!_Playing) @@ -111,6 +112,11 @@ void CStreamFileSource::play() mixer->addSourceWaitingForPlay(this); } } + else + { + nlwarning("Already playing"); + } + /*if (!m_WaitingForPlay) { @@ -127,7 +133,7 @@ void CStreamFileSource::play() void CStreamFileSource::stop() { - nldebug("stop"); + nldebug("stop %s", getStreamFileSound()->getFilePath().c_str()); CStreamSource::stop(); diff --git a/code/nel/src/sound/stream_source.cpp b/code/nel/src/sound/stream_source.cpp index 7d35d06db..1cd1ddcbc 100644 --- a/code/nel/src/sound/stream_source.cpp +++ b/code/nel/src/sound/stream_source.cpp @@ -264,6 +264,8 @@ void CStreamSource::stop() _SpawnEndCb(this, _CbUserParam); delete this; } + + m_WaitingForPlay = false; } void CStreamSource::setPos(const NLMISC::CVector& pos)