在rockchip上调试ffmpeg,播10次左右会一有一次在退出时,出现segment fault。
查了很久,释放流程都是对的。
最后增加延时做调试手段,看具体在那里出现;不在出现崩溃。最后锁定应该是在videoctx释放的时候需要增加延时。
MTV_LOGI("Decode thread Exit4");
if(is->audio_swr_ctx)
{
swr_close(is->audio_swr_ctx);
swr_free(&is->audio_swr_ctx);
is->audio_swr_ctx=NULL;
}
MTV_LOGI("Decode thread Exit5");
if( is->audio_ctx)
{
avcodec_close(is->audio_ctx);
avcodec_free_context(&is->audio_ctx);
is->audio_ctx=NULL;
packet_queue_exit(&is->audioq);
}
MTV_LOGI("Decode thread Exit6");
DecodeThread_Error5:
if(is->video_ctx)
{
avcodec_close(is->video_ctx);
}
SDL_Delay(100);
DecodeThread_Error4:
MTV_LOGI("Decode thread Exit7");
if(is->hw_device_ctx)
{
av_buffer_unref(&is->hw_device_ctx);
is->hw_device_ctx=NULL;
}
SDL_Delay(100);
DecodeThread_Error3:
MTV_LOGI("Decode thread Exit8");
if(is->video_ctx)
{
avcodec_free_context(&is->video_ctx);
is->video_ctx=NULL;
}
MTV_LOGI("Decode thread Exit9");
//SDL_Delay(100);
packet_queue_exit(&is->videoq);
//SDL_Delay(100);
MTV_LOGI("Decode thread Exit10");
//SDL_Delay(100);
DecodeThread_Error2:
MTV_LOGI("Decode thread Exit11");
//SDL_Delay(100);
avformat_close_input(&is->pFormatCtx);
///SDL_Delay(100);
is->pFormatCtx=NULL;
MTV_LOGI("All Decode Data release");