From 29170e68996bcdf2ba592a46996c8ae2ad7585ba Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 10 Dec 2012 13:28:39 +0100 Subject: [PATCH] Changed: Alternative code for play function for streaming source --- .../nel/src/sound/driver/openal/source_al.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/code/nel/src/sound/driver/openal/source_al.cpp b/code/nel/src/sound/driver/openal/source_al.cpp index a1b0af152..2c39b00a9 100644 --- a/code/nel/src/sound/driver/openal/source_al.cpp +++ b/code/nel/src/sound/driver/openal/source_al.cpp @@ -249,11 +249,30 @@ bool CSourceAL::play() else if (_IsStreaming) { _IsPaused = false; + /* NEW */ + // called by user as well as by code to resume after buffer underrun + if (!_IsPlaying) // set start time if not playing yet + _StartTime = CTime::getLocalTime(); + _IsPlaying = true; // this play always virtually succeed but may not actually be playing + if (_QueuedBuffers.size()) // ensure buffers have actually queued + { + alSourcePlay(_Source); + if (alGetError() != AL_NO_ERROR) + { + nlwarning("AL: Unknown error while trying to play streaming source."); + } + } + else + { + nlwarning("AL: Trying to play stream with no buffers queued."); + } + /* OLD alSourcePlay(_Source); _IsPlaying = (alGetError() == AL_NO_ERROR); if (_IsPlaying) _StartTime = CTime::getLocalTime(); // TODO: Played time should freeze when buffering fails, and be calculated based on the number of buffers played plus passed time. This is necessary for synchronizing animation with sound. return _IsPlaying; + */ // Streaming mode //nlwarning("AL: Cannot play null buffer; streaming not implemented" ); //nlstop;