forked from teamnwah/openmw-tes3coop
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()
|
||||
{
|
||||
ALint state;
|
||||
|
||||
alGetSourcei(mSource, AL_SOURCE_STATE, &state);
|
||||
throwALerror();
|
||||
|
||||
if(state == AL_PLAYING)
|
||||
return true;
|
||||
return !mIsFinished;
|
||||
}
|
||||
|
||||
|
@ -259,7 +266,11 @@ bool OpenAL_SoundStream::process()
|
|||
alSourceUnqueueBuffers(mSource, 1, &bufid);
|
||||
processed--;
|
||||
|
||||
if(mIsFinished)
|
||||
continue;
|
||||
|
||||
got = mDecoder->read(&data[0], data.size());
|
||||
mIsFinished = (got < data.size());
|
||||
if(got > 0)
|
||||
{
|
||||
alBufferData(bufid, mFormat, &data[0], got, mSampleRate);
|
||||
|
@ -275,17 +286,14 @@ bool OpenAL_SoundStream::process()
|
|||
|
||||
alGetSourcei(mSource, AL_BUFFERS_QUEUED, &queued);
|
||||
throwALerror();
|
||||
if(queued == 0)
|
||||
if(queued > 0)
|
||||
{
|
||||
mIsFinished = true;
|
||||
return false;
|
||||
alSourcePlay(mSource);
|
||||
throwALerror();
|
||||
}
|
||||
|
||||
alSourcePlay(mSource);
|
||||
throwALerror();
|
||||
}
|
||||
|
||||
return true;
|
||||
return !mIsFinished;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue