From f8e92069dfca9908521c3190e287960528ec0579 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sun, 11 Nov 2012 22:15:05 +0100 Subject: [PATCH] Fix shutdown of osdvector and some hdmi related changes# --- osdopenvg.cc | 75 +++++++++++++++++++++++++++++++++++++++++++--------- osdopenvg.h | 1 + osdvector.cc | 2 +- videoomx.cc | 19 ++++++++----- 4 files changed, 78 insertions(+), 19 deletions(-) diff --git a/osdopenvg.cc b/osdopenvg.cc index 28bc226..85245dc 100644 --- a/osdopenvg.cc +++ b/osdopenvg.cc @@ -302,6 +302,34 @@ int OsdOpenVG::stopUpdate() return 1; } +void OsdOpenVG::purgeAllReferences() +{ + images_ref.clear(); + styles_ref.clear(); // remove all references + + + map::iterator mitty=monobitmaps.begin(); + while (mitty!=monobitmaps.end()) { + vgDestroyImage((VGImage)(*mitty).second); + mitty++; + } + monobitmaps.clear(); + + map::iterator jitty=jpegs.begin(); + while (jitty!=jpegs.end()) { + vgDestroyImage((VGImage)(*jitty).second); + jitty++; + } + jpegs.clear(); + + map,unsigned int>::iterator sitty=styles.begin(); + while (sitty!=styles.end()) { + vgDestroyPaint((VGPaint)(*sitty).second); + sitty++; + } + styles.clear(); + +} int OsdOpenVG::shutdown() { @@ -310,27 +338,45 @@ int OsdOpenVG::shutdown() initted = 0; Log::getInstance()->log("OSD", Log::DEBUG, "shutdown mark1"); threadStop(); + Log::getInstance()->log("OSD", Log::DEBUG, "shutdown mark1a"); + //(((VideoOMX*)Video::getInstance())->shutdownUsingOSDObjects()); + if (eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context)== EGL_FALSE) { + Log::getInstance()->log("OSD", Log::WARN, "Making egl Current failed in shutdown %x",eglGetError()); + } + if (eglBindAPI(EGL_OPENVG_API)==EGL_FALSE) { + Log::getInstance()->log("OSD", Log::WARN, "Binding openvg api thread failed! %x",eglGetError()); + } + Log::getInstance()->log("OSD", Log::DEBUG, "shutdown mark2"); processTasks(); Log::getInstance()->log("OSD", Log::DEBUG, "shutdown mark3"); taskmutex.Lock(); vgmutex.Lock(); - //(((VideoOMX*)Video::getInstance())->shutdownUsingOSDObjects()); + //purgeAllReferences(); + vgDestroyFont(vgfont); vgDestroyFont(vgttfont); vgDestroyPaint(vgttpaint); destroyPaths(); + float colclear[]={0.8f,0.8f,0.8f,1.f}; + vgSetfv(VG_CLEAR_COLOR,4,colclear); vgClear(0,0,BACKBUFFER_WIDTH,BACKBUFFER_HEIGHT); eglSwapBuffers(egl_display, egl_surface); Log::getInstance()->log("OSD", Log::DEBUG, "Making egl current out final"); eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ); - eglDestroySurface(egl_display,egl_surface); - eglDestroyContext(egl_display,egl_context); - eglTerminate(egl_display ); + if (eglDestroySurface(egl_display,egl_surface)==EGL_FALSE) { + Log::getInstance()->log("OSD", Log::ERR, "eglDestroySurface failed %x",eglGetError()); + } + if (eglDestroyContext(egl_display,egl_context)==EGL_FALSE) { + Log::getInstance()->log("OSD", Log::ERR, "eglDestroyContext failed %x",eglGetError()); + } + if (eglTerminate(egl_display )==EGL_FALSE) { + Log::getInstance()->log("OSD", Log::ERR, "eglTerminate failed %x",eglGetError()); + } DISPMANX_UPDATE_HANDLE_T bcm_update; bcm_update=vc_dispmanx_update_start(0); @@ -352,11 +398,15 @@ int OsdOpenVG::shutdown() void OsdOpenVG::threadMethod() { // We have to claim the egl context for this thread - + Log::getInstance()->log("OSD", Log::NOTICE, "Entering drawing thread"); if (eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context)== EGL_FALSE) { Log::getInstance()->log("OSD", Log::WARN, "Making egl Current failed in thread %x",eglGetError()); return; } + if (eglBindAPI(EGL_OPENVG_API)==EGL_FALSE) { + Log::getInstance()->log("OSD", Log::WARN, "Binding openvg api thread failed! %x",eglGetError()); + return; + } int ts=0; while (true) { @@ -373,7 +423,12 @@ void OsdOpenVG::threadMethod() } if (processTasks()) ts=0; } - threadCheckExit(); + if (!threadIsActive()) { + if (eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT )== EGL_FALSE) { + Log::getInstance()->log("OSD", Log::WARN, "Making egl Current out thread failed"); + } + threadCheckExit(); + } if (ts!=0) { struct timespec target_time; clock_gettime(CLOCK_REALTIME,&target_time); @@ -388,7 +443,7 @@ void OsdOpenVG::threadMethod() } //Sleep(1); } - //eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ); + eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ); } @@ -396,13 +451,9 @@ void OsdOpenVG::threadPostStopCleanup() { //Doing nothing //goo; + Log::getInstance()->log("OSD", Log::NOTICE, "Exiting drawing thread"); } - - - - - void OsdOpenVG::InternalRendering(){ vgmutex.Lock(); float colclear[]={1.f,1.0f,1.f,1.f}; diff --git a/osdopenvg.h b/osdopenvg.h index 9a1e9ac..44e88fe 100644 --- a/osdopenvg.h +++ b/osdopenvg.h @@ -117,6 +117,7 @@ protected: bool haveOpenVGResponse(unsigned int id,unsigned int * resp); unsigned int putOpenVGCommand(OpenVGCommand& comm,bool wait); unsigned int handleTask(OpenVGCommand& command); + void purgeAllReferences(); unsigned int wait_id; FT_Library ft_library; diff --git a/osdvector.cc b/osdvector.cc index 322ee4b..457cd80 100644 --- a/osdvector.cc +++ b/osdvector.cc @@ -73,7 +73,7 @@ int OsdVector::restore() curdraw++; } //also clear all handles, they are now invalid, no need to release them - images_ref.clear();; + images_ref.clear(); monobitmaps.clear(); jpegs.clear(); styles.clear(); diff --git a/videoomx.cc b/videoomx.cc index 918b71a..44f89da 100644 --- a/videoomx.cc +++ b/videoomx.cc @@ -603,8 +603,10 @@ int VideoOMX::signalOff() { //TODO reinit osd Log::getInstance()->log("Video", Log::NOTICE, "signalOff"); - vc_tv_power_off(); Osd::getInstance()->stopUpdate(); // turn off drawing thread + Remote::getInstance()->shutdown(); + vc_tv_power_off(); + Remote::getInstance()->init(""); signalon=false; return 1; } @@ -612,8 +614,8 @@ int VideoOMX::signalOff() int VideoOMX::signalOn() { if (!signalon) { - Log::getInstance()->log("Video", Log::NOTICE, "signalOn"); Osd::getInstance()->shutdown(); + Log::getInstance()->log("Video", Log::NOTICE, "signalOn"); selectVideoMode(0); Osd::getInstance()->restore(); Osd::getInstance()->init((void*)""); @@ -652,16 +654,21 @@ int VideoOMX::sync() } void VideoOMX::interlaceSwitch4Demux() { - return ; + return; Demuxer *demux=Demuxer::getInstance(); if ( (outputinterlaced && !demux->getInterlaced()) || (!outputinterlaced && demux->getInterlaced())) { if (hdmi && (demux->getHorizontalSize()>720 || demux->getInterlaced() )) { // only switch if hdmi and HD or interlaced SD material Log::getInstance()->log("Video", Log::NOTICE, "switch interlacing %d",demux->getInterlaced()); + + //OMX_Deinit(); + int set_interlaced=0; + if (demux->getHorizontalSize()>720 && demux->getInterlaced()) { + set_interlaced=1; + } + selectVideoMode(set_interlaced); + //OMX_Init(); Osd::getInstance()->shutdown(); - OMX_Deinit(); - selectVideoMode(demux->getInterlaced()); - OMX_Init(); Osd::getInstance()->restore(); Osd::getInstance()->init((void*)""); BoxStack::getInstance()->redrawAllBoxes(); -- 2.39.5