From f442835dcef03bccd895f342a661407a6c901e8d Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Wed, 20 Aug 2014 20:16:59 +0200 Subject: [PATCH] Hardware JPEG rendering is now working but not perfectly --- imageomx.cc | 392 +++++++++++++++++++++++++++------------------------- imageomx.h | 2 + videoomx.cc | 8 +- videoomx.h | 2 +- 4 files changed, 213 insertions(+), 191 deletions(-) diff --git a/imageomx.cc b/imageomx.cc index d82599d..cd9bc7b 100644 --- a/imageomx.cc +++ b/imageomx.cc @@ -33,6 +33,10 @@ ImageOMX::ImageOMX(OsdVector::PictureReader * treader):OsdVector::PictureDecoder omx_running=false; pictInfValid=false; + omx_imag_decode/*dec*/=NULL; + omx_egl_render/*dec*/=NULL; + + buf_head_egl=NULL; } ImageOMX::~ImageOMX() @@ -139,7 +143,6 @@ int ImageOMX::AllocateCodecsOMX(unsigned char * buffer, unsigned int length) Log::getInstance()->log("Image", Log::DEBUG, "Init OMX Image decoder failed %x", error); video->UnlockClock(); - DeAllocateCodecsOMX(); return 0; } @@ -150,84 +153,14 @@ int ImageOMX::AllocateCodecsOMX(unsigned char * buffer, unsigned int length) Log::getInstance()->log("Image", Log::DEBUG, "Init OMX Image rend OMX_GetParameter failed %x", error); video->UnlockClock(); - DeAllocateCodecsOMX(); return 0; } omx_image_input_port = p_param.nStartPortNumber; omx_image_output_port = p_param.nStartPortNumber+1; - error=OMX_GetHandle(&omx_egl_render,VPE_OMX_EGL_REND,NULL,&callbacks); - - if (error!=OMX_ErrorNone){ - Log::getInstance()->log("Image", Log::DEBUG, "Init OMX EGL renderer failed %x", error); - video->UnlockClock(); - DeAllocateCodecsOMX(); - return 0; - } - - error=OMX_GetParameter(omx_egl_render,OMX_IndexParamVideoInit,&p_param); - if (error!=OMX_ErrorNone){ - Log::getInstance()->log("Image", Log::DEBUG, "Init OMX EGL renderer OMX_GetParameter failed %x", error); - video->UnlockClock(); - DeAllocateCodecsOMX(); - return 0; - } - omx_egl_input_port=p_param.nStartPortNumber; - omx_egl_output_port=p_param.nStartPortNumber+1; - - if (!video->DisablePort(omx_imag_decode,omx_image_input_port) || !video->DisablePort(omx_imag_decode,omx_image_output_port)) { - Log::getInstance()->log("Image", Log::DEBUG, "Disable Ports OMX Image decoder failed"); - video->UnlockClock(); - DeAllocateCodecsOMX(); - return 0; - } - - - if (!video->DisablePort(omx_egl_render,omx_egl_input_port) || !video->DisablePort(omx_egl_render,omx_egl_output_port)) { - Log::getInstance()->log("Image", Log::DEBUG, "Disable Ports OMX Image decoder failed"); - video->UnlockClock(); - DeAllocateCodecsOMX(); - return 0; - } - - if (!video->ChangeComponentState(omx_imag_decode,OMX_StateIdle)) { - Log::getInstance()->log("Image", Log::DEBUG, "image decode idle ChangeComponentState"); - video->UnlockClock(); - DeAllocateCodecsOMX(); - return 0; - } - - if (!video->ChangeComponentState(omx_egl_render,OMX_StateIdle)) { - Log::getInstance()->log("Image", Log::DEBUG, "egl render idle ChangeComponentState"); - video->UnlockClock(); - DeAllocateCodecsOMX(); - return 0; - } - - - - //Setuo chain - - error=OMX_SetupTunnel(omx_imag_decode,omx_image_output_port,omx_egl_render,omx_egl_input_port); - if (error!=OMX_ErrorNone){ - Log::getInstance()->log("Image", Log::DEBUG, "OMX_Setup tunnel decode to egl rend failed %x "); - video->UnlockClock(); - DeAllocateCodecsOMX(); - return 0; - } - - if (!video->EnablePort(omx_imag_decode,omx_image_output_port,false) || !video->EnablePort(omx_egl_render,omx_egl_input_port,false) - ) { - Log::getInstance()->log("Image", Log::DEBUG, "Enable Ports OMXdecoder rend failed"); - video->UnlockClock(); - DeAllocateCodecsOMX(); - return 0; - } - - OMX_IMAGE_PARAM_PORTFORMATTYPE ft_type; memset(&ft_type,0,sizeof(ft_type)); ft_type.nSize=sizeof(ft_type); @@ -241,69 +174,39 @@ int ImageOMX::AllocateCodecsOMX(unsigned char * buffer, unsigned int length) if (error!=OMX_ErrorNone){ Log::getInstance()->log("Image", Log::DEBUG, "Init OMX_IndexParamVImagePortFormat failed %x", error); video->UnlockClock(); - DeAllocateCodecsOMX(); return 0; } - - if ( !video->CommandFinished(omx_egl_render,OMX_CommandPortEnable,omx_egl_input_port)) { + if (!video->DisablePort(omx_imag_decode,omx_image_input_port) || !video->DisablePort(omx_imag_decode,omx_image_output_port)) { + Log::getInstance()->log("Image", Log::DEBUG, "Disable Ports OMX Image decoder failed"); video->UnlockClock(); - Log::getInstance()->log("Image", Log::DEBUG, "commandfinishes end eip"); - DeAllocateCodecsOMX(); return 0; } - if ( !video->CommandFinished(omx_imag_decode,OMX_CommandPortEnable,omx_image_output_port)) { + if (!video->ChangeComponentState(omx_imag_decode,OMX_StateIdle)) { + Log::getInstance()->log("Image", Log::DEBUG, "image decode idle ChangeComponentState"); video->UnlockClock(); - Log::getInstance()->log("Image", Log::DEBUG, "commandfinishes end iop"); - DeAllocateCodecsOMX(); return 0; } - - - if (!PrepareInputBufsOMX(true, buffer, length)) { video->UnlockClock(); Log::getInstance()->log("Image", Log::DEBUG, "prepare input bufs failed"); - DeAllocateCodecsOMX(); return 0; } -/* error=OMX_SetupTunnel(omx_aud_dec,omx_codec_output_port,omx_aud_rend,omx_rend_input_port); - if (error!=OMX_ErrorNone){ - Log::getInstance()->log("Image", Log::DEBUG, "OMX_Setup tunnel dec to render failed %x", error); - video->UnlockClock(); - DeAllocateCodecsOMX(); - return 0; - }*/ - -/* if (!video->EnablePort(omx_aud_dec,omx_codec_output_port,false) || !video->EnablePort(omx_aud_rend,omx_rend_input_port,false) - ) { - Log::getInstance()->log("Image", Log::DEBUG, "Enable Ports OMX codec rend failed"); - video->UnlockClock(); - DeAllocateCodecsOMX(); - return 0; - }*/ -/* if ( !video->CommandFinished(omx_aud_dec,OMX_CommandPortEnable,omx_codec_output_port) - || !video->CommandFinished(omx_aud_rend,OMX_CommandPortEnable,omx_rend_input_port)) { - video->UnlockClock(); - DeAllocateCodecsOMX(); - return 0; - }*/ if (!video->ChangeComponentState(omx_imag_decode,OMX_StateExecuting)) { Log::getInstance()->log("Image", Log::DEBUG, "omx_image_decode ChangeComponentState Execute"); video->UnlockClock(); - DeAllocateCodecsOMX(); return 0; } @@ -314,7 +217,6 @@ int ImageOMX::AllocateCodecsOMX(unsigned char * buffer, unsigned int length) ) { Log::getInstance()->log("Image", Log::DEBUG, "Enable Ports OMXdecoder inputfailed"); video->UnlockClock(); - DeAllocateCodecsOMX(); return 0; } @@ -332,6 +234,10 @@ int ImageOMX::AllocateCodecsOMX(unsigned char * buffer, unsigned int length) } + + + + bool ImageOMX::decodePicture(LoadIndex index, unsigned char * buffer, unsigned int length) { if (pictInfValid) return false; // does support only one image at a Time; @@ -344,7 +250,6 @@ bool ImageOMX::decodePicture(LoadIndex index, unsigned char * buffer, unsigned i VideoOMX *video=(VideoOMX*)Video::getInstance(); - if (!pictcreat) return false; int oldcancelstate; int oldcanceltype; @@ -369,7 +274,7 @@ bool ImageOMX::decodePicture(LoadIndex index, unsigned char * buffer, unsigned i bool ImageOMX::intDecodePicture(LoadIndex index, unsigned char * buffer, unsigned int length, EGLPictureCreator* pictcreat, VideoOMX *video) { - + static OMX_CALLBACKTYPE callbacks= {&VideoOMX::EventHandler_OMX,&EmptyBufferDone_OMX,&FillBufferDone_OMX}; // Use Buffer OMX_BUFFERHEADERTYPE * bufhead; @@ -408,7 +313,7 @@ bool ImageOMX::intDecodePicture(LoadIndex index, unsigned char * buffer, unsigne video->LockClock(); Log::getInstance()->log("Image", Log::DEBUG, - "decodePicture 3"); + "decodePicture 3"); video->WaitForEvent(omx_imag_decode,OMX_EventPortSettingsChanged); @@ -420,7 +325,7 @@ bool ImageOMX::intDecodePicture(LoadIndex index, unsigned char * buffer, unsigne port_def_type.nVersion.nVersion=OMX_VERSION; port_def_type.nPortIndex=omx_image_output_port; Log::getInstance()->log("Image", Log::DEBUG, - "decodePicture 3a"); + "decodePicture 3a"); error=OMX_GetParameter(omx_imag_decode,OMX_IndexParamPortDefinition, &port_def_type); if (error != OMX_ErrorNone) { @@ -430,7 +335,7 @@ bool ImageOMX::intDecodePicture(LoadIndex index, unsigned char * buffer, unsigne return false; } Log::getInstance()->log("Image", Log::DEBUG, - "decodePicture 4"); + "decodePicture 4"); @@ -438,51 +343,87 @@ bool ImageOMX::intDecodePicture(LoadIndex index, unsigned char * buffer, unsigne - video->DisablePort(omx_egl_render,omx_egl_output_port,true); - Log::getInstance()->log("Image", Log::DEBUG, - "decodePicture 4 a"); +/* video->DisablePort(omx_imag_decode,omx_image_output_port,false); Log::getInstance()->log("Image", Log::DEBUG, - "decodePicture 5"); - video->DisablePort(omx_egl_render,omx_egl_input_port,false); - Log::getInstance()->log("Image", Log::DEBUG, - "decodePicture 6"); - - - - + "decodePicture 5"); if ( !video->CommandFinished(omx_imag_decode,OMX_CommandPortDisable,omx_image_output_port)) { video->UnlockClock(); Log::getInstance()->log("Image", Log::DEBUG, "commandfinishes end iop"); return false; - } + }*/ + - if ( !video->CommandFinished(omx_egl_render,OMX_CommandPortDisable,omx_egl_input_port)) { - video->UnlockClock(); - Log::getInstance()->log("Image", Log::DEBUG, "commandfinishes end eip"); - return false; - } port_def_type.format.image.eColorFormat = OMX_COLOR_FormatYUV420PackedPlanar; port_def_type.format.image.nSliceHeight = 16; port_def_type.format.image.nStride = 0; error = OMX_SetParameter(omx_imag_decode, OMX_IndexParamPortDefinition, - &port_def_type); + &port_def_type); if (error != OMX_ErrorNone) { Log::getInstance()->log("Image", Log::DEBUG, - "Set OMX_IndexParamPortDefinition1 failed %x", error); + "Set OMX_IndexParamPortDefinition1 failed %x", error); video->UnlockClock(); return false; } Log::getInstance()->log("Image", Log::DEBUG, - "decodePicture 5 6"); + "decodePicture 5 6"); + error=OMX_GetHandle(&omx_egl_render,VPE_OMX_EGL_REND,NULL,&callbacks); + + if (error!=OMX_ErrorNone){ + Log::getInstance()->log("Image", Log::DEBUG, "Init OMX EGL renderer failed %x", error); + video->UnlockClock(); + return false; + } + + OMX_PORT_PARAM_TYPE p_param; + memset(&p_param,0,sizeof(p_param)); + p_param.nSize=sizeof(p_param); + p_param.nVersion.nVersion=OMX_VERSION; + + error=OMX_GetParameter(omx_egl_render,OMX_IndexParamVideoInit,&p_param); + if (error!=OMX_ErrorNone){ + Log::getInstance()->log("Image", Log::DEBUG, "Init OMX EGL renderer OMX_GetParameter failed %x", error); + video->UnlockClock(); + return false; + } + omx_egl_input_port=p_param.nStartPortNumber; + omx_egl_output_port=p_param.nStartPortNumber+1; + + + + + if (!video->DisablePort(omx_egl_render,omx_egl_input_port) || !video->DisablePort(omx_egl_render,omx_egl_output_port)) { + Log::getInstance()->log("Image", Log::DEBUG, "Disable Ports OMX Image decoder failed"); + video->UnlockClock(); + return false; + } + + + if (!video->ChangeComponentState(omx_egl_render,OMX_StateIdle)) { + Log::getInstance()->log("Image", Log::DEBUG, "egl render idle ChangeComponentState"); + video->UnlockClock(); + return false; + } + + + + //Setuo chain + +/* if ( !video->CommandFinished(omx_egl_render,OMX_CommandPortDisable,omx_egl_input_port)) { + video->UnlockClock(); + Log::getInstance()->log("Image", Log::DEBUG, "commandfinishes end eip"); + return false; + }*/ + -/* port_def_type.nPortIndex=omx_egl_input_port; + + /* port_def_type.nPortIndex=omx_egl_input_port; error = OMX_SetParameter(omx_egl_render, OMX_IndexParamPortDefinition, &port_def_type); if (error != OMX_ErrorNone) { @@ -522,11 +463,11 @@ bool ImageOMX::intDecodePicture(LoadIndex index, unsigned char * buffer, unsigne return false; } Log::getInstance()->log("Image", Log::DEBUG, - "getEGLPict %x",pictInf.reference); + "getEGLPict %x",pictInf.reference); port_def_type.format.video.pNativeWindow = egl_display; error = OMX_SetParameter(omx_egl_render, OMX_IndexParamPortDefinition, - &port_def_type); + &port_def_type); if (error != OMX_ErrorNone) { Log::getInstance()->log("Image", Log::DEBUG, "Set OMX_IndexParamPortDefinition3 failed %x", error); @@ -539,12 +480,48 @@ bool ImageOMX::intDecodePicture(LoadIndex index, unsigned char * buffer, unsigne + + + + + error=OMX_SetupTunnel(omx_imag_decode,omx_image_output_port,omx_egl_render,omx_egl_input_port); + if (error!=OMX_ErrorNone){ + Log::getInstance()->log("Image", Log::DEBUG, "OMX_Setup tunnel decode to egl rend failed %x "); + video->UnlockClock(); + return 0; + } + + if (!video->EnablePort(omx_imag_decode,omx_image_output_port,false) || !video->EnablePort(omx_egl_render,omx_egl_input_port,false) + ) { + Log::getInstance()->log("Image", Log::DEBUG, "Enable Ports OMXdecoder rend failed"); + video->UnlockClock(); + return 0; + } + + if ( !video->CommandFinished(omx_imag_decode,OMX_CommandPortEnable,omx_image_output_port)) { + video->UnlockClock(); + Log::getInstance()->log("Image", Log::DEBUG, "commandfinishes end iop"); + return 0; + } + + if ( !video->CommandFinished(omx_egl_render,OMX_CommandPortEnable,omx_egl_input_port)) { + video->UnlockClock(); + Log::getInstance()->log("Image", Log::DEBUG, "commandfinishes end eip"); + return 0; + } + Log::getInstance()->log("Image", Log::DEBUG, - "decodePicture 7"); + "decodePicture 7"); video->WaitForEvent(omx_egl_render,OMX_EventPortSettingsChanged); Log::getInstance()->log("Image", Log::DEBUG, - "decodePicture 8"); + "decodePicture 8"); + + + + + + error=OMX_SendCommand(omx_egl_render/*dec*/,OMX_CommandPortEnable,omx_egl_output_port/*codec*/,0); if (error!=OMX_ErrorNone){ @@ -552,7 +529,7 @@ bool ImageOMX::intDecodePicture(LoadIndex index, unsigned char * buffer, unsigne return 0; } - OMX_BUFFERHEADERTYPE *buf_head_egl=NULL; + error=OMX_UseEGLImage(omx_egl_render/*dec*/,&buf_head_egl,omx_egl_output_port/*codec*/, this, pictInf.reference); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Image", Log::DEBUG, "Use OMX_UseEGLImage failed %x", error); @@ -562,7 +539,7 @@ bool ImageOMX::intDecodePicture(LoadIndex index, unsigned char * buffer, unsigne buf_head_egl->pAppPrivate=this; Log::getInstance()->log("Image", Log::DEBUG, - "decodePicture 8 a"); + "decodePicture 8 a"); video->EnablePort(omx_imag_decode,omx_image_output_port,false); @@ -575,21 +552,21 @@ bool ImageOMX::intDecodePicture(LoadIndex index, unsigned char * buffer, unsigne Log::getInstance()->log("Image", Log::DEBUG, - "decodePicture 8 end"); + "decodePicture 8 end"); if (!video->ChangeComponentState(omx_egl_render,OMX_StateExecuting)) { Log::getInstance()->log("Image", Log::DEBUG, "omx_egl_rendd ChangeComponentState Execute"); - video->UnlockClock(); + video->UnlockClock(); return false; } Log::getInstance()->log("Image", Log::DEBUG, - "decodePicture 9"); + "decodePicture 9"); //video->EnablePort(omx_egl_render,omx_egl_output_port,false); Log::getInstance()->log("Image", Log::DEBUG, - "decodePicture 10"); + "decodePicture 10"); omx_egl_filled = false; error = OMX_FillThisBuffer(omx_egl_render, buf_head_egl); @@ -604,30 +581,21 @@ bool ImageOMX::intDecodePicture(LoadIndex index, unsigned char * buffer, unsigne while (!omx_egl_filled) { count++; - if (count>100) { + if (count>500) { Log::getInstance()->log("Image", Log::DEBUG, "No one filled my buffer"); - return false; + return false; } - MILLISLEEP(10); + MILLISLEEP(1); } omx_egl_filled = false; - video->LockClock(); - - error=OMX_FreeBuffer(omx_egl_render/*dec*/, omx_egl_output_port/*codec*/,buf_head_egl); - if (error!=OMX_ErrorNone){ - Log::getInstance()->log("Image", Log::DEBUG, "Use OMX_FreeBuffer 2 failed %x", error); - return false; - } + Log::getInstance()->log("Image", Log::DEBUG, + "decodePicture left"); - video->UnlockClock(); - Log::getInstance()->log("Image", Log::DEBUG, - "decodePicture left"); - DeAllocateCodecsOMX(); pictInfValid=true; return true; @@ -780,18 +748,28 @@ int ImageOMX::DeAllocateCodecsOMX() Log::getInstance()->log("Image", Log::DEBUG, "omx_imag_decode ChangeComponentState"); } - if (!video->ChangeComponentState(omx_egl_render,OMX_StateIdle)) { - Log::getInstance()->log("Image", Log::DEBUG, "omx_egl_render ChangeComponentState"); + if (omx_egl_render) { + + if (!video->ChangeComponentState(omx_egl_render,OMX_StateIdle)) { + Log::getInstance()->log("Image", Log::DEBUG, "omx_egl_render ChangeComponentState"); + } + /*if (!video->ChangeComponentState(omx_egl_render,OMX_StateLoaded,false)) { + Log::getInstance()->log("Image", Log::DEBUG, "omx_egl_render ChangeComponentState"); + }*/ } + /* if (!video->ChangeComponentState(omx_imag_decode,OMX_StateLoaded,false)) { + Log::getInstance()->log("Image", Log::DEBUG, "omx_imag_decode ChangeComponentState"); + }*/ + + + // TODO proper deinit sequence // first flush all buffers - error=OMX_SendCommand(omx_imag_decode,OMX_CommandFlush, omx_image_input_port, NULL); - if (error!=OMX_ErrorNone) { - Log::getInstance()->log("Image", Log::DEBUG, "OMX_Flush rend in failed %x", error); - } + + Log::getInstance()->log("Image", Log::DEBUG, "deallocatecodecsomx mark 3"); error=OMX_SendCommand(omx_imag_decode,OMX_CommandFlush, omx_image_output_port, NULL); if (error!=OMX_ErrorNone) { @@ -799,30 +777,68 @@ int ImageOMX::DeAllocateCodecsOMX() } - error=OMX_SendCommand(omx_egl_render,OMX_CommandFlush, omx_egl_input_port, NULL); - if (error!=OMX_ErrorNone) { - Log::getInstance()->log("Image", Log::DEBUG, "OMX_Flush rend in failed %x", error); + if (omx_egl_render) { - } + if (!video->ChangeComponentState(omx_egl_render,OMX_StateIdle)) { + Log::getInstance()->log("Image", Log::DEBUG, "omx_egl_render ChangeComponentState"); + } + + Log::getInstance()->log("Image", Log::DEBUG, "deallocatecodecsomx mark 4"); + + error=OMX_SendCommand(omx_egl_render,OMX_CommandFlush, omx_egl_input_port, NULL); + if (error!=OMX_ErrorNone) { + Log::getInstance()->log("Image", Log::DEBUG, "OMX_Flush rend in failed %x", error); + + } + + Log::getInstance()->log("Image", Log::DEBUG, "deallocatecodecsomx mark 5"); + + error=OMX_SendCommand(omx_egl_render,OMX_CommandFlush, omx_egl_output_port, NULL); + if (error!=OMX_ErrorNone) { + Log::getInstance()->log("Image", Log::DEBUG, "OMX_Flush rend in failed %x", error); + + } - error=OMX_SendCommand(omx_egl_render,OMX_CommandFlush, omx_egl_output_port, NULL); + Log::getInstance()->log("Image", Log::DEBUG, "deallocatecodecsomx mark 6"); + + if (!video->CommandFinished(omx_egl_render,OMX_CommandFlush,omx_egl_input_port) || + !video->CommandFinished(omx_egl_render,OMX_CommandFlush,omx_egl_output_port)) { + Log::getInstance()->log("Image", Log::DEBUG, "flush cmd clock shed failed"); + } + Log::getInstance()->log("Image", Log::DEBUG, "deallocatecodecsomx mark 6 a"); + } + error=OMX_SendCommand(omx_imag_decode,OMX_CommandFlush, omx_image_input_port, NULL); if (error!=OMX_ErrorNone) { Log::getInstance()->log("Image", Log::DEBUG, "OMX_Flush rend in failed %x", error); } + if (buf_head_egl) { + error=OMX_FreeBuffer(omx_egl_render/*dec*/, omx_egl_output_port/*codec*/,buf_head_egl); + if (error!=OMX_ErrorNone){ + Log::getInstance()->log("Image", Log::DEBUG, "Use OMX_FreeBuffer 2 failed %x", error); + } + } + + buf_head_egl=NULL; + + + + - Log::getInstance()->log("Image", Log::DEBUG, "deallocatecodecsomx mark 6"); + Log::getInstance()->log("Image", Log::DEBUG, "deallocatecodecsomx mark 6 b"); + + if (!video->CommandFinished(omx_imag_decode,OMX_CommandFlush,omx_image_input_port) || - !video->CommandFinished(omx_egl_render,OMX_CommandFlush,omx_egl_input_port) || - !video->CommandFinished(omx_imag_decode,OMX_CommandFlush,omx_image_output_port) || - !video->CommandFinished(omx_egl_render,OMX_CommandFlush,omx_egl_output_port)) { - Log::getInstance()->log("Image", Log::DEBUG, "flush cmd clock shed failed"); + !video->CommandFinished(omx_imag_decode,OMX_CommandFlush,omx_image_output_port) ) { + Log::getInstance()->log("Image", Log::DEBUG, "flush cmd clock shed failed"); } + Log::getInstance()->log("Image", Log::DEBUG, "deallocatecodecsomx mark 6 c"); + DestroyInputBufsOMX(); //We have to make sure that no buffers are in use @@ -833,24 +849,24 @@ int ImageOMX::DeAllocateCodecsOMX() Log::getInstance()->log("Image", Log::DEBUG, "Disable Tunnel Port failed 1"); } + if (omx_egl_render) { - if (!video->DisablePort(omx_egl_render,omx_egl_input_port,true)) { - Log::getInstance()->log("Image", Log::DEBUG, "Disable Tunnel Port failed 4"); - } - - + if (!video->DisablePort(omx_egl_render,omx_egl_input_port,true)) { + Log::getInstance()->log("Image", Log::DEBUG, "Disable Tunnel Port failed 4"); + } - error=OMX_SetupTunnel(omx_imag_decode,omx_image_output_port,NULL,NULL); - if (error!=OMX_ErrorNone) { - Log::getInstance()->log("Image", Log::DEBUG, "OMX_Setup tunnel teardown failed %x", error); + error=OMX_SetupTunnel(omx_imag_decode,omx_image_output_port,NULL,NULL); + if (error!=OMX_ErrorNone) { + Log::getInstance()->log("Image", Log::DEBUG, "OMX_Setup tunnel teardown failed %x", error); - } + } - error=OMX_SetupTunnel(omx_egl_render,omx_egl_input_port,NULL,NULL); - if (error!=OMX_ErrorNone) { - Log::getInstance()->log("Image", Log::DEBUG, "OMX_Setup tunnel teardown failed %x", error); + error=OMX_SetupTunnel(omx_egl_render,omx_egl_input_port,NULL,NULL); + if (error!=OMX_ErrorNone) { + Log::getInstance()->log("Image", Log::DEBUG, "OMX_Setup tunnel teardown failed %x", error); + } } @@ -862,9 +878,11 @@ int ImageOMX::DeAllocateCodecsOMX() if (error!=OMX_ErrorNone) { Log::getInstance()->log("Image", Log::DEBUG, "FreeHandle failed %d", error); } - error=OMX_FreeHandle(omx_egl_render); - if (error!=OMX_ErrorNone) { - Log::getInstance()->log("Image", Log::DEBUG, "FreeHandle failed %d", error); + if (omx_egl_render) { + error=OMX_FreeHandle(omx_egl_render); + if (error!=OMX_ErrorNone) { + Log::getInstance()->log("Image", Log::DEBUG, "FreeHandle failed %d", error); + } } video->UnlockClock(); diff --git a/imageomx.h b/imageomx.h index 292ead1..dbc2af7 100644 --- a/imageomx.h +++ b/imageomx.h @@ -95,6 +95,8 @@ class ImageOMX : public OsdVector::PictureDecoder bool omx_first_frame; bool omx_egl_filled; + OMX_BUFFERHEADERTYPE *buf_head_egl; + int initted; protected: diff --git a/videoomx.cc b/videoomx.cc index b23b4d1..81a37d4 100644 --- a/videoomx.cc +++ b/videoomx.cc @@ -1599,7 +1599,7 @@ int VideoOMX::setClockExecutingandRunning() } -int VideoOMX::ChangeComponentState(OMX_HANDLETYPE handle,OMX_STATETYPE type) //needs to be called with locked mutex +int VideoOMX::ChangeComponentState(OMX_HANDLETYPE handle,OMX_STATETYPE type,bool wait) //needs to be called with locked mutex { OMX_ERRORTYPE error; error=OMX_SendCommand(handle,OMX_CommandStateSet,type,0); @@ -1608,8 +1608,10 @@ int VideoOMX::ChangeComponentState(OMX_HANDLETYPE handle,OMX_STATETYPE type) //n return 0; } - if (!CommandFinished(handle,OMX_CommandStateSet,type)) { - return 0; + if (wait) { + if (!CommandFinished(handle,OMX_CommandStateSet,type)) { + return 0; + } } return 1; diff --git a/videoomx.h b/videoomx.h index 5885e38..5a2c39c 100644 --- a/videoomx.h +++ b/videoomx.h @@ -205,7 +205,7 @@ class VideoOMX : public Video void AddOmxEvent(VPE_OMX_EVENT new_event); void ReturnEmptyOMXBuffer(OMX_BUFFERHEADERTYPE* bulibaver); - int ChangeComponentState(OMX_HANDLETYPE handle,OMX_STATETYPE type); + int ChangeComponentState(OMX_HANDLETYPE handle,OMX_STATETYPE type, bool wait=true); int CommandFinished(OMX_HANDLETYPE handle,OMX_U32 command,OMX_U32 data2); int WaitForEvent(OMX_HANDLETYPE handle,OMX_U32 event,int wait=200); int EnablePort(OMX_HANDLETYPE handle,OMX_U32 port,bool wait); -- 2.39.5