Merge pull request #2236 from Capostrophic/audio

Fix EAGAIN error leading to packets getting lost (bugs #4906, #4909)
pull/541/head
Bret Curtis 6 years ago committed by GitHub
commit a4b647db3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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…
Cancel
Save