From d60abd97d15ce1f846c9926ac43f5df83975ee10 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sat, 10 Nov 2012 11:31:01 +0100 Subject: [PATCH] Change pause handling, as suggested by davep --- audioomx.cc | 41 +++++++++------------------------ audioomx.h | 1 - videoomx.cc | 65 +++++++++++++++++++++++++---------------------------- videoomx.h | 2 +- 4 files changed, 41 insertions(+), 68 deletions(-) diff --git a/audioomx.cc b/audioomx.cc index 4d3f5b5..46b59ed 100644 --- a/audioomx.cc +++ b/audioomx.cc @@ -1088,9 +1088,9 @@ int AudioOMX::AllocateCodecsOMX() video->UnlockClock(); - paused=false; omx_running=true; setVolume(volume); + video->clockUnpause(); if (!video->setClockExecutingandRunning()) return 0; @@ -1441,42 +1441,21 @@ int AudioOMX::unMute() int AudioOMX::pause() { if (!initted) return 0; - if (!paused) { - paused = true; - VideoOMX *vw = (VideoOMX*) Video::getInstance(); - vw->LockClock(); - if (omx_running) { - OMX_ERRORTYPE error; - error = OMX_SendCommand(omx_aud_rend, OMX_CommandFlush, - omx_rend_input_port, NULL); - if (error != OMX_ErrorNone) { - Log::getInstance()->log("Audio", Log::DEBUG, - "OMX_Flush rend in failed %x", error); - } - if (!vw->ChangeComponentState(omx_aud_rend,OMX_StateIdle)) { - Log::getInstance()->log("Audio", Log::DEBUG, " pause aud_rend idle ChangeComponentState"); - } - } - vw->UnlockClock(); - vw->clockPause(); - } + VideoOMX *vw = (VideoOMX*) Video::getInstance(); + vw->clockPause(); + return 1; } int AudioOMX::unPause() { if (!initted) return 0; - if (paused) { - paused=false; // may be also change omx clock - VideoOMX *vw = (VideoOMX*) Video::getInstance(); - if (omx_running) { - if (!vw->ChangeComponentState(omx_aud_rend,OMX_StateExecuting)) { - Log::getInstance()->log("Audio", Log::DEBUG, " unpause aud_rend idle ChangeComponentState"); - } - } - vw->clockUnpause(); - } + + VideoOMX *vw = (VideoOMX*) Video::getInstance(); + + vw->clockUnpause(); + return 1; } @@ -1671,7 +1650,7 @@ UINT AudioOMX::DeliverMediaPacket(MediaPacket packet, const UCHAR* buffer, } if (!omx_running) return 0; // if we are not runnig do not do this - if (paused) return 0; //Block if we pause + //if (paused) return 0; //Block if we pause //Log::getInstance()->log("Audio", Log::DEBUG, "DMP mark 1"); //Log::getInstance()->log("Audio", Log::DEBUG, "DeliverMediaPacketOMX time %lld",packet.presentation_time); diff --git a/audioomx.h b/audioomx.h index b166e0d..ddbc9d3 100644 --- a/audioomx.h +++ b/audioomx.h @@ -108,7 +108,6 @@ class AudioOMX : public Audio MediaPacket packet; UINT packetpos; - bool paused; bool hdmi; // use hdmi as audio output bool passthrough; // use audio passthrough for the current audio type diff --git a/videoomx.cc b/videoomx.cc index db69e66..2078de4 100644 --- a/videoomx.cc +++ b/videoomx.cc @@ -442,7 +442,7 @@ void VideoOMX::selectVideoMode(int interlaced) outputinterlaced=interlaced; } else { /* analog tv case */ - Log::getInstance()->log("Video", Log::NOTICE, "No CEA and DMT modes found analog tv case?"); + Log::getInstance()->log("Video", Log::NOTICE, "Analog tv case"); Remote::getInstance()->shutdown(); vc_tv_power_off(); SDTV_MODE_T setmode=SDTV_MODE_PAL; @@ -888,20 +888,20 @@ int VideoOMX::getClockVideoandInit() void VideoOMX::clockUnpause() { OMX_ERRORTYPE error; + Log::getInstance()->log("Video", Log::NOTICE, "enter Clockunpause"); clock_mutex.Lock(); - if (clock_references>0) { - OMX_TIME_CONFIG_CLOCKSTATETYPE clock_conf; - memset(&clock_conf,0,sizeof(clock_conf)); - clock_conf.nSize=sizeof(clock_conf); - clock_conf.nVersion.nVersion=OMX_VERSION; - clock_conf.eState=OMX_TIME_ClockStateRunning; - clock_conf.nStartTime=intToOMXTicks(0); - clock_conf.nOffset=intToOMXTicks(0); - clock_conf.nWaitMask=OMX_CLOCKPORT1; - error=OMX_SetConfig(omx_clock,OMX_IndexConfigTimeClockState,&clock_conf); + if (clock_references>0 && clockpaused) { + OMX_TIME_CONFIG_SCALETYPE scale_type; + memset(&scale_type,0,sizeof(scale_type)); + scale_type.nSize=sizeof(scale_type); + scale_type.nVersion.nVersion=OMX_VERSION; + scale_type.xScale=1<<16; + error=OMX_SetConfig(omx_clock,OMX_IndexConfigTimeScale,&scale_type); if (error!=OMX_ErrorNone) { - Log::getInstance()->log("Video", Log::DEBUG, "ClockUnpause IndexConfigTimeClockState failed %x", error); + Log::getInstance()->log("Video", Log::DEBUG, "ClockUnpause OMX_IndexConfigTimeScale failed %x", error); } + Log::getInstance()->log("Video", Log::NOTICE, "set playback speed ClockUnpause"); + clockpaused=false; } clock_mutex.Unlock(); } @@ -910,20 +910,20 @@ void VideoOMX::clockUnpause() void VideoOMX::clockPause() { OMX_ERRORTYPE error; + Log::getInstance()->log("Video", Log::NOTICE, "enter ClockPause"); clock_mutex.Lock(); - if (clock_references>0) { - OMX_TIME_CONFIG_CLOCKSTATETYPE clock_conf; - memset(&clock_conf,0,sizeof(clock_conf)); - clock_conf.nSize=sizeof(clock_conf); - clock_conf.nVersion.nVersion=OMX_VERSION; - clock_conf.eState=OMX_TIME_ClockStateStopped; - clock_conf.nStartTime=intToOMXTicks(0); - clock_conf.nOffset=intToOMXTicks(0); - clock_conf.nWaitMask=OMX_CLOCKPORT1; - error=OMX_SetConfig(omx_clock,OMX_IndexConfigTimeClockState,&clock_conf); + if (clock_references>0 && !clockpaused) { + OMX_TIME_CONFIG_SCALETYPE scale_type; + memset(&scale_type,0,sizeof(scale_type)); + scale_type.nSize=sizeof(scale_type); + scale_type.nVersion.nVersion=OMX_VERSION; + scale_type.xScale=0; + error=OMX_SetConfig(omx_clock,OMX_IndexConfigTimeScale,&scale_type); if (error!=OMX_ErrorNone) { - Log::getInstance()->log("Video", Log::DEBUG, "ClockUnpause IndexConfigTimeClockState failed %x", error); + Log::getInstance()->log("Video", Log::DEBUG, "ClockPause OMX_IndexConfigTimeScale failed %x", error); } + Log::getInstance()->log("Video", Log::NOTICE, "set playback speed ClockPause"); + clockpaused=true; } clock_mutex.Unlock(); } @@ -1433,10 +1433,11 @@ int VideoOMX::AllocateCodecsOMX() //playbacktimeoffset=-GetCurrentSystemTime(); - paused=false; + iframemode=false; omx_running=true; clock_mutex.Unlock(); + clockUnpause(); updateMode(); setClockExecutingandRunning(); @@ -2122,12 +2123,8 @@ int VideoOMX::pause() { if (!initted) return 0; Log::getInstance()->log("Video", Log::DEBUG, "enter pause"); - if (!paused) { - paused=true; - //maybe also change omx clock? - //pausetimecode=GetCurrentSystemTime(); - - } + // clockPause(); + // ignore it audio handles this return 1; } @@ -2136,10 +2133,8 @@ int VideoOMX::unPause() // FIXME get rid - same as play!! Not here! if (!initted) return 0; Log::getInstance()->log("Video", Log::DEBUG, "enter unpause"); - if (paused) { - // playbacktimeoffset+=GetCurrentSystemTime()-pausetimecode; - paused=false; // may be also change omx clock - } + //clockUnpause(); + //ignore it audio handles this return 1; } @@ -2545,7 +2540,7 @@ UINT VideoOMX::DeliverMediaPacket(MediaPacket packet, if (!omx_running) return 0; // if we are not runnig do not do this - if (paused) return 0; //Block if we pause + //if (paused) return 0; //Block if we pause // Log::getInstance()->log("Video", Log::DEBUG, "DMP mark 1"); //Log::getInstance()->log("Video", Log::DEBUG, "DeliverMediaPacketOMX time %lld",packet.presentation_time); diff --git a/videoomx.h b/videoomx.h index ea3c247..026757a 100644 --- a/videoomx.h +++ b/videoomx.h @@ -166,7 +166,7 @@ class VideoOMX : public Video // long long playbacktimeoffset; //this is the offset between the media time and system clock // long long pausetimecode; - bool paused; + bool clockpaused; /* static long long GetCurrentSystemTime(); static void WaitUntil(long long time); -- 2.39.5