mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 16:49:54 +00:00
Stop trying to read decoded audio once it's finished
This commit is contained in:
parent
4f69972a9c
commit
afa2cb6de7
1 changed files with 15 additions and 7 deletions
|
@ -230,6 +230,13 @@ void OpenAL_SoundStream::stop()
|
||||||
|
|
||||||
bool OpenAL_SoundStream::isPlaying()
|
bool OpenAL_SoundStream::isPlaying()
|
||||||
{
|
{
|
||||||
|
ALint state;
|
||||||
|
|
||||||
|
alGetSourcei(mSource, AL_SOURCE_STATE, &state);
|
||||||
|
throwALerror();
|
||||||
|
|
||||||
|
if(state == AL_PLAYING)
|
||||||
|
return true;
|
||||||
return !mIsFinished;
|
return !mIsFinished;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +266,11 @@ bool OpenAL_SoundStream::process()
|
||||||
alSourceUnqueueBuffers(mSource, 1, &bufid);
|
alSourceUnqueueBuffers(mSource, 1, &bufid);
|
||||||
processed--;
|
processed--;
|
||||||
|
|
||||||
|
if(mIsFinished)
|
||||||
|
continue;
|
||||||
|
|
||||||
got = mDecoder->read(&data[0], data.size());
|
got = mDecoder->read(&data[0], data.size());
|
||||||
|
mIsFinished = (got < data.size());
|
||||||
if(got > 0)
|
if(got > 0)
|
||||||
{
|
{
|
||||||
alBufferData(bufid, mFormat, &data[0], got, mSampleRate);
|
alBufferData(bufid, mFormat, &data[0], got, mSampleRate);
|
||||||
|
@ -275,17 +286,14 @@ bool OpenAL_SoundStream::process()
|
||||||
|
|
||||||
alGetSourcei(mSource, AL_BUFFERS_QUEUED, &queued);
|
alGetSourcei(mSource, AL_BUFFERS_QUEUED, &queued);
|
||||||
throwALerror();
|
throwALerror();
|
||||||
if(queued == 0)
|
if(queued > 0)
|
||||||
{
|
{
|
||||||
mIsFinished = true;
|
alSourcePlay(mSource);
|
||||||
return false;
|
throwALerror();
|
||||||
}
|
}
|
||||||
|
|
||||||
alSourcePlay(mSource);
|
|
||||||
throwALerror();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return !mIsFinished;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue