1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-29 22:45:34 +00:00

Fix the last audio packet getting lost

This commit is contained in:
Capostrophic 2019-03-09 21:25:16 +03:00
parent 947bf880df
commit d1967562a3

View file

@ -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;