cmarty
Posts: 38
Joined: Thu Jul 19, 2012 7:23 am
Location: Czech Republic

Correct cleanup after video playing in videocube example

Mon Aug 12, 2013 7:01 am

Hello.
In examples hello_videocube and hello_teapot there is not correctly done the code which does finishing and cleaning up.
The examples uses egl render component to render video to egl image.
I've tried to fix it up but I'm not omx skilled to find the solution.
The first strange thing above the code is :
https://github.com/raspberrypi/firmware ... deo.c#L247

Code: Select all

      // wait for EOS from render
      ilclient_wait_for_event(video_render, OMX_EventBufferFlag, 90, 0, OMX_BUFFERFLAG_EOS, 0,
                              ILCLIENT_BUFFER_FLAG_EOS, 10000);
There is use of port 90 of videorender component, but in those examples there isn't active any video_render component. Instead of it there is egl_render component.

Second: the video always finish with exit(1) at my_fill_buffer_done handler.
https://github.com/raspberrypi/firmware ... ideo.c#L48

Third: after correction of exiting in my_fill_buffer_done handler the code stuck when trying to change component's state to OMX_StateLoaded
https://github.com/raspberrypi/firmware ... deo.c#L264

Does anybody know how these examples can be modified to correctly clean up and finish the playing of video.

Ed_was_here
Posts: 4
Joined: Thu Oct 18, 2012 1:16 am

Re: Correct cleanup after video playing in videocube example

Tue Aug 20, 2013 11:54 pm

I saw those too. For your 3rd issue I removed that line and it seemed to be fine. My fixed version of the code is for the camera board, but might help you out: https://github.com/ed-was-here/userland ... xture_cube

I added a global flag "quitting" to stop the callback from copying data when closing. My shutdown code looks like this:

Code: Select all

	quitting = 1; // set flag to stop the callback from copying data
	ilclient_disable_tunnel(tunnel);
	ilclient_disable_tunnel(tunnel+1);
	ilclient_disable_tunnel(tunnel+2);
	ilclient_teardown_tunnels(tunnel);
	if (verbose) printf("close\n");
	
	ilclient_state_transition(list, OMX_StateIdle);
	
	// TODO: This hangs.  The code is never executed in the example so it might be a bug
	// The docs say ilclient_state_transition waits for the components to complete the state transition,
	// so one or more may be stuck
	//ilclient_state_transition(list, OMX_StateLoaded);
	
	if (verbose) printf("cleanup\n");
	ilclient_cleanup_components(list);
	
	if (verbose) printf("omx deinit\n");
	OMX_Deinit();
	
	if (verbose) printf("ilclient destroy\n");
	ilclient_destroy(client);
	if (verbose) printf("Done quitting preview\n");

cmarty
Posts: 38
Joined: Thu Jul 19, 2012 7:23 am
Location: Czech Republic

Re: Correct cleanup after video playing in videocube example

Mon Aug 26, 2013 7:41 am

Thanks for that. I solve the callback issue with similar code.
But disable the component state transition to OMX_StateLoaded is not a solution. I can call exit func instead an this will result with the same effect.
I want in my code to fast open new video file without destroying all omx elements and recreating it again. So I think must put them all to OMX_StateLoaded as it was in a begin.
Has anybody seen some videoplay example with egl image that can switch between playing videos.

Return to “OpenMAX”