diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index 9dc0b8c5d..58566225b 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -316,15 +316,25 @@ void OpenAL_SoundStream::play() throwALerror(); mSamplesQueued = 0; - for(ALuint i = 0;i < sNumBuffers;i++) - alBufferData(mBuffers[i], mFormat, this, 0, mSampleRate); - throwALerror(); + std::vector data(mBufferSize); - alSourceQueueBuffers(mSource, sNumBuffers, mBuffers); - alSourcePlay(mSource); - throwALerror(); + bool finished = false; + for(ALuint i = 0;i < sNumBuffers && !finished;i++) + { + size_t got = mDecoder->read(&data[0], data.size()); + finished = (got < data.size()); + if(got > 0) + { + ALuint bufid = mBuffers[i]; + alBufferData(bufid, mFormat, &data[0], got, mSampleRate); + alSourceQueueBuffers(mSource, 1, &bufid); + throwALerror(); + mSamplesQueued += getBufferSampleCount(bufid); + } + } - mIsFinished = false; + mIsFinished = finished; + alSourcePlay(mSource); mOutput.mStreamThread->add(this); }