From aef44cb41a73d160662b18dc7c746f0bd3b599e0 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sun, 4 Nov 2012 16:11:01 +0100 Subject: [PATCH] Preparations for dynamic mode switching --- audioomx.cc | 2 ++ osdopenvg.cc | 41 ++++++++++++++++++++++++----------------- osdopenvg.h | 1 + remotelinux.cc | 3 +++ videoomx.cc | 27 +++++++++++++++++++++++++-- videoomx.h | 3 +++ 6 files changed, 58 insertions(+), 19 deletions(-) diff --git a/audioomx.cc b/audioomx.cc index de9264e..4d3f5b5 100644 --- a/audioomx.cc +++ b/audioomx.cc @@ -546,6 +546,8 @@ int AudioOMX::play() { lastAType=MPTYPE_MPEG_AUDIO; Log::getInstance()->log("Audio", Log::DEBUG, "enter play"); + ((VideoOMX*)Video::getInstance())->interlaceSwitch4Demux(); // switch resolution if necessary + if (!AllocateCodecsOMX()) { return 0; } diff --git a/osdopenvg.cc b/osdopenvg.cc index 709fa36..b78a1b4 100644 --- a/osdopenvg.cc +++ b/osdopenvg.cc @@ -57,6 +57,7 @@ OsdOpenVG::OsdOpenVG() mode=0; aspect_correction=1.; + freetype_inited=false; wait_id=1; } @@ -69,6 +70,7 @@ OsdOpenVG::~OsdOpenVG() shutdown(); } + if (freetype_inited) FT_Done_Face(ft_face); vgmutex.Unlock(); taskmutex.Unlock(); @@ -316,7 +318,8 @@ int OsdOpenVG::shutdown() vgmutex.Lock(); //(((VideoOMX*)Video::getInstance())->shutdownUsingOSDObjects()); - FT_Done_Face(ft_face); + + vgDestroyFont(vgfont); vgDestroyFont(vgttfont); vgDestroyPaint(vgttpaint); @@ -466,24 +469,28 @@ unsigned int OsdOpenVG::loadTTchar(cTeletextChar c) int OsdOpenVG::loadFont() { - int error=FT_Init_FreeType(&ft_library); + int error; float font_size=16.f; - if (error) - { - Log::getInstance()->log("OSD", Log::WARN, "Could not load freetype %x",error); - return 0; - } + if (!freetype_inited) { + error=FT_Init_FreeType(&ft_library); + if (error) + { + Log::getInstance()->log("OSD", Log::WARN, "Could not load freetype %x",error); + return 0; + } - error=FT_New_Memory_Face(ft_library,font_data,font_data_end-font_data,0,&ft_face ); - if (error) { - Log::getInstance()->log("OSD", Log::WARN, "Could not load font face %x",error); - return 0; - } - error=FT_Set_Char_Size(ft_face,0,font_size*64,0,0 /*dpi*/); - if (error) { - FT_Done_Face(ft_face); - Log::getInstance()->log("OSD", Log::WARN, "Could not set face size %x",error); - return 0; + error=FT_New_Memory_Face(ft_library,font_data,font_data_end-font_data,0,&ft_face ); + if (error) { + Log::getInstance()->log("OSD", Log::WARN, "Could not load font face %x",error); + return 0; + } + error=FT_Set_Char_Size(ft_face,0,font_size*64,0,0 /*dpi*/); + if (error) { + FT_Done_Face(ft_face); + Log::getInstance()->log("OSD", Log::WARN, "Could not set face size %x",error); + return 0; + } + freetype_inited=true; } vgfont=vgCreateFont(0); FT_ULong cur_char; diff --git a/osdopenvg.h b/osdopenvg.h index 97b19a4..6882c9c 100644 --- a/osdopenvg.h +++ b/osdopenvg.h @@ -154,6 +154,7 @@ protected: EGLConfig egl_ourconfig; float font_height; float aspect_correction; + bool freetype_inited; }; diff --git a/remotelinux.cc b/remotelinux.cc index 08fedb9..0a93201 100644 --- a/remotelinux.cc +++ b/remotelinux.cc @@ -199,10 +199,13 @@ int RemoteLinux::shutdown() void RemoteLinux::deinitCec() { if (cec_adap) { + Log::getInstance()->log("Remote", Log::NOTICE, "Shutdown libcec begin"); cec_adap->SetInactiveView(); cec_adap->Close(); + vc_cec_register_callback(NULL, NULL);//deactivate callback! UnloadLibCec(cec_adap); cec_adap = NULL; + Log::getInstance()->log("Remote", Log::NOTICE, "Shutdown libcec end"); } } diff --git a/videoomx.cc b/videoomx.cc index b2c9c37..07f983d 100644 --- a/videoomx.cc +++ b/videoomx.cc @@ -61,6 +61,7 @@ VideoOMX::VideoOMX() { deinterlace=2; //advanced signalon=false; + outputinterlaced=0; } @@ -368,8 +369,8 @@ void VideoOMX::selectVideoMode(int interlaced) if (all_my_modes<=0 || connection==COMPOSITERGB ) { /* analog tv case */ Log::getInstance()->log("Video", Log::NOTICE, "No CEA and DMT modes found analog tv case?"); - vc_tv_power_off(); Remote::getInstance()->shutdown(); + vc_tv_power_off(); SDTV_MODE_T setmode=SDTV_MODE_PAL; SDTV_OPTIONS_T options; @@ -431,8 +432,8 @@ void VideoOMX::selectVideoMode(int interlaced) } } - vc_tv_power_off(); Remote::getInstance()->shutdown(); + vc_tv_power_off(); if (mymode) { Log::getInstance()->log("Video", Log::NOTICE, "Switch to optimum mode"); vc_tv_hdmi_power_on_explicit(HDMI_MODE_HDMI,group,mymode->code); @@ -445,6 +446,7 @@ void VideoOMX::selectVideoMode(int interlaced) (EDID_MODE_MATCH_FLAG_T)(HDMI_MODE_MATCH_FRAMERATE|HDMI_MODE_MATCH_RESOLUTION|HDMI_MODE_MATCH_SCANMODE)); } hdmi=true; + outputinterlaced=interlaced; } Remote::getInstance()->init(""); @@ -629,6 +631,25 @@ int VideoOMX::sync() return 1; } +void VideoOMX::interlaceSwitch4Demux() { + 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()); + Osd::getInstance()->shutdown(); + selectVideoMode(demux->getInterlaced()); + Osd::getInstance()->restore(); + Osd::getInstance()->init((void*)""); + BoxStack::getInstance()->redrawAllBoxes(); + initted=1; + + } + + } +} + int VideoOMX::play() { if (!initted) @@ -636,6 +657,8 @@ int VideoOMX::play() { iframemode = false; Log::getInstance()->log("Video", Log::DEBUG, "enter play"); + interlaceSwitch4Demux(); + if (AllocateCodecsOMX()) { return 1; // Otherwise fall back to libav diff --git a/videoomx.h b/videoomx.h index dd0ee0e..3371aad 100644 --- a/videoomx.h +++ b/videoomx.h @@ -216,6 +216,8 @@ class VideoOMX : public Video void clockPause(); void clockUnpause(); + void interlaceSwitch4Demux(); + Mutex clock_mutex; //clock mutex is now responsible for all omx stuff long long cur_clock_time; @@ -275,6 +277,7 @@ class VideoOMX : public Video bool signalon; bool pendingmodechange; bool hdmi; + int outputinterlaced; -- 2.39.5