Skip to content

Commit

Permalink
free aframe and do the parse
Browse files Browse the repository at this point in the history
  • Loading branch information
courville committed Aug 27, 2024
1 parent 6ebcb56 commit ca31fe5
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions Source/codec_ffmpeg_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,32 +232,38 @@ serprintf("cannot open codec\r\n");
int ret = avcodec_send_packet(actx, &avpkt);
if (ret < 0) {
serprintf("%s: Failed sending packet for decoding: %s\n", __FUNCTION__, av_err2str(ret));
goto ErrorExit;
goto ErrorExit2;
}
ret = avcodec_receive_frame(actx, aframe);
if (ret < 0) {
serprintf("%s: Failed receiving an audio frame out of audio decoder %s\n", __FUNCTION__, av_err2str(ret));
goto ErrorExit;
goto ErrorExit2;
}

if( profile )
*profile = actx->profile;
if( channels )
*channels = actx->channels;

while ( ret >= 0) {
// drain the decoder, should not be necessary
int ret_rx_post = avcodec_receive_frame(actx, aframe);
if (ret_rx_post == 0) {
serprintf("%s: Got an unexpected additional audio frame %s\n", __FUNCTION__, av_err2str(ret_rx_post)));
serprintf("%s: got an unexpected additional audio frame (%s)\n", __FUNCTION__, av_err2str(ret_rx_post));
} else {
break;
}
}
if( profile )
*profile = actx->profile;
if( channels )
*channels = actx->channels;

av_free(aframe);

return 0;

ErrorExit2:
if ( aframe ) {
av_free(aframe);
}

ErrorExit:
// Close the codec
if ( actx ) {
Expand Down

0 comments on commit ca31fe5

Please sign in to comment.