mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 03:35:27 +00:00
Merge pull request #2236 from Capostrophic/audio
Fix EAGAIN error leading to packets getting lost (bugs #4906, #4909)
This commit is contained in:
commit
a4b647db3e
@ -96,25 +96,25 @@ bool FFmpeg_Decoder::getAVAudioData()
|
||||
return false;
|
||||
|
||||
do {
|
||||
if(mPacket.size == 0 && !getNextPacket())
|
||||
return false;
|
||||
|
||||
/* Decode some data, and check for errors */
|
||||
int ret = 0;
|
||||
ret = avcodec_receive_frame(mCodecCtx, mFrame);
|
||||
if (ret == 0)
|
||||
got_frame = true;
|
||||
int ret = avcodec_receive_frame(mCodecCtx, mFrame);
|
||||
if (ret == AVERROR(EAGAIN))
|
||||
ret = 0;
|
||||
if (ret == 0)
|
||||
{
|
||||
if (mPacket.size == 0 && !getNextPacket())
|
||||
return false;
|
||||
ret = avcodec_send_packet(mCodecCtx, &mPacket);
|
||||
if (ret < 0 && ret != AVERROR(EAGAIN))
|
||||
av_packet_unref(&mPacket);
|
||||
if (ret == 0)
|
||||
continue;
|
||||
}
|
||||
if (ret != 0)
|
||||
return false;
|
||||
|
||||
av_packet_unref(&mPacket);
|
||||
|
||||
if (!got_frame || mFrame->nb_samples == 0)
|
||||
if (mFrame->nb_samples == 0)
|
||||
continue;
|
||||
got_frame = true;
|
||||
|
||||
if(mSwr)
|
||||
{
|
||||
@ -138,7 +138,7 @@ bool FFmpeg_Decoder::getAVAudioData()
|
||||
else
|
||||
mFrameData = &mFrame->data[0];
|
||||
|
||||
} while(!got_frame || mFrame->nb_samples == 0);
|
||||
} while(!got_frame);
|
||||
mNextPts += (double)mFrame->nb_samples / mCodecCtx->sample_rate;
|
||||
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user