From 73fd8cbd9fee06a10534394c8705a263a6184ca9 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sat, 16 Mar 2013 11:56:09 +0100 Subject: [PATCH] Minor change in stream handling --- audioomx.cc | 11 +++++++++++ audioomx.h | 1 + draintarget.h | 1 + stream.cc | 1 + videoomx.cc | 15 +++++++++++++-- videoomx.h | 2 ++ 6 files changed, 29 insertions(+), 2 deletions(-) diff --git a/audioomx.cc b/audioomx.cc index cf4f564..68d3c56 100644 --- a/audioomx.cc +++ b/audioomx.cc @@ -1602,6 +1602,7 @@ unsigned int AudioOMX::AdvanceMpAudioSync(const UCHAR *data,unsigned int size,un frame_size=(frame_size*144000)/(sample_rate<log("Audio", Log::DEBUG, "FRAME: %d %d %d %d %d %d",lsf,layer,bitrate_index,sample_rate,padding,framesize); *framesize=frame_size; return test; // probably FrameSync @@ -1748,6 +1749,16 @@ long long AudioOMX::correctAudioLatency(long long pts,int addsamples,int srate) return workpts; } +bool AudioOMX::DrainTargetBufferFull() +{ + //Check, if we have OMX output buffers + bool full; + input_bufs_omx_mutex.Lock(); + full=(input_bufs_omx_free.size()==0); + input_bufs_omx_mutex.Unlock(); + return full; + +} UINT AudioOMX::DeliverMediaPacket(MediaPacket packet, const UCHAR* buffer, diff --git a/audioomx.h b/audioomx.h index 74ac21d..42f525b 100644 --- a/audioomx.h +++ b/audioomx.h @@ -90,6 +90,7 @@ class AudioOMX : public Audio virtual void ResetTimeOffsets(); virtual bool DrainTargetReady() {return omx_running;}; + virtual bool DrainTargetBufferFull(); UCHAR getLastAType() {return lastAType;} diff --git a/draintarget.h b/draintarget.h index 95d5e06..e3a8f2b 100644 --- a/draintarget.h +++ b/draintarget.h @@ -70,6 +70,7 @@ class DrainTarget virtual void ResetTimeOffsets()=0; virtual bool DrainTargetReady() {return false;}; //if the draintarget is blocking in paused state, this tells that it is ready to rumble + virtual bool DrainTargetBufferFull() { return false;}; virtual bool dtsTimefix(){return false;} //determines if the draintargets needs a mixure of pts and dts or not diff --git a/stream.cc b/stream.cc index 665739b..5fb8c70 100644 --- a/stream.cc +++ b/stream.cc @@ -164,6 +164,7 @@ bool Stream::drain(bool * dataavail) { bool ret = false; if (dataavail) *dataavail=false; + if (draintarget->DrainTargetBufferFull()) return false; //We are full, no need to do something else lock(); UINT listlength = mediapackets.size(); if (listlength != 0) diff --git a/videoomx.cc b/videoomx.cc index fdf7b5d..085441e 100644 --- a/videoomx.cc +++ b/videoomx.cc @@ -1702,8 +1702,6 @@ int VideoOMX::CommandFinished(OMX_HANDLETYPE handle,OMX_U32 command,OMX_U32 data - - int VideoOMX::PrepareInputBufsOMX() //needs to be called with locked mutex { OMX_ERRORTYPE error; @@ -2562,6 +2560,19 @@ bool VideoOMX::detectIFrame(const UCHAR *buffer,unsigned int length) return false; // no frame found } + + +bool VideoOMX::DrainTargetBufferFull() +{ + //Check, if we have OMX output buffers + bool full; + input_bufs_omx_mutex.Lock(); + full=(input_bufs_omx_free.size()==0); + input_bufs_omx_mutex.Unlock(); + return full; + +} + void VideoOMX::PrepareMediaSample(const MediaPacketList& mplist,UINT samplepos) { diff --git a/videoomx.h b/videoomx.h index 7974e4a..602bc47 100644 --- a/videoomx.h +++ b/videoomx.h @@ -150,6 +150,8 @@ class VideoOMX : public Video bool iframemode; bool InIframemode() {return iframemode;}; + virtual bool DrainTargetBufferFull(); + UINT DeliverMediaPacket(MediaPacket packet,const UCHAR* bulibaver,UINT *samplepos); #define VPE_DECODER_OMX 1 -- 2.39.2