From 3f8c52f91860dd7f911a51dcdeb95db296f21862 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 17 Feb 2014 00:20:29 +0100 Subject: [PATCH] Additional streaming behaviour fix for XAudio2 driver --- .../sound/driver/xaudio2/source_xaudio2.cpp | 29 +++++-------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/code/nel/src/sound/driver/xaudio2/source_xaudio2.cpp b/code/nel/src/sound/driver/xaudio2/source_xaudio2.cpp index 0087a53bc..21290951c 100644 --- a/code/nel/src/sound/driver/xaudio2/source_xaudio2.cpp +++ b/code/nel/src/sound/driver/xaudio2/source_xaudio2.cpp @@ -397,30 +397,16 @@ void CSourceXAudio2::submitStreamingBuffer(IBuffer *buffer) // nldebug(NLSOUND_XAUDIO2_PREFIX "submitStreamingBuffer"); nlassert(_BufferStreaming); - - IBuffer::TBufferFormat bufferFormat; - uint8 channels; - uint8 bitsPerSample; - uint32 frequency; - buffer->getFormat(bufferFormat, channels, bitsPerSample, frequency); + // allow to change the format if not playing if (!_IsPlaying) { - if (!_SourceVoice) - { - // if no source yet, prepare the format - preparePlay(bufferFormat, channels, bitsPerSample, frequency); - } - else - { - XAUDIO2_VOICE_STATE voice_state; - _SourceVoice->GetState(&voice_state); - // if no buffers queued, prepare the format - if (!voice_state.BuffersQueued) - { - preparePlay(bufferFormat, channels, bitsPerSample, frequency); - } - } + IBuffer::TBufferFormat bufferFormat; + uint8 channels; + uint8 bitsPerSample; + uint32 frequency; + buffer->getFormat(bufferFormat, channels, bitsPerSample, frequency); + preparePlay(bufferFormat, channels, bitsPerSample, frequency); } submitBuffer(static_cast(buffer)); @@ -636,6 +622,7 @@ bool CSourceXAudio2::play() // preparePlay already called, // stop already called before going into buffer streaming nlassert(!_IsPlaying); + nlassert(_SourceVoice); _PlayStart = CTime::getLocalTime(); if (SUCCEEDED(_SourceVoice->Start(0))) _IsPlaying = true; else nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED Play (_BufferStreaming)");