From d71ae5b4f98fdb54af69ce3fb50d7f4c25925800 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 20 Oct 2013 00:47:03 +0200 Subject: [PATCH] raspi/omx_utils: fix ordering of shutdown sequence apparently, all ports need to be disabled before the inter-component tunnels are teared down, otherwise video_decodeRIL:image pool objects will leak see http://www.raspberrypi.org/phpBB3/viewtopic.php?f=70&t=48177 --- raspi/omx_utils.c | 93 +++++++++++++++++++++++++++++++---------------- 1 file changed, 61 insertions(+), 32 deletions(-) diff --git a/raspi/omx_utils.c b/raspi/omx_utils.c index 2e9f1c5..1fce867 100644 --- a/raspi/omx_utils.c +++ b/raspi/omx_utils.c @@ -1028,9 +1028,70 @@ void omx_teardown_pipeline(struct omx_pipeline_t* pi) omx_send_command_and_wait(&pi->image_fx, OMX_CommandPortDisable, 191, NULL); } + DEBUGF("[vcodec] omx_teardown pipeline 10\n"); + + /* NOTE: The clock disable doesn't complete until after the video scheduler port is + disabled (but it completes before the video scheduler port disabling completes). */ + OERR(OMX_SendCommand(pi->clock.h, OMX_CommandPortDisable, 80, NULL)); + omx_send_command_and_wait(&pi->audio_render, OMX_CommandPortDisable, 101, NULL); + OERR(OMX_SendCommand(pi->clock.h, OMX_CommandPortDisable, 81, NULL)); + omx_send_command_and_wait(&pi->video_scheduler, OMX_CommandPortDisable, 12, NULL); + if (pi->video_decode.port_settings_changed == 2) { + //dumpport(pi->video_decode.h,131); + omx_send_command_and_wait(&pi->video_decode, OMX_CommandPortDisable, 131, NULL); + } + + DEBUGF("[vcodec] omx_teardown pipeline 11\n"); + + /* Disable video_decode input port and buffers */ + //dumpport(pi->video_decode.h,130); + omx_send_command_and_wait0(&pi->video_decode, OMX_CommandPortDisable, 130, NULL); + DEBUGF("[vcodec] omx_teardown pipeline 6\n"); + omx_free_buffers(&pi->video_decode, 130); + DEBUGF("[vcodec] omx_teardown pipeline 7\n"); + omx_send_command_and_wait1(&pi->video_decode, OMX_CommandPortDisable, 130, NULL); + + DEBUGF("[vcodec] omx_teardown pipeline 8a\n"); //dumpport(pi->video_scheduler.h,10); +#if 0 + /* ports need to be disabled before tunnels are shut down. Otherwise, + * "video_decodeRIL:image pool" buffers will leak (check with "vcdbg reloc" + * the following paranoia checks are not necessary, because + * omx_send_command_and_wait() waits for completion + */ + fprintf(stderr,"is_enabled 130\n"); + while (is_port_enabled(pi->video_decode.h, 130)) + {fprintf(stderr, "."); usleep(1);} + fprintf(stderr,"is_enabled 131\n"); + while (is_port_enabled(pi->video_decode.h, 131)) + {fprintf(stderr, "."); usleep(1);} + fprintf(stderr,"is_enabled 10\n"); + while (is_port_enabled(pi->video_scheduler.h, 10)) + {fprintf(stderr, "."); usleep(1);} + fprintf(stderr,"is_enabled 11\n"); + while (is_port_enabled(pi->video_scheduler.h, 11)) + {fprintf(stderr, "."); usleep(1);} + fprintf(stderr,"is_enabled 90\n"); + while (is_port_enabled(pi->video_render.h, 90)) + {fprintf(stderr, "."); usleep(1);} + fprintf(stderr,"is_enabled 101\n"); + while (is_port_enabled(pi->audio_render.h, 101)) + {fprintf(stderr, "."); usleep(1);} + fprintf(stderr,"is_enabled 100\n"); + while (is_port_enabled(pi->audio_render.h, 100)) + {fprintf(stderr, "."); usleep(1);} + DEBUGF("[vcodec] omx_teardown pipeline 8b\n"); +#endif + omx_show_state(&pi->video_decode,130,131,0); + dumpport(pi->video_decode.h,131); + omx_show_state(&pi->video_scheduler,10,11,12); + if (pi->do_deinterlace) { omx_show_state(&pi->image_fx,190,191,0); } + omx_show_state(&pi->video_render,90,0,0); + omx_show_state(&pi->audio_render,100,101,0); + omx_show_state(&pi->clock,80,81,0); + DEBUGF("[vcodec] omx_teardown pipeline 8c\n"); /* Teardown tunnels */ /* @@ -1044,15 +1105,6 @@ void omx_teardown_pipeline(struct omx_pipeline_t* pi) //dumpport(pi->video_decode.h,131); OERR(OMX_SetupTunnel(pi->video_scheduler.h, 10, NULL, 0)); - DEBUGF("[vcodec] omx_teardown pipeline 10\n"); - - /* NOTE: The clock disable doesn't complete until after the video scheduler port is - disabled (but it completes before the video scheduler port disabling completes). */ - OERR(OMX_SendCommand(pi->clock.h, OMX_CommandPortDisable, 80, NULL)); - omx_send_command_and_wait(&pi->audio_render, OMX_CommandPortDisable, 101, NULL); - OERR(OMX_SendCommand(pi->clock.h, OMX_CommandPortDisable, 81, NULL)); - omx_send_command_and_wait(&pi->video_scheduler, OMX_CommandPortDisable, 12, NULL); - DEBUGF("[vcodec] omx_teardown pipeline 12b\n"); if (pi->do_deinterlace) { @@ -1085,29 +1137,6 @@ void omx_teardown_pipeline(struct omx_pipeline_t* pi) [audio data] -> 100 audio_render */ - omx_show_state(&pi->video_decode,130,131,0); - dumpport(pi->video_decode.h,131); - omx_show_state(&pi->video_scheduler,10,11,12); - if (pi->do_deinterlace) { omx_show_state(&pi->image_fx,190,191,0); } - omx_show_state(&pi->video_render,90,0,0); - omx_show_state(&pi->audio_render,100,101,0); - omx_show_state(&pi->clock,80,81,0); - - if (pi->video_decode.port_settings_changed == 2) { - //dumpport(pi->video_decode.h,131); - omx_send_command_and_wait(&pi->video_decode, OMX_CommandPortDisable, 131, NULL); - } - - DEBUGF("[vcodec] omx_teardown pipeline 11\n"); - - /* Disable video_decode input port and buffers */ - //dumpport(pi->video_decode.h,130); - omx_send_command_and_wait0(&pi->video_decode, OMX_CommandPortDisable, 130, NULL); - DEBUGF("[vcodec] omx_teardown pipeline 6\n"); - omx_free_buffers(&pi->video_decode, 130); - DEBUGF("[vcodec] omx_teardown pipeline 7\n"); - //omx_send_command_and_wait1(&pi->video_decode, OMX_CommandPortDisable, 130, NULL); - //dumpport(pi->video_decode.h,130); if (is_port_enabled(pi->video_decode.h, 130)) { fprintf(stderr,"Unexpected error video_decode port 130 is not disabled\n");