forked from teamnwah/openmw-tes3coop
Fix crash when avcodec_decode_audio4 doesn't return a full frame (Fixes #2088)
This commit is contained in:
parent
0ce1732edb
commit
efa4d09c48
1 changed files with 5 additions and 2 deletions
|
@ -107,6 +107,9 @@ bool FFmpeg_Decoder::getAVAudioData()
|
||||||
av_shrink_packet(&mPacket, remaining);
|
av_shrink_packet(&mPacket, remaining);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!got_frame || mFrame->nb_samples == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
if(mSwr)
|
if(mSwr)
|
||||||
{
|
{
|
||||||
if(!mDataBuf || mDataBufLen < mFrame->nb_samples)
|
if(!mDataBuf || mDataBufLen < mFrame->nb_samples)
|
||||||
|
@ -114,7 +117,7 @@ bool FFmpeg_Decoder::getAVAudioData()
|
||||||
av_freep(&mDataBuf);
|
av_freep(&mDataBuf);
|
||||||
if(av_samples_alloc(&mDataBuf, NULL, av_get_channel_layout_nb_channels(mOutputChannelLayout),
|
if(av_samples_alloc(&mDataBuf, NULL, av_get_channel_layout_nb_channels(mOutputChannelLayout),
|
||||||
mFrame->nb_samples, mOutputSampleFormat, 0) < 0)
|
mFrame->nb_samples, mOutputSampleFormat, 0) < 0)
|
||||||
break;
|
return false;
|
||||||
else
|
else
|
||||||
mDataBufLen = mFrame->nb_samples;
|
mDataBufLen = mFrame->nb_samples;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +125,7 @@ bool FFmpeg_Decoder::getAVAudioData()
|
||||||
if(swr_convert(mSwr, (uint8_t**)&mDataBuf, mFrame->nb_samples,
|
if(swr_convert(mSwr, (uint8_t**)&mDataBuf, mFrame->nb_samples,
|
||||||
(const uint8_t**)mFrame->extended_data, mFrame->nb_samples) < 0)
|
(const uint8_t**)mFrame->extended_data, mFrame->nb_samples) < 0)
|
||||||
{
|
{
|
||||||
break;
|
return false;
|
||||||
}
|
}
|
||||||
mFrameData = &mDataBuf;
|
mFrameData = &mDataBuf;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue