From ed69ebb1136b2651c8684af2095ecb79a330e7ef Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sun, 23 Feb 2020 16:14:43 +0000 Subject: [PATCH] Convert all uses of Mutex to std::mutex --- audioomx.cc | 73 ++++++------ audioomx.h | 18 ++- boxstack.cc | 46 ++++---- boxstack.h | 13 +-- demuxermedia.h | 2 - demuxerts.cc | 19 ++- demuxerts.h | 7 +- demuxervdr.cc | 19 ++- demuxervdr.h | 7 +- dsallocator.cc | 69 ++++++----- dsallocator.h | 6 +- imageomx.cc | 39 +++---- imageomx.h | 6 +- mutex.cc | 60 ---------- mutex.h | 47 -------- objects.mk | 2 +- osdopengl.cc | 39 +++---- osdopengl.h | 23 +--- osdopenvg.cc | 66 +++++------ osdopenvg.h | 10 +- osdvector.cc | 111 +++++++++--------- osdvector.h | 13 ++- osdwinvector.cc | 44 +++---- osdwinvector.h | 17 ++- surfaceopengl.cc | 29 +++-- surfaceopengl.h | 10 +- surfacevector.cc | 63 +++++----- surfacevector.h | 3 +- videoomx.cc | 293 +++++++++++++++++++++++------------------------ videoomx.h | 21 ++-- 30 files changed, 511 insertions(+), 664 deletions(-) delete mode 100644 mutex.cc delete mode 100644 mutex.h diff --git a/audioomx.cc b/audioomx.cc index f948e76..d331d37 100644 --- a/audioomx.cc +++ b/audioomx.cc @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #include "audioomx.h" @@ -513,11 +512,11 @@ OMX_ERRORTYPE AudioOMX::EmptyBufferDone_OMX(OMX_IN OMX_HANDLETYPE hcomp,OMX_IN O } void AudioOMX::ReturnEmptyOMXBuffer(OMX_BUFFERHEADERTYPE* buffer){ - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); //Log::getInstance()->log("Audio", Log::NOTICE, "ReturnEmptyOMXBuffer %d",input_bufs_omx_free.size()); input_bufs_omx_free.push_back(buffer); //Log::getInstance()->log("Audio", Log::NOTICE, "ReturnEmptyOMXBuffer %d",input_bufs_omx_free.size()); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); VideoOMX *video=(VideoOMX*)Video::getInstance(); video->signalOmx(); } @@ -813,7 +812,7 @@ int AudioOMX::ChangeAudioPortConfig(bool disport) //clock aka omx mutex needs to } int AudioOMX::InitDecoderLibAV() { - libav_mutex.Lock(); + libav_mutex.lock(); ac3codec_context_libav = avcodec_alloc_context3(ac3codec_libav); if (!ac3codec_context_libav) { Log::getInstance()->log("Audio", Log::DEBUG, "Alloc avcodec for ac3 decoding context failed!"); @@ -835,7 +834,7 @@ int AudioOMX::InitDecoderLibAV() int avc_ret = avcodec_open2(ac3codec_context_libav, ac3codec_libav, NULL); if (avc_ret < 0) { Log::getInstance()->log("Audio", Log::DEBUG, "Opening libav codec failed \n"); - libav_mutex.Unlock(); + libav_mutex.unlock(); return 0; } @@ -860,7 +859,7 @@ int AudioOMX::InitDecoderLibAV() avc_ret = avcodec_open2(aaclatmcodec_context_libav, aaclatmcodec_libav, NULL); if (avc_ret < 0) { Log::getInstance()->log("Audio", Log::DEBUG, "Opening libav codec failed \n"); - libav_mutex.Unlock(); + libav_mutex.unlock(); return 0; } @@ -868,7 +867,7 @@ int AudioOMX::InitDecoderLibAV() mp23codec_context_libav = avcodec_alloc_context3(mp23codec_libav); if (!ac3codec_context_libav) { Log::getInstance()->log("Audio", Log::DEBUG, "Alloc avcodec for mp23 decoding context failed!"); - libav_mutex.Unlock(); + libav_mutex.unlock(); return 0; } @@ -887,7 +886,7 @@ int AudioOMX::InitDecoderLibAV() avc_ret = avcodec_open2(mp23codec_context_libav, mp23codec_libav, NULL); if (avc_ret < 0) { Log::getInstance()->log("Audio", Log::DEBUG, "Opening libav codec failed \n"); - libav_mutex.Unlock(); + libav_mutex.unlock(); return 0; } @@ -914,7 +913,7 @@ int AudioOMX::InitDecoderLibAV() #else decode_frame_libav=avcodec_alloc_frame(); #endif - libav_mutex.Unlock(); + libav_mutex.unlock(); decompress_buffer_filled=0; @@ -925,7 +924,7 @@ int AudioOMX::InitDecoderLibAV() void AudioOMX::DeinitDecoderLibAV() { - libav_mutex.Lock(); + libav_mutex.lock(); if (ac3codec_context_libav) { avcodec_close(ac3codec_context_libav); av_free(ac3codec_context_libav); @@ -946,7 +945,7 @@ void AudioOMX::DeinitDecoderLibAV() { } - libav_mutex.Unlock(); + libav_mutex.unlock(); } @@ -1220,13 +1219,13 @@ int AudioOMX::PrepareInputBufsOMX(bool setportdef) //needs to be called with loc return 0; } - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); for (unsigned int i=0; i< port_def_type.nBufferCountActual;i++) { OMX_BUFFERHEADERTYPE *buf_head=NULL; error=OMX_AllocateBuffer(omx_aud_rend/*dec*/,&buf_head,omx_rend_input_port/*codec*/,NULL,port_def_type.nBufferSize); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Audio", Log::DEBUG, "Use OMX_AllocateBuffer failed %x", error); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); return 0; } input_bufs_omx_all.push_back(buf_head); @@ -1236,7 +1235,7 @@ int AudioOMX::PrepareInputBufsOMX(bool setportdef) //needs to be called with loc firstsynched=false; cur_input_buf_omx=NULL; - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); if (!video->CommandFinished(omx_aud_rend/*dec*/,OMX_CommandPortEnable,omx_rend_input_port /*codec*/)) { return 0; @@ -1250,19 +1249,19 @@ int AudioOMX::DestroyInputBufsOMX() //call with clock mutex locked OMX_ERRORTYPE error; cur_input_buf_omx=NULL; - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); for (UINT i=0; i< input_bufs_omx_all.size();i++) { error=OMX_FreeBuffer(omx_aud_rend/*dec*/,omx_rend_input_port/*codec*/,input_bufs_omx_all[i]); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Audio", Log::DEBUG, "Use OMX_FreeBuffer failed %x", error); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); return 0; } } input_bufs_omx_all.clear(); input_bufs_omx_free.clear(); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); return 1; } @@ -1272,7 +1271,7 @@ int AudioOMX::DestroyInputBufsOMXwhilePlaying() //call with clock mutex locked //OMX_ERRORTYPE error; cur_input_buf_omx=NULL; - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); while (input_bufs_omx_all.size()>0) { if (input_bufs_omx_free.size()>0) { // Destroy one buffer @@ -1286,14 +1285,14 @@ int AudioOMX::DestroyInputBufsOMXwhilePlaying() //call with clock mutex locked } } } else { - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); MILLISLEEP(5); - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); } } Log::getInstance()->log("Audio", Log::DEBUG, "DestroyInputBufsOMXwhilePlaying %d %d", input_bufs_omx_all.size(),input_bufs_omx_free.size()); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); return 1; } @@ -1793,9 +1792,9 @@ bool AudioOMX::DrainTargetBufferFull() { //Check, if we have OMX output buffers bool full; - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); full=(input_bufs_omx_free.size()==0); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); return full; } @@ -1913,9 +1912,9 @@ UINT AudioOMX::DeliverMediaPacket(MediaPacket mpacket, const UCHAR* buffer, } } if (!cur_input_buf_omx) { - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); if (input_bufs_omx_free.size()==0) { - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); //Log::getInstance()->log("Audio", Log::DEBUG, "DMP mark 6"); //Log::getInstance()->log("Audio", Log::DEBUG, "Deliver MediaPacket no free sample"); return 0; // we do not have a free media sample @@ -1926,7 +1925,7 @@ UINT AudioOMX::DeliverMediaPacket(MediaPacket mpacket, const UCHAR* buffer, cur_input_buf_omx->nOffset=0; cur_input_buf_omx->nTimeStamp=VideoOMX::intToOMXTicks(0); input_bufs_omx_free.pop_front(); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); } //Log::getInstance()->log("Audio", Log::DEBUG, "DMP mark 7"); @@ -2020,9 +2019,9 @@ UINT AudioOMX::DeliverMediaPacket(MediaPacket mpacket, const UCHAR* buffer, cur_input_buf_omx=NULL; if (haveToCopy>0) { // get5 new buffer - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); if (input_bufs_omx_free.size()==0) { - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); // Log::getInstance()->log("Audio", Log::DEBUG, "Deliver MediaPacket no free sample2"); return *samplepos; // we do not have a free media sample } @@ -2032,7 +2031,7 @@ UINT AudioOMX::DeliverMediaPacket(MediaPacket mpacket, const UCHAR* buffer, cur_input_buf_omx->nFlags=OMX_BUFFERFLAG_TIME_UNKNOWN; cur_input_buf_omx->nTimeStamp=VideoOMX::intToOMXTicks(0); input_bufs_omx_free.pop_front(); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); } //Log::getInstance()->log("Audio", Log::DEBUG, "DMP mark 12"); @@ -2135,13 +2134,13 @@ UINT AudioOMX::DeliverMediaPacket(MediaPacket mpacket, const UCHAR* buffer, pthread_testcancel(); pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldcancelstate); pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldcanceltype); - libav_mutex.Lock(); + libav_mutex.lock(); if (!omx_running || !mp23codec_context_libav || !ac3codec_context_libav) { - libav_mutex.Unlock(); + libav_mutex.unlock(); return *samplepos; } - libav_mutex.Unlock(); + libav_mutex.unlock(); // Log::getInstance()->log("Audio", Log::DEBUG,"libav out"); int save_size=incoming_paket_libav.size; @@ -2168,7 +2167,7 @@ UINT AudioOMX::DeliverMediaPacket(MediaPacket mpacket, const UCHAR* buffer, //Log::getInstance()->log("Audio", Log::DEBUG, "libav out2"); //Log::getInstance()->log("Audio", Log::DEBUG, "DMP mark 20"); if (!omx_running) { - libav_mutex.Unlock(); + libav_mutex.unlock(); return *samplepos; } @@ -2230,9 +2229,9 @@ UINT AudioOMX::DeliverMediaPacket(MediaPacket mpacket, const UCHAR* buffer, int count = 0; while (count < 10 && omx_running) { count++; - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); if (input_bufs_omx_free.size() == 0) { - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); // Log::getInstance()->log("Audio", Log::DEBUG, // "Deliver MediaPacket no free sample"); MILLISLEEP(5); @@ -2247,7 +2246,7 @@ UINT AudioOMX::DeliverMediaPacket(MediaPacket mpacket, const UCHAR* buffer, cur_input_buf_omx->nTimeStamp = VideoOMX::intToOMXTicks(0); cur_input_buf_omx->nFlags=OMX_BUFFERFLAG_TIME_UNKNOWN; input_bufs_omx_free.pop_front(); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); break; } if (!cur_input_buf_omx) return *samplepos; diff --git a/audioomx.h b/audioomx.h index c1a31a5..ae3c2b8 100644 --- a/audioomx.h +++ b/audioomx.h @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #ifndef AUDIOOMX_H @@ -25,11 +24,7 @@ #include #include #include - -#include "defines.h" -#include "audio.h" -#include "videoomx.h" - +#include extern "C" { #include @@ -37,8 +32,9 @@ extern "C" { #include } - - +#include "defines.h" +#include "audio.h" +#include "videoomx.h" class AudioOMX : public Audio { @@ -169,12 +165,12 @@ class AudioOMX : public Audio std::vector input_bufs_omx_all; std::list input_bufs_omx_free; - Mutex input_bufs_omx_mutex; + std::mutex input_bufs_omx_mutex; OMX_BUFFERHEADERTYPE* cur_input_buf_omx; bool omx_running; bool omx_first_frame; - Mutex libav_mutex; + std::mutex libav_mutex; AVCodec *aaclatmcodec_libav; AVCodecContext *aaclatmcodec_context_libav; diff --git a/boxstack.cc b/boxstack.cc index 9813615..abfbb91 100644 --- a/boxstack.cc +++ b/boxstack.cc @@ -1,5 +1,5 @@ /* - Copyright 2004-2005 Chris Tallon + Copyright 2004-2020 Chris Tallon This file is part of VOMP. @@ -68,9 +68,9 @@ void BoxStack::removeAll() int BoxStack::addVideoDisplay(Boxx* box,VideoDisplay vd) { - boxLock.Lock(); + boxLock.lock(); videoStack.push(std::pair(box,vd)); - boxLock.Unlock(); + boxLock.unlock(); Video::getInstance()->setVideoDisplay(vd); return 1; } @@ -79,17 +79,17 @@ int BoxStack::add(Boxx* v) { if (!initted) return 0; Log::getInstance()->log("BoxStack", Log::DEBUG, "add called"); - boxLock.Lock(); + boxLock.lock(); Log::getInstance()->log("BoxStack", Log::DEBUG, "Locked for add"); if (numBoxes == 16) { //Error Log::getInstance()->log("BoxStack", Log::ERR, "More than 16 boxes! Unlocked for add"); - boxLock.Unlock(); + boxLock.unlock(); return 0; } boxes[numBoxes++] = v; - boxLock.Unlock(); + boxLock.unlock(); VideoDisplay vd; if (v->getVideoDisplay(vd)) { Log::getInstance()->log("BoxStack", Log::DEBUG, "Add video display"); @@ -110,12 +110,12 @@ int BoxStack::remove(Boxx* toDelete) if (!initted) return 0; VideoDisplay *display = NULL; - boxLock.Lock(); + boxLock.lock(); Log::getInstance()->log("BoxStack", Log::DEBUG, "Locked for remove"); if (numBoxes == 0) { - boxLock.Unlock(); + boxLock.unlock(); Log::getInstance()->log("BoxStack", Log::ERR, "Unlocked for remove numBoxes == 0"); return 0; } @@ -142,17 +142,17 @@ int BoxStack::remove(Boxx* toDelete) { // not a Box we have! // FIXME - boxLock.Unlock(); + boxLock.unlock(); Log::getInstance()->log("BoxStack", Log::ERR, "Unlocked for remove - no boxx deleted"); return 0; } } - boxLock.Unlock(); + boxLock.unlock(); toDelete->preDelete(); - boxLock.Lock(); + boxLock.lock(); // Log::getInstance()->log("BoxStack", Log::DEBUG, "Starting deleteBox"); deleteBox(i); @@ -175,7 +175,7 @@ int BoxStack::remove(Boxx* toDelete) videoStack.pop(); if (!videoStack.empty()) display=&videoStack.top().second; } - boxLock.Unlock(); + boxLock.unlock(); Log::getInstance()->log("BoxStack", Log::DEBUG, "Unlocked for remove"); // Delete the box @@ -210,7 +210,7 @@ void BoxStack::deleteBox(int z) void BoxStack::redrawAllBoxes() { - boxLock.Lock(); + boxLock.lock(); for (int z = 0; z < numBoxes; z++) { @@ -218,7 +218,7 @@ void BoxStack::redrawAllBoxes() } - boxLock.Unlock(); + boxLock.unlock(); update(NULL,NULL); // should blt all } @@ -226,7 +226,7 @@ void BoxStack::update(Boxx* toUpdate, Region* regionToUpdate) { Log::getInstance()->log("BoxStack", Log::DEBUG, "Update called"); if (!initted) return; // it is allowed to call this before init - boxLock.Lock(); + boxLock.lock(); Log::getInstance()->log("BoxStack", Log::DEBUG, "Locked for update"); // Get the z index of the box @@ -241,7 +241,7 @@ void BoxStack::update(Boxx* toUpdate, Region* regionToUpdate) if (z == numBoxes) { // not a Box we have! - boxLock.Unlock(); + boxLock.unlock(); Log::getInstance()->log("BoxStack", Log::ERR, "Unlocked for update! box not inside boxstack"); return; } @@ -252,7 +252,7 @@ void BoxStack::update(Boxx* toUpdate, Region* regionToUpdate) } if (!toUpdate) { - boxLock.Unlock(); + boxLock.unlock(); Log::getInstance()->log("BoxStack", Log::DEBUG, "Unlocked for update, no box present"); return ; } @@ -285,7 +285,7 @@ void BoxStack::update(Boxx* toUpdate, Region* regionToUpdate) rl.pop_front(); } - boxLock.Unlock(); + boxLock.unlock(); Log::getInstance()->log("BoxStack", Log::DEBUG, "Unlocked for update"); } @@ -463,21 +463,21 @@ void BoxStack::removeAllExceptWallpaper() while(numBoxes > 1) { - boxLock.Lock(); + boxLock.lock(); if (numBoxes == 1) { - boxLock.Unlock(); + boxLock.unlock(); break; } toDel = boxes[numBoxes - 1]; - boxLock.Unlock(); + boxLock.unlock(); toDel->preDelete(); - boxLock.Lock(); + boxLock.lock(); // If boxes[numBoxes - 1] isn't toDel then there's a problem if (boxes[numBoxes - 1] == toDel) @@ -494,7 +494,7 @@ void BoxStack::removeAllExceptWallpaper() videoStack.pop(); if (!videoStack.empty()) display=&videoStack.top().second; } - boxLock.Unlock(); + boxLock.unlock(); //AVO: do the delete outside the lock to allow for recursive deletes Log::getInstance()->log("BoxStack", Log::DEBUG, "going to delete boxx %p, num=%d", toDel, numBoxes); diff --git a/boxstack.h b/boxstack.h index 733d371..41232f3 100644 --- a/boxstack.h +++ b/boxstack.h @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #ifndef BOXSTACK_H @@ -26,12 +25,7 @@ #include #include #include - -#ifndef WIN32 -#include -#endif - -#include "mutex.h" +#include #include "boxx.h" #include "region.h" @@ -74,8 +68,7 @@ class BoxStack VideoDisplayStack videoStack; - Mutex boxLock; - + std::mutex boxLock; void deleteBox(int z); void repaintRevealed(int x, Region r); diff --git a/demuxermedia.h b/demuxermedia.h index 7ead15f..2e22433 100644 --- a/demuxermedia.h +++ b/demuxermedia.h @@ -21,7 +21,6 @@ #ifndef DEMUXERMEDIA_H #define DEMUXERMEDIA_H -#include "mutex.h" #include #include "demuxer.h" #include "defines.h" @@ -54,7 +53,6 @@ class DemuxerMedia : public Demuxer typedef struct { ULLONG pts; ULONG frame; } PTSMapEntry; typedef std::deque PTSMap; PTSMap pts_map; - Mutex pts_map_mutex; ULLONG firstPTS; ULLONG currentPTS; ULLONG lastPTS; diff --git a/demuxerts.cc b/demuxerts.cc index 26401f7..1466fff 100644 --- a/demuxerts.cc +++ b/demuxerts.cc @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #include "demuxerts.h" @@ -752,7 +751,7 @@ ULONG DemuxerTS::getFrameNumFromPTS(ULLONG pts) ULONG ref_frame = 0; int total = 0, actual = 0; if (pts==0) return 0; //we are in startup - pts_map_mutex.Lock(); + pts_map_mutex.lock(); PTSMap::iterator iter = pts_map.begin(); while (iter != pts_map.end()) { @@ -779,7 +778,7 @@ ULONG DemuxerTS::getFrameNumFromPTS(ULLONG pts) iter = pts_map.begin(); iter++; pts_map.erase(iter, pts_map.end()); } - pts_map_mutex.Unlock(); + pts_map_mutex.unlock(); //Log::getInstance()->log("DemuxerTS", Log::DEBUG, "getFrameNumfromPTS pts %lld deleted %d difference %lld", pts, total,difference); @@ -821,17 +820,17 @@ void DemuxerTS::parseTSPacketDetails(PESPacket &packet) // Only important stuff if ((h264 || packet.findSeqHeader(h264) > 1) && packet.hasPTS()) { PTSMapEntry me; - pts_map_mutex.Lock(); + pts_map_mutex.lock(); if (pts_map.empty()) { me.pts = packet.getPTS(); me.frame = frame_num; - pts_map_mutex.Unlock(); - pts_map_mutex.Lock(); + pts_map_mutex.unlock(); + pts_map_mutex.lock(); pts_map.push_front(me); } me = pts_map.front(); - pts_map_mutex.Unlock(); + pts_map_mutex.unlock(); //UINT fps = Video::getInstance()->getFPS(); double tfps=fps; @@ -854,9 +853,9 @@ void DemuxerTS::parseTSPacketDetails(PESPacket &packet) // Only important stuff { me.pts = packet.getPTS(); me.frame = frame_num; - pts_map_mutex.Lock(); + pts_map_mutex.lock(); pts_map.push_front(me); - pts_map_mutex.Unlock(); + pts_map_mutex.unlock(); } } } diff --git a/demuxerts.h b/demuxerts.h index 2ce62fb..dbfe7f3 100644 --- a/demuxerts.h +++ b/demuxerts.h @@ -14,14 +14,13 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #ifndef DEMUXERTS_H #define DEMUXERTS_H -#include "mutex.h" +#include #include #include "demuxer.h" @@ -87,7 +86,7 @@ class DemuxerTS : public Demuxer typedef struct { ULLONG pts; ULONG frame; } PTSMapEntry; typedef std::deque PTSMap; PTSMap pts_map; - Mutex pts_map_mutex; + std::mutex pts_map_mutex; void parseTSPacketDetails(PESPacket &packet); struct PictCountInfo pinfo; diff --git a/demuxervdr.cc b/demuxervdr.cc index c5bd28d..f1a2a3d 100644 --- a/demuxervdr.cc +++ b/demuxervdr.cc @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #include "demuxervdr.h" @@ -254,7 +253,7 @@ ULONG DemuxerVDR::getFrameNumFromPTS(ULLONG pts) ULLONG difference = (1LL<<33); ULONG ref_frame = 0; int total = 0, actual = 0; - pts_map_mutex.Lock(); + pts_map_mutex.lock(); PTSMap::iterator iter = pts_map.begin(); while (iter != pts_map.end()) { @@ -280,7 +279,7 @@ ULONG DemuxerVDR::getFrameNumFromPTS(ULLONG pts) iter = pts_map.begin(); iter++; pts_map.erase(iter, pts_map.end()); } - pts_map_mutex.Unlock(); + pts_map_mutex.unlock(); if (difference == (1LL<<33)) return 0; // We cannot make sense of the pts @@ -365,18 +364,18 @@ void DemuxerVDR::parseVDRPacketDetails() if (packet.findSeqHeader(h264) > 1 && packet.hasPTS()) { PTSMapEntry me; - pts_map_mutex.Lock(); + pts_map_mutex.lock(); if (pts_map.empty()) { me.pts = packet.getPTS(); me.frame = frame_num; - pts_map_mutex.Unlock(); + pts_map_mutex.unlock(); Log::getInstance()->log("Demuxer", Log::DEBUG, "+* PTS INIT *+ %llu %u", me.pts, me.frame); - pts_map_mutex.Lock(); + pts_map_mutex.lock(); pts_map.push_front(me); } me = pts_map.front(); - pts_map_mutex.Unlock(); + pts_map_mutex.unlock(); // UINT fps = Video::getInstance()->getFPS(); ULLONG pts_expected = me.pts + 90000*((ULONG)((double)(frame_num - me.frame)) / fps); @@ -387,9 +386,9 @@ Log::getInstance()->log("Demuxer", Log::DEBUG, "+* PTS INIT *+ %llu %u", me.pts, Log::getInstance()->log("Demuxer", Log::DEBUG, "+* PTS JUMP *+ %llu %u", packet.getPTS(), frame_num); me.pts = packet.getPTS(); me.frame = frame_num; - pts_map_mutex.Lock(); + pts_map_mutex.lock(); pts_map.push_front(me); - pts_map_mutex.Unlock(); + pts_map_mutex.unlock(); } } } diff --git a/demuxervdr.h b/demuxervdr.h index 5efa71a..8630224 100644 --- a/demuxervdr.h +++ b/demuxervdr.h @@ -14,14 +14,13 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #ifndef DEMUXERVDR_H #define DEMUXERVDR_H -#include "mutex.h" +#include #include #include "demuxer.h" #include "defines.h" @@ -53,7 +52,7 @@ class DemuxerVDR : public Demuxer typedef struct { ULLONG pts; ULONG frame; } PTSMapEntry; typedef std::deque PTSMap; PTSMap pts_map; - Mutex pts_map_mutex; + std::mutex pts_map_mutex; void parseVDRPacketDetails(); void dealWithSubtitlePacket(); diff --git a/dsallocator.cc b/dsallocator.cc index c41d90d..80f2298 100644 --- a/dsallocator.cc +++ b/dsallocator.cc @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #define INITGUID @@ -60,7 +59,7 @@ DsAllocator::~DsAllocator() { } void DsAllocator::CleanupSurfaces() { - Lock(); + dsaLock.lock(); while(fullevrsamples.size()>0) { IMFSample *sample=fullevrsamples.front(); @@ -79,20 +78,20 @@ void DsAllocator::CleanupSurfaces() { surfaces[i]=NULL; } start_get_evr_samples=false; - Unlock(); + dsaLock.unlock(); } HRESULT STDMETHODCALLTYPE DsAllocator::InitializeDevice(DWORD_PTR userid,VMR9AllocationInfo* allocinf,DWORD*numbuf){ if (!surfallocnotify) return S_FALSE; CleanupSurfaces(); - Lock(); + dsaLock.lock(); surfaces.resize(*numbuf); HRESULT hres= surfallocnotify->AllocateSurfaceHelper(allocinf,numbuf,&surfaces.at(0)); vheight=allocinf->dwHeight; vwidth=allocinf->dwWidth; start_get_evr_samples=false; - Unlock(); + dsaLock.unlock(); /* char buffer[1024]; sprintf(buffer,"%d * %d",allocinf->dwWidth,allocinf->dwHeight); MessageBox(0,"hi",buffer,0);*/ @@ -102,11 +101,11 @@ HRESULT STDMETHODCALLTYPE DsAllocator::InitializeDevice(DWORD_PTR userid,VMR9All void DsAllocator::LostDevice(IDirect3DDevice9 *d3ddev, IDirect3D9* d3d) { if (!surfallocnotify) return ; CleanupSurfaces(); - Lock(); + dsaLock.lock(); // d3ddev=((OsdWin*)Osd::getInstance())->getD3dDev(); HMONITOR hmon=d3d->GetAdapterMonitor(D3DADAPTER_DEFAULT); surfallocnotify->ChangeD3DDevice(d3ddev,hmon); - Unlock(); + dsaLock.unlock(); } @@ -120,21 +119,21 @@ HRESULT STDMETHODCALLTYPE DsAllocator::GetSurface(DWORD_PTR userid,DWORD surfind if (surfindex>=surfaces.size()) return E_FAIL; if (surf==NULL) return E_POINTER; - Lock(); + dsaLock.lock(); surfaces[surfindex]->AddRef(); *surf=surfaces[surfindex]; - Unlock(); + dsaLock.unlock(); return S_OK; } HRESULT STDMETHODCALLTYPE DsAllocator::AdviseNotify(IVMRSurfaceAllocatorNotify9* allnoty){ - Lock(); + dsaLock.lock(); surfallocnotify=allnoty; IDirect3DDevice9 *d3ddev; //OK lets set the direct3d object from the osd d3ddev=dynamic_cast(Osd::getInstance())->getD3dDev(); HMONITOR hmon=dynamic_cast(Osd::getInstance())->getD3d()->GetAdapterMonitor(D3DADAPTER_DEFAULT); HRESULT hres=surfallocnotify->SetD3DDevice(d3ddev,hmon); - Unlock(); + dsaLock.unlock(); return hres; } @@ -225,7 +224,7 @@ HRESULT STDMETHODCALLTYPE DsAllocator::GetDeviceID(IID *pDid) HRESULT STDMETHODCALLTYPE DsAllocator::InitServicePointers(IMFTopologyServiceLookup *plooky) { if (!plooky) return E_POINTER; - Lock(); + dsaLock.lock(); inevrmode=true; /* get all interfaces we need*/ @@ -238,13 +237,13 @@ HRESULT STDMETHODCALLTYPE DsAllocator::InitServicePointers(IMFTopologyServiceLoo __uuidof(IMFClock),(void**)&mfclock,&dwobjcts); - Unlock(); + dsaLock.unlock(); return S_OK; } HRESULT STDMETHODCALLTYPE DsAllocator::ReleaseServicePointers() { - Lock(); + dsaLock.lock(); inevrmode=false; /* TODO Set RenderState , sample type etc.*/ @@ -261,7 +260,7 @@ HRESULT STDMETHODCALLTYPE DsAllocator::ReleaseServicePointers() if (mfmediatype) mfmediatype->Release(); mfmediatype=NULL; - Unlock(); + dsaLock.unlock(); return S_OK; } @@ -293,14 +292,14 @@ HRESULT STDMETHODCALLTYPE DsAllocator::GetService(const GUID &guid,const IID &ii void DsAllocator::GetEVRSamples() { - Lock(); + dsaLock.lock(); MFCLOCK_STATE clockstate; if (mfclock) mfclock->GetState(0,&clockstate); //MessageBox(0,"get samples","samples",0); if (mfclock && clockstate==MFCLOCK_STATE_STOPPED && fullevrsamples.size()>0) { - Unlock(); + dsaLock.unlock(); return; } @@ -386,7 +385,7 @@ void DsAllocator::GetEVRSamples() } else break; } - Unlock(); + dsaLock.unlock(); } HRESULT STDMETHODCALLTYPE DsAllocator::ProcessMessage(MFVP_MESSAGE_TYPE mess,ULONG_PTR mess_para) @@ -502,15 +501,15 @@ HRESULT STDMETHODCALLTYPE DsAllocator::OnClockSetRate(MFTIME systime,float rate) HRESULT STDMETHODCALLTYPE DsAllocator::GetCurrentMediaType(IMFVideoMediaType **mtype) {// MessageBox(0,"mediatype","mediatype",0); if (mtype==NULL) return E_POINTER; -Lock(); +dsaLock.lock(); if (mfmediatype==NULL) { - Unlock(); + dsaLock.unlock(); *mtype=NULL; return MF_E_NOT_INITIALIZED; } HRESULT hres=mfmediatype->QueryInterface(IID_IMFVideoMediaType,(void**)mtype); -Unlock(); +dsaLock.unlock(); return hres; } @@ -565,13 +564,13 @@ void DsAllocator::RenegotiateEVRMediaType() gotcha=true; - Lock(); + dsaLock.lock(); if (mfmediatype) mfmediatype->Release(); mfmediatype=NULL; mfmediatype=mixtype; AllocateEVRSurfaces(); - Unlock(); + dsaLock.unlock(); hres=mftransform->SetOutputType(0,mixtype,0); @@ -579,12 +578,12 @@ void DsAllocator::RenegotiateEVRMediaType() if (hres!=S_OK) { - Lock(); + dsaLock.lock(); if (mfmediatype) mfmediatype->Release(); mfmediatype=NULL; gotcha=false; - Unlock(); + dsaLock.unlock(); } @@ -611,7 +610,7 @@ void DsAllocator::AllocateEVRSurfaces() format=D3DFMT_X8R8G8B8; CleanupSurfaces(); - Lock(); + dsaLock.lock(); WindowsOsd* osdwin = dynamic_cast(Osd::getInstance()); LPDIRECT3DDEVICE9 d3ddev=osdwin->getD3dDev(); osdwin->BeginPainting(); @@ -644,20 +643,20 @@ void DsAllocator::AllocateEVRSurfaces() if (sample) emptyevrsamples.push(sample); } } - Unlock(); + dsaLock.unlock(); } void DsAllocator::FlushEVRSamples() { - Lock(); + dsaLock.lock(); while(fullevrsamples.size()>0) { IMFSample *sample=fullevrsamples.front(); fullevrsamples.pop(); emptyevrsamples.push(sample); } - Unlock(); + dsaLock.unlock(); } #define FAC 1 @@ -666,7 +665,7 @@ void DsAllocator::GetNextSurface(LPDIRECT3DSURFACE9* surf,DWORD *waittime) *surf=NULL; *waittime=10; - Lock(); + dsaLock.lock(); if (fullevrsamples.size()==0) { *waittime=1; if (start_get_evr_samples) GetEVRSamples(); @@ -746,7 +745,7 @@ void DsAllocator::GetNextSurface(LPDIRECT3DSURFACE9* surf,DWORD *waittime) } } - Unlock(); + dsaLock.unlock(); } @@ -755,10 +754,10 @@ void DsAllocator::DiscardSurfaceandgetWait(DWORD *waittime) //Log::getInstance()->log("DsAllocator", Log::DEBUG , "Discard surface and get Wait"); if (start_get_evr_samples) GetEVRSamples(); //Log::getInstance()->log("DsAllocator", Log::DEBUG , "Discard surface and get Wait2"); - Lock(); + dsaLock.lock(); if (fullevrsamples.size()==0) { *waittime=0; - Unlock(); + dsaLock.unlock(); return; } IMFSample *sample=fullevrsamples.front(); @@ -800,7 +799,7 @@ void DsAllocator::DiscardSurfaceandgetWait(DWORD *waittime) break; } - Unlock(); + dsaLock.unlock(); } void DsAllocator::ResetSyncOffsets() diff --git a/dsallocator.h b/dsallocator.h index acc73f8..32211c9 100644 --- a/dsallocator.h +++ b/dsallocator.h @@ -21,6 +21,7 @@ #include #include +#include #include @@ -28,12 +29,11 @@ #include #include #include -#include "mutex.h" //The Allocator and Presenter for VMR9 is also a Presnter for EVR -class DsAllocator: public IVMRSurfaceAllocator9, IVMRImagePresenter9, Mutex,IMFVideoDeviceID, +class DsAllocator: public IVMRSurfaceAllocator9, IVMRImagePresenter9, IMFVideoDeviceID, IMFTopologyServiceLookupClient,public IMFVideoPresenter,IMFGetService, IQualProp { public: DsAllocator(); @@ -122,6 +122,8 @@ protected: int jitter; int avgfps; LONGLONG lastdelframe; + + std::mutex dsaLock; }; #endif diff --git a/imageomx.cc b/imageomx.cc index 9348901..f3a25e2 100644 --- a/imageomx.cc +++ b/imageomx.cc @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #include "imageomx.h" @@ -73,7 +72,7 @@ OMX_ERRORTYPE ImageOMX::EmptyBufferDone_OMX(OMX_IN OMX_HANDLETYPE /*hcomp*/,OMX_ } void ImageOMX::ReturnEmptyOMXBuffer(OMX_BUFFERHEADERTYPE* buffer){ - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); /*if (buffer->pBuffer) { free(buffer->pBuffer); buffer->pBuffer = NULL; @@ -82,7 +81,7 @@ void ImageOMX::ReturnEmptyOMXBuffer(OMX_BUFFERHEADERTYPE* buffer){ //Log::getInstance()->log("Image", Log::NOTICE, "ReturnEmptyOMXBuffer %d",input_bufs_omx_free.size()); input_bufs_omx_free.push_back(buffer); //Log::getInstance()->log("Image", Log::NOTICE, "ReturnEmptyOMXBuffer %d",input_bufs_omx_free.size()); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); VideoOMX* video = static_cast(Video::getInstance()); video->signalOmx(); @@ -97,10 +96,10 @@ OMX_ERRORTYPE ImageOMX::FillBufferDone_OMX(OMX_IN OMX_HANDLETYPE /*hcomp*/, OMX_ void ImageOMX::ReturnFillOMXBuffer(OMX_BUFFERHEADERTYPE* /*buffer*/) { - //input_bufs_omx_mutex.Lock(); + //input_bufs_omx_mutex.lock(); omx_egl_filled = true; //output_bufs_omx_full.push_back(buffer); - //input_bufs_omx_mutex.Unlock(); + //input_bufs_omx_mutex.unlock(); VideoOMX* video = static_cast(Video::getInstance()); video->signalOmx(); } @@ -300,10 +299,10 @@ bool ImageOMX::intDecodePicture(LoadIndex index, unsigned char* /* buffer */, un // Use Buffer OMX_BUFFERHEADERTYPE * bufhead; - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); int count =0; while (input_bufs_omx_free.size()==0) { - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); //Log::getInstance()->log("Image", Log::DEBUG, "DMP mark 6"); //Log::getInstance()->log("Image", Log::DEBUG, "Deliver MediaPacket no free sample"); //return 0; // we do not have a free media sample @@ -312,7 +311,7 @@ bool ImageOMX::intDecodePicture(LoadIndex index, unsigned char* /* buffer */, un if (count>100) return false; MILLISLEEP(10); - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); } bufhead=input_bufs_omx_free.front(); @@ -323,7 +322,7 @@ bool ImageOMX::intDecodePicture(LoadIndex index, unsigned char* /* buffer */, un //bufhead->pBuffer=buffer; bufhead->pAppPrivate=this; input_bufs_omx_free.pop_front(); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); bufhead->nFilledLen=length;//bufhead->nAllocLen; @@ -687,13 +686,13 @@ int ImageOMX::PrepareInputBufsOMX(bool setportdef, unsigned char * buffer, unsig return 0; } - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); for (unsigned int i=0; i< port_def_type.nBufferCountActual;i++) { OMX_BUFFERHEADERTYPE *buf_head=NULL; error=OMX_UseBuffer(omx_imag_decode/*dec*/,&buf_head,omx_image_input_port/*codec*/,this,port_def_type.nBufferSize, buffer); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Image", Log::DEBUG, "Use OMX_UseBuffer failed %x", error); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); return 0; } input_bufs_omx_all.push_back(buf_head); @@ -702,7 +701,7 @@ int ImageOMX::PrepareInputBufsOMX(bool setportdef, unsigned char * buffer, unsig omx_first_frame=true; - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); if (!video->CommandFinished(omx_imag_decode/*dec*/,OMX_CommandPortEnable, omx_image_input_port /*codec*/)) { return 0; @@ -715,7 +714,7 @@ int ImageOMX::DestroyInputBufsOMX() //call with clock mutex locked { OMX_ERRORTYPE error; - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); for (UINT i=0; i< input_bufs_omx_all.size();i++) { Log::getInstance()->log("Image", Log::DEBUG, "OMX_FreeBuffer mark"); //if (input_bufs_omx_all[i]->pBuffer) free(input_bufs_omx_all[i]->pBuffer); @@ -723,14 +722,14 @@ int ImageOMX::DestroyInputBufsOMX() //call with clock mutex locked error=OMX_FreeBuffer(omx_imag_decode/*dec*/,omx_image_input_port/*codec*/,input_bufs_omx_all[i]); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Image", Log::DEBUG, "Use OMX_FreeBuffer failed %x", error); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); return 0; } } input_bufs_omx_all.clear(); input_bufs_omx_free.clear(); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); return 1; } @@ -739,7 +738,7 @@ int ImageOMX::DestroyInputBufsOMXwhilePlaying() //call with clock mutex locked { //OMX_ERRORTYPE error; - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); while (input_bufs_omx_all.size()>0) { if (input_bufs_omx_free.size()>0) { // Destroy one buffer @@ -753,14 +752,14 @@ int ImageOMX::DestroyInputBufsOMXwhilePlaying() //call with clock mutex locked } } } else { - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); MILLISLEEP(5); - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); } } Log::getInstance()->log("Image", Log::DEBUG, "DestroyInputBufsOMXwhilePlaying %d %d", input_bufs_omx_all.size(),input_bufs_omx_free.size()); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); return 1; } diff --git a/imageomx.h b/imageomx.h index 5a204e7..96442ba 100644 --- a/imageomx.h +++ b/imageomx.h @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #ifndef IMAGEOMX_H @@ -25,6 +24,7 @@ #include #include #include +#include #include #include @@ -97,7 +97,7 @@ class ImageOMX : public OsdVector::PictureDecoder std::vector input_bufs_omx_all; std::list input_bufs_omx_free; //list output_bufs_omx_full; - Mutex input_bufs_omx_mutex; + std::mutex input_bufs_omx_mutex; bool omx_running; bool omx_first_frame; diff --git a/mutex.cc b/mutex.cc deleted file mode 100644 index 42478c6..0000000 --- a/mutex.cc +++ /dev/null @@ -1,60 +0,0 @@ -/* - Copyright 2004-2005 Chris Tallon - - This file is part of VOMP. - - VOMP is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - VOMP is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -#include "mutex.h" - -// FIXME - delete me. - - - -#ifndef WIN32 -#include -#include -#endif - -Mutex::Mutex() { -#ifndef WIN32 - pthread_mutex_init(&my_mutex, NULL); -#else - my_mutex=CreateMutex(NULL,FALSE,NULL); -#endif -} - -Mutex::~Mutex() { -#ifdef WIN32 - CloseHandle(my_mutex); -#endif -} - -void Mutex::Lock() { -#ifndef WIN32 - pthread_mutex_lock(&my_mutex); -#else - WaitForSingleObject(my_mutex, INFINITE ); -#endif -} - -void Mutex::Unlock() { -#ifndef WIN32 - pthread_mutex_unlock(&my_mutex); -#else - ReleaseMutex(my_mutex); -#endif -} - diff --git a/mutex.h b/mutex.h deleted file mode 100644 index 21b04b7..0000000 --- a/mutex.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright 2004-2005 Chris Tallon - - This file is part of VOMP. - - VOMP is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - VOMP is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#ifndef MUTEX_H -#define MUTEX_H - -#ifndef WIN32 -#include -#else -#include -#include -#endif - - - -class Mutex -{ -public: - Mutex(); - ~Mutex(); - void Lock(); - void Unlock(); -protected: -#ifndef WIN32 - pthread_mutex_t my_mutex; -#else - HANDLE my_mutex; -#endif -}; -#endif diff --git a/objects.mk b/objects.mk index a209ca1..d87d0ef 100644 --- a/objects.mk +++ b/objects.mk @@ -1,5 +1,5 @@ OBJ_COMMON = command.o tcp.o dsock.o thread.o timers.o i18n.o vdp6.o \ - message.o messagequeue.o wol.o audio.o video.o log.o mutex.o \ + message.o messagequeue.o wol.o audio.o video.o log.o \ vdr.o recman.o recording.o recinfo.o channel.o rectimer.o event.o \ directory.o mark.o option.o player.o playerradio.o vfeed.o afeed.o \ demuxer.o demuxervdr.o demuxerts.o stream.o osd.o surface.o \ diff --git a/osdopengl.cc b/osdopengl.cc index 7cd1fcd..e1986cb 100644 --- a/osdopengl.cc +++ b/osdopengl.cc @@ -14,23 +14,22 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ -#include "osdopengl.h" #include "videoomx.h" #include "surfaceopengl.h" - #include "message.h" #include "command.h" +#include "osdopengl.h" + #define BACKBUFFER_WIDTH 1280 #define BACKBUFFER_HEIGHT 720 OsdOpenGL::OsdOpenGL() { - glmutex.Lock(); + glmutex.lock(); external_driving=false; @@ -57,7 +56,7 @@ OsdOpenGL::~OsdOpenGL() } - glmutex.Unlock(); + glmutex.unlock(); } int OsdOpenGL::getFD() @@ -83,7 +82,7 @@ int OsdOpenGL::init() if (egl_display==EGL_NO_DISPLAY) { Log::getInstance()->log("OSD", Log::WARN, "Could not get egl display! %x",eglGetError()); - glmutex.Unlock(); + glmutex.unlock(); return 0; } @@ -91,7 +90,7 @@ int OsdOpenGL::init() if (eglInitialize(egl_display, NULL, NULL)==EGL_FALSE) { Log::getInstance()->log("OSD", Log::WARN, "Initialising display failed! %x",eglGetError()); - glmutex.Unlock(); + glmutex.unlock(); return 0; } @@ -114,7 +113,7 @@ int OsdOpenGL::init() if (eglChooseConfig(egl_display, attributs, &egl_ourconfig, 1, &number)==EGL_FALSE) { Log::getInstance()->log("OSD", Log::WARN, "Choosing egl config failed! %x",eglGetError()); - glmutex.Unlock(); + glmutex.unlock(); return 0; } @@ -126,7 +125,7 @@ int OsdOpenGL::init() egl_context=eglCreateContext(egl_display,egl_ourconfig,EGL_NO_CONTEXT,attr_context); if (egl_context==EGL_NO_CONTEXT) { Log::getInstance()->log("OSD", Log::WARN, "Creating egl context failed! %x",eglGetError()); - glmutex.Unlock(); + glmutex.unlock(); return 0; } @@ -134,7 +133,7 @@ int OsdOpenGL::init() display_width=display_height=0; if (graphics_get_display_size(0, &display_width, &display_height)<0) { Log::getInstance()->log("OSD", Log::WARN, "Getting display size failed! (BCM API) "); - glmutex.Unlock(); + glmutex.unlock(); return 0; } Log::getInstance()->log("OSD", Log::NOTICE, "Displaysize is %d x %d ",display_width, display_height); @@ -158,13 +157,13 @@ int OsdOpenGL::init() egl_surface = eglCreateWindowSurface(egl_display,egl_ourconfig, &nativewindow,NULL ); if (egl_surface==EGL_NO_SURFACE) { Log::getInstance()->log("OSD", Log::WARN, "Creating egl window surface failed!"); - glmutex.Unlock(); + glmutex.unlock(); return 0; } if (eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context)== EGL_FALSE) { Log::getInstance()->log("OSD", Log::WARN, "Making egl Current failed"); - glmutex.Unlock(); + glmutex.unlock(); return 0; } // Test stuff @@ -202,7 +201,7 @@ int OsdOpenGL::init() if (!osd_shader.init()) { Log::getInstance()->log("OSD", Log::WARN, "Init Osd Shader failed"); - glmutex.Unlock(); + glmutex.unlock(); return 0; } @@ -219,7 +218,7 @@ int OsdOpenGL::init() } - glmutex.Unlock(); + glmutex.unlock(); threadStart(); return 1; @@ -270,7 +269,7 @@ void OsdOpenGL::InitVertexBuffer(float scalex,float scaley) int OsdOpenGL::shutdown() { if (!initted) return 0; - glmutex.Lock(); + glmutex.lock(); initted = 0; threadStop(); delete screen; @@ -309,9 +308,9 @@ void OsdOpenGL::screenShot(const char* fileName) void OsdOpenGL::threadMethod() { // We have to claim the gl context for this thread - //glmutex.Lock(); + //glmutex.lock(); - //glmutex.Unlock(); + //glmutex.unlock(); int ts=0; while (true) { @@ -403,7 +402,7 @@ void OsdOpenGL::InternalRendering(){ void OsdOpenGL::BeginPainting() {//We synchronize calls to d3d between different threads - glmutex.Lock(); + glmutex.lock(); if (initted) { if (eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context)== EGL_FALSE) { Log::getInstance()->log("OSD", Log::WARN, "Making egl Current failed in thread %d",eglGetError()); @@ -414,7 +413,7 @@ void OsdOpenGL::BeginPainting() {//We synchronize calls to d3d between different void OsdOpenGL::EndPainting() { eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ); - glmutex.Unlock(); + glmutex.unlock(); } diff --git a/osdopengl.h b/osdopengl.h index 61ca7ee..82abbae 100644 --- a/osdopengl.h +++ b/osdopengl.h @@ -14,16 +14,14 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #ifndef OSDOPENGL_H #define OSDOPENGL_H #include - - +#include #include #include @@ -33,16 +31,10 @@ #include "defines.h" #include "log.h" #include "threadp.h" -#include "mutex.h" #include "videoomx.h" #include "glosdshader.h" - - - - - struct OSDCOLOR{ GLfloat r; GLfloat g; @@ -60,11 +52,6 @@ struct OSDVERTEX { GLfloat v; }; - - - - - class OsdOpenGL : public Osd, public Thread_TYPE { public: @@ -110,7 +97,7 @@ private: // This indicates, that currently a video is played, thus the osd updates are driven by the Videosystem bool external_driving; - Mutex glmutex; + std::mutex glmutex; long long lastrendertime; void InternalRendering(); void InitVertexBuffer(float scalex,float scaley); @@ -119,9 +106,6 @@ private: GLOsdShader osd_shader; - - - /* BCM specific */ uint32_t display_height; @@ -131,7 +115,6 @@ private: uint32_t mode; - EGLDisplay egl_display; EGLSurface egl_surface; EGLContext egl_context; diff --git a/osdopenvg.cc b/osdopenvg.cc index 7e68201..6441788 100644 --- a/osdopenvg.cc +++ b/osdopenvg.cc @@ -48,8 +48,8 @@ EXTERNAL_PICTS OsdOpenVG::OsdOpenVG() { - vgmutex.Lock(); - taskmutex.Lock(); + vgmutex.lock(); + taskmutex.lock(); lastrendertime=getTimeMS(); display_height=0; display_width=0; @@ -111,8 +111,8 @@ OsdOpenVG::~OsdOpenVG() } } - vgmutex.Unlock(); - taskmutex.Unlock(); + vgmutex.unlock(); + taskmutex.unlock(); } @@ -130,7 +130,7 @@ int OsdOpenVG::init() if (egl_display==EGL_NO_DISPLAY) { Log::getInstance()->log("OSD", Log::WARN, "Could not get egl display! %x",eglGetError()); - vgmutex.Unlock(); + vgmutex.unlock(); return 0; } @@ -138,7 +138,7 @@ int OsdOpenVG::init() if (eglInitialize(egl_display, NULL, NULL)==EGL_FALSE) { Log::getInstance()->log("OSD", Log::WARN, "Initialising display failed! %x",eglGetError()); - vgmutex.Unlock(); + vgmutex.unlock(); return 0; } @@ -152,7 +152,7 @@ int OsdOpenVG::init() if (eglBindAPI(EGL_OPENVG_API)==EGL_FALSE) { Log::getInstance()->log("OSD", Log::WARN, "Binding openvg api failed! %x",eglGetError()); - vgmutex.Unlock(); + vgmutex.unlock(); return 0; } @@ -168,7 +168,7 @@ int OsdOpenVG::init() if (eglChooseConfig(egl_display, attributs, &egl_ourconfig, 1, &number)==EGL_FALSE) { Log::getInstance()->log("OSD", Log::WARN, "Choosing egl config failed! %x",eglGetError()); - vgmutex.Unlock(); + vgmutex.unlock(); return 0; } @@ -177,7 +177,7 @@ int OsdOpenVG::init() egl_context=eglCreateContext(egl_display,egl_ourconfig,NULL,NULL); if (egl_context==EGL_NO_CONTEXT) { Log::getInstance()->log("OSD", Log::WARN, "Creating egl context failed! %x",eglGetError()); - vgmutex.Unlock(); + vgmutex.unlock(); return 0; } @@ -185,7 +185,7 @@ int OsdOpenVG::init() display_width=display_height=0; if (graphics_get_display_size(0, &display_width, &display_height)<0) { Log::getInstance()->log("OSD", Log::WARN, "Getting display size failed! (BCM API) "); - vgmutex.Unlock(); + vgmutex.unlock(); return 0; } Log::getInstance()->log("OSD", Log::NOTICE, "Displaysize is %d x %d ",display_width, display_height); @@ -226,13 +226,13 @@ int OsdOpenVG::init() egl_surface = eglCreateWindowSurface(egl_display,egl_ourconfig, &nativewindow,NULL ); if (egl_surface==EGL_NO_SURFACE) { Log::getInstance()->log("OSD", Log::WARN, "Creating egl window surface failed!"); - vgmutex.Unlock(); + vgmutex.unlock(); return 0; } Log::getInstance()->log("OSD", Log::DEBUG, "Making egl current in1%d",syscall(SYS_gettid)); if (eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context)== EGL_FALSE) { Log::getInstance()->log("OSD", Log::WARN, "Making egl Current failed"); - vgmutex.Unlock(); + vgmutex.unlock(); return 0; } // Test stuff @@ -313,8 +313,8 @@ int OsdOpenVG::init() threadStart(); - taskmutex.Unlock(); - vgmutex.Unlock(); + taskmutex.unlock(); + vgmutex.unlock(); #ifdef PICTURE_DECODER_OMX imageomx=new ImageOMX(&reader); @@ -505,8 +505,8 @@ int OsdOpenVG::shutdown() processTasks(); Log::getInstance()->log("OSD", Log::DEBUG, "shutdown mark3"); - taskmutex.Lock(); - vgmutex.Lock(); + taskmutex.lock(); + vgmutex.lock(); @@ -607,7 +607,7 @@ void OsdOpenVG::threadMethod() } void OsdOpenVG::InternalRendering(){ - vgmutex.Lock(); + vgmutex.lock(); Colour bg=DrawStyle::WALLPAPER; float colclear[]={1.f,1.0f,1.f,1.f}; if (bg.alpha==0) colclear[3]=0.f; @@ -620,7 +620,7 @@ void OsdOpenVG::InternalRendering(){ //Show it to the user! eglSwapBuffers(egl_display, egl_surface); - vgmutex.Unlock(); + vgmutex.unlock(); } @@ -1344,38 +1344,38 @@ unsigned int OsdOpenVG::handleTask(OpenVGCommand& command) bool OsdOpenVG::processTasks() { bool worked=false; - taskmutex.Lock(); - vgmutex.Lock(); + taskmutex.lock(); + vgmutex.lock(); while (vgcommands.size()>0) { OpenVGCommand comm=vgcommands.front(); vgcommands.pop_front(); - taskmutex.Unlock(); + taskmutex.unlock(); OpenVGResponse resp; resp.result=handleTask(comm); resp.id=comm.id; - taskmutex.Lock(); + taskmutex.lock(); if (comm.id) { vgresponses.push_back(resp); } - taskmutex.Unlock(); - vgmutex.Unlock(); + taskmutex.unlock(); + vgmutex.unlock(); //threadCheckExit(); vgtaskSignal.signal(); - taskmutex.Lock(); - vgmutex.Lock(); + taskmutex.lock(); + vgmutex.lock(); worked=true; } - taskmutex.Unlock(); - vgmutex.Unlock(); + taskmutex.unlock(); + vgmutex.unlock(); return worked; } bool OsdOpenVG::haveOpenVGResponse(unsigned int id,unsigned int * resp) { - taskmutex.Lock(); + taskmutex.lock(); if (vgresponses.size()>0) { std::deque::iterator itty=vgresponses.begin(); @@ -1383,20 +1383,20 @@ bool OsdOpenVG::haveOpenVGResponse(unsigned int id,unsigned int * resp) { if ((*itty).id==id) { *resp=(*itty).result; - taskmutex.Unlock(); + taskmutex.unlock(); return true; } itty++; } } - taskmutex.Unlock(); + taskmutex.unlock(); return false; } unsigned int OsdOpenVG::putOpenVGCommand(OpenVGCommand& comm,bool wait) { - taskmutex.Lock(); + taskmutex.lock(); if (wait){ comm.id=wait_id; wait_id++; @@ -1404,7 +1404,7 @@ unsigned int OsdOpenVG::putOpenVGCommand(OpenVGCommand& comm,bool wait) comm.id=0; // we are not waiting } vgcommands.push_back(comm); - taskmutex.Unlock(); + taskmutex.unlock(); threadSignal(); while (wait) { unsigned int resp; diff --git a/osdopenvg.h b/osdopenvg.h index 4a293ab..0742821 100644 --- a/osdopenvg.h +++ b/osdopenvg.h @@ -14,15 +14,14 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #ifndef OSDOPENVG_H #define OSDOPENVG_H #include - +#include #include #include @@ -35,7 +34,6 @@ #include "defines.h" #include "log.h" #include "threadp.h" -#include "mutex.h" #include "signal.h" #include "videoomx.h" #include "staticartwork.h" @@ -134,8 +132,8 @@ protected: - Mutex vgmutex; - Mutex taskmutex; + std::mutex vgmutex; + std::mutex taskmutex; Signal vgtaskSignal; std::deque vgcommands; std::deque vgresponses; diff --git a/osdvector.cc b/osdvector.cc index a0b44b6..b0bd6e1 100644 --- a/osdvector.cc +++ b/osdvector.cc @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #include "osdvector.h" @@ -169,7 +168,7 @@ void OsdVector::Blank() int OsdVector::restore() { // First clear the contents of all registered surfaces - surfaces_mutex.Lock(); + surfaces_mutex.lock(); //Now go through all surfaces and draw them std::list::iterator curdraw=scommands.begin(); @@ -193,13 +192,13 @@ int OsdVector::restore() tvmedias_load_inv.clear(); tvmedias_loaded.clear(); - surfaces_mutex.Unlock(); + surfaces_mutex.unlock(); return 1; } void OsdVector::drawSurfaces() { - surfaces_mutex.Lock(); + surfaces_mutex.lock(); std::list todraw; //First figure out if a surfaces is below another surface std::list::iterator itty1=scommands.begin(); while (itty1!=scommands.end()) { @@ -251,13 +250,13 @@ void OsdVector::drawSurfaces() curdraw++; } - surfaces_mutex.Unlock(); + surfaces_mutex.unlock(); } void OsdVector::updateOrAddSurface(const SurfaceVector *surf,float x,float y,float height,float width, std::vector& commands) { - surfaces_mutex.Lock(); + surfaces_mutex.lock(); //First determine it is already in our system std::list::iterator itty=scommands.begin(); while (itty!=scommands.end()) { @@ -304,12 +303,12 @@ void OsdVector::updateOrAddSurface(const SurfaceVector *surf,float x,float y,flo referenceSVGCommand((*itty).commands); cleanupOrphanedRefs(); - surfaces_mutex.Unlock(); + surfaces_mutex.unlock(); } void OsdVector::removeSurface(const SurfaceVector *surf) { - surfaces_mutex.Lock(); + surfaces_mutex.lock(); //First determine it is already in our system std::list::iterator itty=scommands.begin(); while (itty!=scommands.end()) { @@ -321,7 +320,7 @@ void OsdVector::removeSurface(const SurfaceVector *surf) } itty++; } - surfaces_mutex.Unlock(); + surfaces_mutex.unlock(); } @@ -370,13 +369,13 @@ void OsdVector::removeImageRef(const ImageIndex ref) int OsdVector::getLoadIndexRef(LoadIndex index) { - surfaces_mutex.Lock(); + surfaces_mutex.lock(); if (loadindex_ref.find(index)==loadindex_ref.end()) { return -1; } else { return loadindex_ref[index]; } - surfaces_mutex.Unlock(); + surfaces_mutex.unlock(); } void OsdVector::incLoadIndexRef(LoadIndex index) @@ -503,13 +502,13 @@ void OsdVector::cleanupOrphanedRefs() int OsdVector::getImageRef(ImageIndex index) { - surfaces_mutex.Lock(); + surfaces_mutex.lock(); if (images_ref.find(index)==images_ref.end()) { return -1; } else { return images_ref[index]; } - surfaces_mutex.Unlock(); + surfaces_mutex.unlock(); } void OsdVector::incStyleRef(VectorHandle index) @@ -540,7 +539,7 @@ void OsdVector::removeStyleRef(VectorHandle index) VectorHandle OsdVector::getStyleRef(const DrawStyle &c) { - surfaces_mutex.Lock(); + surfaces_mutex.lock(); VectorHandle style_handle = 0; if (!styles_lastit_valid || (*styles_lastit).first!=c) { styles_lastit_valid=false; @@ -549,9 +548,9 @@ VectorHandle OsdVector::getStyleRef(const DrawStyle &c) if (styles_lastit==styles.end()) { - surfaces_mutex.Unlock(); + surfaces_mutex.unlock(); style_handle=createStyleRef(c); - surfaces_mutex.Lock(); + surfaces_mutex.lock(); styles_lastit = styles.insert(std::pair(c, style_handle)).first; } else { @@ -564,15 +563,15 @@ VectorHandle OsdVector::getStyleRef(const DrawStyle &c) if (styles_ref_lastit==styles_ref.end()) { //invalid handle recreate - surfaces_mutex.Unlock(); + surfaces_mutex.unlock(); style_handle=createStyleRef(c); - surfaces_mutex.Lock(); + surfaces_mutex.lock(); (*styles_lastit).second=style_handle; } else styles_ref_lastit_valid=true; } styles_lastit_valid=true; incStyleRef(style_handle); - surfaces_mutex.Unlock(); + surfaces_mutex.unlock(); return style_handle; } @@ -596,7 +595,7 @@ LoadIndex OsdVector::getTVMediaRef(TVMediaInfo& tvmedia, ImageIndex& image) { ImageIndex image_handle=0; LoadIndex loadindex=0; - surfaces_mutex.Lock(); + surfaces_mutex.lock(); if (tvmedias.find(tvmedia)==tvmedias.end()) { loadindex=loadTVMedia(tvmedia); @@ -613,7 +612,7 @@ LoadIndex OsdVector::getTVMediaRef(TVMediaInfo& tvmedia, ImageIndex& image) /*tvmedias[tvmedia]=createTVMedia(tvmedia,width,height); incImageRef(image_handle);*/ image=image_handle; - surfaces_mutex.Unlock(); + surfaces_mutex.unlock(); return loadindex; } @@ -664,7 +663,7 @@ void OsdVector::informPicture(LoadIndex index, ImageIndex imageIndex) ImageIndex image_index=0; Log::getInstance()->log("OsdVector", Log::DEBUG, "TVMedia Picture for request id %llx arrived %x",index, imageIndex); - surfaces_mutex.Lock(); + surfaces_mutex.lock(); TVMediaInfo tvmedia=tvmedias_load_inv[index]; if (imageIndex) { std::map::iterator itty=loadindex_ref.find(index); @@ -681,7 +680,7 @@ void OsdVector::informPicture(LoadIndex index, ImageIndex imageIndex) incImageRef(image_index); // hold one index until all loadings refs are gone; } } - surfaces_mutex.Unlock(); + surfaces_mutex.unlock(); } @@ -713,25 +712,25 @@ ImageIndex OsdVector::getJpegRef(const char* fileName, int *width,int *height) ImageIndex OsdVector::getMonoBitmapRef(void *base,int width,int height) { ImageIndex image_handle; - surfaces_mutex.Lock(); + surfaces_mutex.lock(); if (monobitmaps.find(base)==monobitmaps.end()) { - surfaces_mutex.Unlock(); + surfaces_mutex.unlock(); image_handle=createMonoBitmap(base,width,height); - surfaces_mutex.Lock(); + surfaces_mutex.lock(); monobitmaps[base]=image_handle; } else { image_handle=monobitmaps[base]; if (images_ref.find(image_handle)==images_ref.end()) { //invalid handle recreate - surfaces_mutex.Unlock(); + surfaces_mutex.unlock(); image_handle=createMonoBitmap(base,width,height); - surfaces_mutex.Lock(); + surfaces_mutex.lock(); monobitmaps[base]=image_handle; } } incImageRef(image_handle); - surfaces_mutex.Unlock(); + surfaces_mutex.unlock(); return image_handle; } @@ -739,23 +738,23 @@ ImageIndex OsdVector::getImagePalette(int width,int height,const unsigned char { ImageIndex image_handle; image_handle=createImagePalette(width,height,image_data,palette_data); - surfaces_mutex.Lock(); + surfaces_mutex.lock(); palettepics.push_back(image_handle); incImageRef(image_handle); - surfaces_mutex.Unlock(); + surfaces_mutex.unlock(); return image_handle; } OsdVector::PictureReader::~PictureReader() { - decoders_lock.Lock(); + decoders_lock.lock(); while ( decoders.size()) { PictureDecoder* dec=decoders.front(); decoders.pop_front(); delete dec; } - decoders_lock.Unlock(); + decoders_lock.unlock(); } void OsdVector::PictureReader::init() @@ -772,15 +771,15 @@ void OsdVector::PictureReader::shutdown() void OsdVector::PictureReader::addDecoder(PictureDecoder* decoder) { - decoders_lock.Lock(); + decoders_lock.lock(); decoder->init(); decoders.push_front(decoder); - decoders_lock.Unlock(); + decoders_lock.unlock(); } void OsdVector::PictureReader::removeDecoder(PictureDecoder* decoder) { - decoders_lock.Lock(); + decoders_lock.lock(); std::list::iterator itty=decoders.begin(); while (itty!=decoders.end()) { if ((*itty) == decoder) @@ -793,7 +792,7 @@ void OsdVector::PictureReader::removeDecoder(PictureDecoder* decoder) Log::getInstance()->log("OsdVector", Log::DEBUG, "removeDecoder"); decoder->shutdown(); delete decoder; - decoders_lock.Unlock(); + decoders_lock.unlock(); } void OsdVector::PictureReader::threadMethod() @@ -811,7 +810,7 @@ void OsdVector::PictureReader::threadMethod() { todos=false; PictureInfo pictinf; - decoders_lock.Lock(); + decoders_lock.lock(); std::list::iterator itty=decoders.begin(); while (itty!=decoders.end()) { @@ -827,7 +826,7 @@ void OsdVector::PictureReader::threadMethod() todos = true; } - decoders_lock.Unlock(); + decoders_lock.unlock(); } //Log::getInstance()->log("OsdVector", Log::DEBUG, "TVMedia Sleep Picture Reader"); @@ -848,33 +847,33 @@ void OsdVector::PictureReader::threadMethod() void OsdVector::PictureReader::invalidateLoadIndex(LoadIndex index) { - pict_lock_incoming.Lock(); + pict_lock_incoming.lock(); invalid_loadindex.insert(index); - pict_lock_incoming.Unlock(); + pict_lock_incoming.unlock(); } void OsdVector::PictureReader::informFallback(LoadIndex index, int fallback) { - pict_lock_incoming.Lock(); + pict_lock_incoming.lock(); inform_fallback[index]=fallback; - pict_lock_incoming.Unlock(); + pict_lock_incoming.unlock(); } void OsdVector::PictureReader::receivePicture(VDR_ResponsePacket *vresp) { - pict_lock_incoming.Lock(); + pict_lock_incoming.lock(); pict_incoming.push(vresp); - pict_lock_incoming.Unlock(); + pict_lock_incoming.unlock(); threadSignal(); } void OsdVector::PictureReader::addStaticImage(unsigned int id) { - pict_lock_incoming.Lock(); + pict_lock_incoming.lock(); pict_incoming_static.push(id); invalid_loadindex.erase(((long long) id) << 32LL); - pict_lock_incoming.Unlock(); + pict_lock_incoming.unlock(); threadSignal(); } @@ -887,7 +886,7 @@ bool OsdVector::PictureReader::processReceivedPictures() { bool decoded = false; bool valid = true; - pict_lock_incoming.Lock(); + pict_lock_incoming.lock(); if (pict_incoming.size()) { VDR_ResponsePacket *vresp=pict_incoming.front(); pict_incoming.pop(); @@ -896,7 +895,7 @@ bool OsdVector::PictureReader::processReceivedPictures() valid = false; invalid_loadindex.erase(setpos); } - pict_lock_incoming.Unlock(); + pict_lock_incoming.unlock(); if (!valid) { // we do not want it anymore skip it; delete vresp; return true; @@ -915,11 +914,11 @@ bool OsdVector::PictureReader::processReceivedPictures() freed = true; } else { int fallback=-1; - pict_lock_incoming.Lock(); + pict_lock_incoming.lock(); if (inform_fallback.find(vresp->getStreamID())!=inform_fallback.end()) { fallback=inform_fallback[vresp->getStreamID()]; } - pict_lock_incoming.Unlock(); + pict_lock_incoming.unlock(); if (fallback >= 0 && ((OsdVector*)Osd::getInstance())->getStaticImageData(fallback, &userdata, &length)) { decode = true; @@ -941,9 +940,9 @@ bool OsdVector::PictureReader::processReceivedPictures() free(userdata); } } - pict_lock_incoming.Lock(); + pict_lock_incoming.lock(); inform_fallback.erase(vresp->getStreamID()); - pict_lock_incoming.Unlock(); + pict_lock_incoming.unlock(); //else osd->informPicture(vresp->getStreamID(), 0); delete vresp; } else if (pict_incoming_static.size()){ @@ -954,7 +953,7 @@ bool OsdVector::PictureReader::processReceivedPictures() valid = false; invalid_loadindex.erase(setpos); } - pict_lock_incoming.Unlock(); + pict_lock_incoming.unlock(); if (!valid) { // we do not want it anymore skip it; return true; } @@ -973,7 +972,7 @@ bool OsdVector::PictureReader::processReceivedPictures() } } } else { - pict_lock_incoming.Unlock(); + pict_lock_incoming.unlock(); } diff --git a/osdvector.h b/osdvector.h index 411203e..a4c165b 100644 --- a/osdvector.h +++ b/osdvector.h @@ -20,15 +20,16 @@ #ifndef OSDVECTOR_H #define OSDVECTOR_H -#include "osd.h" -#include "mutex.h" -#include "colour.h" #include #include #include #include #include #include +#include + +#include "osd.h" +#include "colour.h" #include "tvmedia.h" #include "vdr.h" @@ -325,8 +326,8 @@ class OsdVector : public Osd void threadMethod(); - Mutex pict_lock_incoming; //locks - Mutex decoders_lock; + std::mutex pict_lock_incoming; //locks + std::mutex decoders_lock; std::queue pict_incoming; std::queue pict_incoming_static; std::list decoders; @@ -402,7 +403,7 @@ protected: std::list scommands; - Mutex surfaces_mutex; + std::mutex surfaces_mutex; float byte_char_width[256]; diff --git a/osdwinvector.cc b/osdwinvector.cc index f7aab50..f9ef386 100644 --- a/osdwinvector.cc +++ b/osdwinvector.cc @@ -291,7 +291,7 @@ int OsdWinVector::init() - queuemutex.Lock(); + queuemutex.lock(); HRESULT hres; DXGI_SURFACE_DESC surf_desc; @@ -325,14 +325,14 @@ int OsdWinVector::init() D3DPOOL_DEFAULT, &surfinfo.surf9, &surfinfo.sharedhandle); if (hres != S_OK) { Log::getInstance()->log("OSD", Log::WARN, "Could not create Texture for Direct3D9 !"); - queuemutex.Unlock(); + queuemutex.unlock(); return 0; } hres = d3ddevice->CreateQuery(D3DQUERYTYPE_EVENT, &surfinfo.query9); if (hres != S_OK) { Log::getInstance()->log("OSD", Log::WARN, "Could not create Query for Direct3D9 !"); - queuemutex.Unlock(); + queuemutex.unlock(); return 0; } @@ -343,14 +343,14 @@ int OsdWinVector::init() hres = d3ddevice10->OpenSharedResource(surfinfo.sharedhandle, __uuidof(ID3D10Resource), (void**)&tempres); if (hres != S_OK) { Log::getInstance()->log("OSD", Log::WARN, "Could not open resourcee for Direct3D10 !"); - queuemutex.Unlock(); + queuemutex.unlock(); return 0; } hres = tempres->QueryInterface(__uuidof(ID3D10Texture2D), (void**)&surfinfo.surf10); if (hres != S_OK) { Log::getInstance()->log("OSD", Log::WARN, "Could not query surface for Direct3D10 !"); - queuemutex.Unlock(); + queuemutex.unlock(); return 0; } tempres->Release(); @@ -359,14 +359,14 @@ int OsdWinVector::init() hres = surfinfo.surf10->QueryInterface(__uuidof(IDXGISurface), (void**)&surfinfo.surfdxgi); if (hres != S_OK) { Log::getInstance()->log("OSD", Log::WARN, "Could not query surface for DXGI !"); - queuemutex.Unlock(); + queuemutex.unlock(); return 0; } hres = d2dfactory->CreateDxgiSurfaceRenderTarget(surfinfo.surfdxgi, &rt_prop, &surfinfo.rendtarget2D); if (hres != S_OK) { Log::getInstance()->log("OSD", Log::WARN, "Could not create render target!"); - queuemutex.Unlock(); + queuemutex.unlock(); return 0; } @@ -383,7 +383,7 @@ int OsdWinVector::init() hres = d3ddevice10->CreateQuery(&qdesc, &surfinfo.query10); if (hres != S_OK) { Log::getInstance()->log("OSD", Log::WARN, "Could not create Query for Direct2D Direct3D10 !"); - queuemutex.Unlock(); + queuemutex.unlock(); return 0; } allsurfs.push_back(surfinfo); @@ -392,7 +392,7 @@ int OsdWinVector::init() aspect_correction = ((float)OSD_BUFFER_HEIGHT) / 576.f / (((float)OSD_BUFFER_WIDTH) / 720.f); - queuemutex.Unlock(); + queuemutex.unlock(); initPaths(); @@ -415,7 +415,7 @@ int OsdWinVector::shutdown() destroyPaths(); - queuemutex.Lock(); + queuemutex.lock(); if (currentosd_render.surf9) { currentosd_render.surf9 = NULL; } @@ -477,7 +477,7 @@ int OsdWinVector::shutdown() while (d3dtod2d.size()) d3dtod2d.pop(); while (d2dtod3d.size()) d2dtod3d.pop(); - queuemutex.Unlock(); + queuemutex.unlock(); @@ -1088,7 +1088,7 @@ bool OsdWinVector::screenShot(void *buffer, int width, int height, bool osd /*in LPDIRECT3DTEXTURE9 OsdWinVector::getNextOsdTexture() { - queuemutex.Lock(); + queuemutex.lock(); if (d2dtod3d.size()) { SurfaceInfo surfinfo = d2dtod3d.front(); @@ -1103,7 +1103,7 @@ LPDIRECT3DTEXTURE9 OsdWinVector::getNextOsdTexture() d2dtod3d.pop(); //} } - queuemutex.Unlock(); + queuemutex.unlock(); return currentosd_render.surf9; } @@ -1111,7 +1111,7 @@ LPDIRECT3DTEXTURE9 OsdWinVector::getNextOsdTexture() void OsdWinVector::updateOsd() { - queuemutex.Lock(); + queuemutex.lock(); if (d3dtod2d.size()) { currentosd_backbuffer = d3dtod2d.front(); @@ -1119,7 +1119,7 @@ void OsdWinVector::updateOsd() if (currentosd_backbuffer.query9->GetData(NULL, 0, 0) == S_OK) { - //queuemutex.Unlock(); + //queuemutex.unlock(); currentosd_backbuffer.query10->Begin(); currentosd_backbuffer.rendtarget2D->BeginDraw(); @@ -1139,7 +1139,7 @@ void OsdWinVector::updateOsd() d3ddevice10->Flush(); currentosd_backbuffer.query10->End(); - //queuemutex.Lock(); + //queuemutex.lock(); d3dtod2d.pop(); d2dtod3d.push(currentosd_backbuffer); @@ -1147,29 +1147,29 @@ void OsdWinVector::updateOsd() } - queuemutex.Unlock(); + queuemutex.unlock(); } ID2D1RenderTarget * OsdWinVector::LockOsdDrawing() { - queuemutex.Lock(); + queuemutex.lock(); if (d3dtod2d.size()) { currentosd_backbuffer=d3dtod2d.front(); return currentosd_backbuffer.rendtarget2D; } - queuemutex.Unlock(); + queuemutex.unlock(); int loop = 0; while (loop < 100) { - queuemutex.Lock(); + queuemutex.lock(); if (d3dtod2d.size()) { currentosd_backbuffer = d3dtod2d.front(); return currentosd_backbuffer.rendtarget2D; } - queuemutex.Unlock(); + queuemutex.unlock(); MILLISLEEP(100); loop++; @@ -1182,7 +1182,7 @@ ID2D1RenderTarget * OsdWinVector::LockOsdDrawing() } void OsdWinVector::UnlockOsdDrawing() { - queuemutex.Unlock(); + queuemutex.unlock(); } void OsdWinVector::lostDestroyObjects() diff --git a/osdwinvector.h b/osdwinvector.h index b046214..9a72ca9 100644 --- a/osdwinvector.h +++ b/osdwinvector.h @@ -14,25 +14,24 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #ifndef OSDWINVECTOR_H #define OSDWINVECTOR_H #include - -#include "osdvector.h" -#include "defines.h" -#include "log.h" -#include "windowsosd.h" -#include "mutex.h" #include #include #include #include #include +#include + +#include "osdvector.h" +#include "defines.h" +#include "log.h" +#include "windowsosd.h" @@ -128,7 +127,7 @@ protected: ID2D1RenderTarget * LockOsdDrawing(); void UnlockOsdDrawing(); - Mutex queuemutex; + std::mutex queuemutex; void initPaths(); void destroyPaths(); diff --git a/surfaceopengl.cc b/surfaceopengl.cc index c1745c0..ed8fb3c 100644 --- a/surfaceopengl.cc +++ b/surfaceopengl.cc @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #include @@ -40,19 +39,19 @@ SurfaceOpenGL::SurfaceOpenGL(int id) data=NULL; sheight=swidth=0; // fastdraw=false; - srf_mutex.Lock(); + srf_mutex.lock(); } SurfaceOpenGL::~SurfaceOpenGL() { - srf_mutex.Lock(); + srf_mutex.lock(); if (data) { free(data); data=NULL; } else { glDeleteTextures(1,&gltexture); } - srf_mutex.Unlock(); + srf_mutex.unlock(); } int SurfaceOpenGL::create(UINT width, UINT height) @@ -85,7 +84,7 @@ int SurfaceOpenGL::create(UINT width, UINT height) //osd->EndPainting(); - srf_mutex.Unlock(); + srf_mutex.unlock(); return 1; } @@ -94,12 +93,12 @@ void SurfaceOpenGL::display() } int SurfaceOpenGL::fillblt(int x, int y, int width, int height, const DrawStyle& c) { - srf_mutex.Lock(); + srf_mutex.lock(); //since this might be called before surface //allocation we will wait in this case, hopefully without deadlocks if (screen == this || !data ) { //This should not happen! - srf_mutex.Unlock(); + srf_mutex.unlock(); return 0; } @@ -110,7 +109,7 @@ int SurfaceOpenGL::fillblt(int x, int y, int width, int height, const DrawStyle& glViewport(0,0,swidth,sheight);*/ //osd->EndPainting(); - srf_mutex.Unlock(); + srf_mutex.unlock(); unsigned int my_c=InternalColour(c.rgba()); @@ -140,11 +139,11 @@ int SurfaceOpenGL::fillblt(int x, int y, int width, int height, const DrawStyle& void SurfaceOpenGL::startFastDraw(){ - srf_mutex.Lock(); + srf_mutex.lock(); } void SurfaceOpenGL::endFastDraw(){ - srf_mutex.Unlock(); + srf_mutex.unlock(); } void SurfaceOpenGL::drawPixel(int x, int y, Colour & colour, bool fastdraw) { @@ -167,7 +166,7 @@ void SurfaceOpenGL::drawPixel(int x, int y, unsigned int c, bool fastdraw) { } //OsdWin* osd; if (!fastdraw) { - srf_mutex.Lock(); //since this might be called before surface + srf_mutex.lock(); //since this might be called before surface } //allocation we will wait in this case, hopefully without deadlocks @@ -183,7 +182,7 @@ void SurfaceOpenGL::drawPixel(int x, int y, unsigned int c, bool fastdraw) { row[0] = my_c; if (!fastdraw) { - srf_mutex.Unlock(); //since this might be called before surface + srf_mutex.unlock(); //since this might be called before surface } } @@ -211,7 +210,7 @@ void SurfaceOpenGL::drawBitmap(int x, int y, const Bitmap& bm,const DisplayRegio int SurfaceOpenGL::updateToScreen(int sx, int sy, int w, int h, int dx, int dy) // FIXME new, replace others with this FIXME { // Log::getInstance()->log("Surface", Log::WARN, "UTS Mark1"); - srf_mutex.Lock();//since this might be called before surface + srf_mutex.lock();//since this might be called before surface //allocation we will wait in this case, hopefully without deadlocks OsdOpenGL* osd=((OsdOpenGL*)(Osd::getInstance())); @@ -233,7 +232,7 @@ int SurfaceOpenGL::updateToScreen(int sx, int sy, int w, int h, int dx, int dy) osd->EndPainting(); - srf_mutex.Unlock(); + srf_mutex.unlock(); return 0; } diff --git a/surfaceopengl.h b/surfaceopengl.h index 88ba56a..a3bec72 100644 --- a/surfaceopengl.h +++ b/surfaceopengl.h @@ -14,17 +14,17 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #ifndef SURFACEOPENGL_H #define SURFACEOPENGL_H +#include +#include + #include "defines.h" #include "surface.h" -#include "mutex.h" -#include class SurfaceOpenGL : public Surface { @@ -62,7 +62,7 @@ class SurfaceOpenGL : public Surface - Mutex srf_mutex; + std::mutex srf_mutex; protected: void drawPixel(int x, int y, Colour& c, bool fastdraw=false); void drawPixel(int x, int y, unsigned int c, bool fastdraw=false); diff --git a/surfacevector.cc b/surfacevector.cc index 52b19ec..a4c544c 100644 --- a/surfacevector.cc +++ b/surfacevector.cc @@ -14,16 +14,15 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ -#include "surfacevector.h" -#include "bitmap.h" -#include "staticartwork.h" #include #include #include +#include "bitmap.h" +#include "staticartwork.h" +#include "surfacevector.h" SurfaceVector::SurfaceVector(OsdVector* vosd) { @@ -72,7 +71,7 @@ int SurfaceVector::drawText(const char* text, int x, int y, int width, const Dra size_t length=strlen(text); - command_mutex.Lock(); + command_mutex.lock(); VectorHandle ref=osd->getStyleRef(c); float *charwidtharray=osd->getCharWidthArray(); @@ -97,7 +96,7 @@ int SurfaceVector::drawText(const char* text, int x, int y, int width, const Dra length -= num_bytes; run += num_bytes; if (shift>width && width >0) { - command_mutex.Unlock(); + command_mutex.unlock(); return 1; } num_bytes=mbrtowc(&tempo, run, length, &state); @@ -119,7 +118,7 @@ int SurfaceVector::drawText(const char* text, int x, int y, int width, const Dra #endif commands.resize(commands_size+chars); - command_mutex.Unlock(); + command_mutex.unlock(); return 1; } @@ -208,16 +207,16 @@ void SurfaceVector::drawJpeg(const char *fileName,int x, int y,int *width, int * /* void SurfaceVector::drawJpeg(const char *fileName,int x, int y,int *width, int *height) { - command_mutex.Lock(); + command_mutex.lock(); ImageIndex image=osd->getJpegRef(fileName,width,height); commands.push_back(SVGCommand::PaintImage(x,y,*width,*height,image,0)); - command_mutex.Unlock(); + command_mutex.unlock(); } */ void SurfaceVector::drawTVMedia(TVMediaInfo & tvmedia,float x, float y, float width, float height, Corner corner) { - command_mutex.Lock(); + command_mutex.lock(); ImageIndex image=0; LoadIndex load_index=osd->getTVMediaRef(tvmedia,image); if (width!=0 && height!=0) { @@ -231,14 +230,14 @@ void SurfaceVector::drawTVMedia(TVMediaInfo & tvmedia,float x, float y, float w commands.push_back(SVGCommand::PaintImageLoading(load_index,x,y,width,height,0,corner)); //Log::getInstance()->log("SurfaceVector", Log::DEBUG, "TVMedia Add instru image loading %d %d", load_index,image); } - command_mutex.Unlock(); + command_mutex.unlock(); } void SurfaceVector::drawClippingRectangle(float x, float y, float w, float h) { - command_mutex.Lock(); + command_mutex.lock(); commands.push_back(SVGCommand::PaintClipping((float)x,(float)y,(float)w,(float)h)); - command_mutex.Unlock(); + command_mutex.unlock(); } int SurfaceVector::create(UINT width, UINT height) @@ -254,33 +253,33 @@ void SurfaceVector::display() int SurfaceVector::fillblt(int x, int y, int width, int height, const DrawStyle& c) { - command_mutex.Lock(); + command_mutex.lock(); removeCommands(x,y,width,height); // remove commands below the box VectorHandle ref=osd->getStyleRef(c); commands.push_back(SVGCommand::PaintPath(x,y,width,height,PIRectangle,ref)); - command_mutex.Unlock(); + command_mutex.unlock(); return 1; } void SurfaceVector::drawHorzLine(int x1, int x2, int y, const DrawStyle& c) { - command_mutex.Lock(); + command_mutex.lock(); VectorHandle ref = osd->getStyleRef(c); commands.push_back(SVGCommand::PaintPath(x1,y,x2-x1,1,PIHorzLine,ref)); - command_mutex.Unlock(); + command_mutex.unlock(); } void SurfaceVector::drawVertLine(int x, int y1, int y2, const DrawStyle& c){ - command_mutex.Lock(); + command_mutex.lock(); VectorHandle ref = osd->getStyleRef(c); commands.push_back(SVGCommand::PaintPath(x,y1,1,y2-y1,PIVertLine,ref)); - command_mutex.Unlock(); + command_mutex.unlock(); } void SurfaceVector::drawBitmap(int x, int y, const Bitmap& bm,const DisplayRegion & region) { //this is complicated - command_mutex.Lock(); + command_mutex.lock(); /* unsigned int * data=(unsigned int*)malloc(sizeof(unsigned int)*bm.getWidth()*bm.getHeight()); for (UINT j = 0; j < bm.getHeight(); ++j){ @@ -306,23 +305,23 @@ void SurfaceVector::drawBitmap(int x, int y, const Bitmap& bm,const DisplayRegio SVGCommand temp=SVGCommand::PaintImage(tx,ty,tw,th,image,0); removeCommands(tx,ty,tw,th); commands.push_back(temp); - command_mutex.Unlock(); + command_mutex.unlock(); } void SurfaceVector::drawPoint(int x, int y, DrawStyle& c, bool fastdraw){ - if (!fastdraw) command_mutex.Lock(); + if (!fastdraw) command_mutex.lock(); VectorHandle ref = osd->getStyleRef(c); commands.push_back(SVGCommand::PaintPath(x,y,1,1,PIPoint,ref)); - if (!fastdraw) command_mutex.Unlock(); + if (!fastdraw) command_mutex.unlock(); } void SurfaceVector::drawMonoBitmap(UCHAR* base, int dx, int dy, unsigned int height,unsigned int width, DrawStyle& nextColour) { - command_mutex.Lock(); + command_mutex.lock(); ImageIndex image=osd->getMonoBitmapRef(base,width,height); VectorHandle ref = osd->getStyleRef(nextColour); removeCommands(dx,dy,width,height); commands.push_back(SVGCommand::PaintImage(dx,dy,height,width,image,ref)); - command_mutex.Unlock(); + command_mutex.unlock(); } @@ -385,25 +384,25 @@ int SurfaceVector::removeCommands(float x,float y,float width,float height) int SurfaceVector::updateToScreen(int sx, int sy, int w, int h, int dx, int dy) { // ok this method really works in a pixel oriented way - command_mutex.Lock(); + command_mutex.lock(); osd->updateOrAddSurface(this,dx-sx,dy-sy,swidth,sheight,commands); - command_mutex.Unlock(); + command_mutex.unlock(); return 1; } /* This is for systems which need a locking of the drawing surface to speed up drawing */ void SurfaceVector::startFastDraw() { - command_mutex.Lock(); + command_mutex.lock(); } void SurfaceVector::endFastDraw() { - command_mutex.Unlock(); + command_mutex.unlock(); } void SurfaceVector::drawTTChar(int ox, int oy,int x, int y, cTeletextChar c) { - command_mutex.Lock(); + command_mutex.lock(); std::vector::iterator itty=commands.begin(); while (itty!=commands.end()) { @@ -415,5 +414,5 @@ void SurfaceVector::drawTTChar(int ox, int oy,int x, int y, cTeletextChar c) } } commands.push_back(SVGCommand::PaintTTchar(ox,oy,x,y,c.getInternal())); - command_mutex.Unlock(); + command_mutex.unlock(); } diff --git a/surfacevector.h b/surfacevector.h index 903df7a..a6b29c6 100644 --- a/surfacevector.h +++ b/surfacevector.h @@ -20,6 +20,7 @@ #ifndef SURFACEVECTOR_H #define SURFACEVECTOR_H +#include #include #include "surface.h" @@ -72,7 +73,7 @@ class SurfaceVector : public Surface std::vector commands; int swidth, sheight; - Mutex command_mutex; + std::mutex command_mutex; OsdVector* osd; void drawPixel(int /* x */, int /* y */, unsigned int /* c */, bool /* fastdraw */){}; // these are not supported! diff --git a/videoomx.cc b/videoomx.cc index 8072910..ed52061 100644 --- a/videoomx.cc +++ b/videoomx.cc @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #include "videoomx.h" @@ -170,9 +169,9 @@ OMX_ERRORTYPE VideoOMX::EventHandler_OMX(OMX_IN OMX_HANDLETYPE handle,OMX_IN OMX void VideoOMX::AddOmxEvent(VPE_OMX_EVENT new_event) { - omx_event_mutex.Lock(); + omx_event_mutex.lock(); omx_events.push_back(new_event); - omx_event_mutex.Unlock(); + omx_event_mutex.unlock(); omx_event_ready_signal.signal(); } @@ -190,11 +189,11 @@ OMX_ERRORTYPE VideoOMX::EmptyBufferDone_OMX(OMX_IN OMX_HANDLETYPE hcomp,OMX_IN O } void VideoOMX::ReturnEmptyOMXBuffer(OMX_BUFFERHEADERTYPE* buffer){ - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); //Log::getInstance()->log("Video", Log::NOTICE, "ReturnEmptyOMXBuffer %d %d",input_bufs_omx_free.size(),input_bufs_omx_all.size()); input_bufs_omx_free.push_back(buffer); //Log::getInstance()->log("Video", Log::NOTICE, "ReturnEmptyOMXBuffer %d",input_bufs_omx_free.size()); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); omx_event_ready_signal.signal(); } @@ -603,7 +602,7 @@ bool VideoOMX::setVideoDisplay(VideoDisplay display) void VideoOMX::updateMode() { - clock_mutex.Lock(); + clock_mutex.lock(); if (omx_running) { int oldcancelstate; int oldcanceltype; @@ -624,7 +623,7 @@ void VideoOMX::updateMode() "Set OMX_IndexConfigDisplayRegion1 failed %x", error); pthread_setcancelstate(oldcancelstate, NULL); pthread_setcanceltype(oldcanceltype, NULL); - clock_mutex.Unlock(); + clock_mutex.unlock(); return; } @@ -639,7 +638,7 @@ void VideoOMX::updateMode() "Set OMX_IndexConfigDisplayRegion5 failed %x", error); pthread_setcancelstate(oldcancelstate, NULL); pthread_setcanceltype(oldcanceltype, NULL); - clock_mutex.Unlock(); + clock_mutex.unlock(); return; } @@ -659,7 +658,7 @@ void VideoOMX::updateMode() "Set OMX_IndexConfigDisplayRegion2 failed %x", error); pthread_setcancelstate(oldcancelstate, NULL); pthread_setcanceltype(oldcanceltype, NULL); - clock_mutex.Unlock(); + clock_mutex.unlock(); return; } @@ -677,7 +676,7 @@ void VideoOMX::updateMode() "Set OMX_IndexConfigDisplayRegion3 failed %x", error); pthread_setcancelstate(oldcancelstate, NULL); pthread_setcanceltype(oldcanceltype, NULL); - clock_mutex.Unlock(); + clock_mutex.unlock(); return; } @@ -690,7 +689,7 @@ void VideoOMX::updateMode() "Getting display size failed! (BCM API) "); pthread_setcancelstate(oldcancelstate, NULL); pthread_setcanceltype(oldcanceltype, NULL); - clock_mutex.Unlock(); + clock_mutex.unlock(); return; } //UnSetFullscreen with window @@ -712,7 +711,7 @@ void VideoOMX::updateMode() "Set OMX_IndexConfigDisplayRegion failed %x", error); pthread_setcancelstate(oldcancelstate, NULL); pthread_setcanceltype(oldcanceltype, NULL); - clock_mutex.Unlock(); + clock_mutex.unlock(); return; } } @@ -720,7 +719,7 @@ void VideoOMX::updateMode() pthread_setcanceltype(oldcanceltype, NULL); } - clock_mutex.Unlock(); + clock_mutex.unlock(); } int VideoOMX::signalOff() @@ -838,20 +837,20 @@ int VideoOMX::play() { int VideoOMX::initClock() { OMX_ERRORTYPE error; - clock_mutex.Lock(); + clock_mutex.lock(); if (clock_references==0) { static OMX_CALLBACKTYPE callbacks= {&EventHandler_OMX,&EmptyBufferDone_OMX,&FillBufferDone_OMX}; - omx_event_mutex.Lock(); + omx_event_mutex.lock(); omx_events.clear(); - omx_event_mutex.Unlock(); + omx_event_mutex.unlock(); error=OMX_GetHandle(&omx_clock,L_VPE_OMX_CLOCK,NULL,&callbacks); if (error!=OMX_ErrorNone) { Log::getInstance()->log("Video", Log::DEBUG, "Init OMX clock failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -864,7 +863,7 @@ int VideoOMX::initClock() error=OMX_GetParameter(omx_clock,OMX_IndexParamOtherInit,&p_param); if (error!=OMX_ErrorNone) { Log::getInstance()->log("Video", Log::DEBUG, "Init clock OMX_GetParameter failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -873,7 +872,7 @@ int VideoOMX::initClock() for (unsigned int i=0;ilog("Video", Log::DEBUG, "Disable Ports OMX clock failed %d",i); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -885,7 +884,7 @@ int VideoOMX::initClock() } Log::getInstance()->log("Video", Log::DEBUG, "init omx clock %x %x",this,omx_clock); clock_references++; - clock_mutex.Unlock(); + clock_mutex.unlock(); return 1; } @@ -898,7 +897,7 @@ int VideoOMX::getClockAudioandInit(OMX_HANDLETYPE *p_omx_clock,OMX_U32 *p_omx_cl if (!initClock()) { return 0; } - clock_mutex.Lock(); + clock_mutex.lock(); OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE refclock; memset(&refclock,0,sizeof(refclock)); @@ -911,7 +910,7 @@ int VideoOMX::getClockAudioandInit(OMX_HANDLETYPE *p_omx_clock,OMX_U32 *p_omx_cl error=OMX_SetConfig(omx_clock,OMX_IndexConfigTimeActiveRefClock,&refclock); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "Clock OMX_IndexConfigTimeActiveRefClock failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -923,7 +922,7 @@ int VideoOMX::getClockAudioandInit(OMX_HANDLETYPE *p_omx_clock,OMX_U32 *p_omx_cl error=OMX_GetParameter(omx_clock,OMX_IndexParamOtherInit,&p_param); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "Init clock OMX_GetParameter failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -945,7 +944,7 @@ int VideoOMX::getClockAudioandInit(OMX_HANDLETYPE *p_omx_clock,OMX_U32 *p_omx_cl *p_omx_clock_output_port=p_param.nStartPortNumber+1; *p_omx_clock=omx_clock; - clock_mutex.Unlock(); + clock_mutex.unlock(); return 1; } @@ -956,7 +955,7 @@ int VideoOMX::getClockVideoandInit() if (!initClock()) { return 0; } - clock_mutex.Lock(); + clock_mutex.lock(); if (clock_references==1) { // only if no audio is attached to this clock! OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE refclock; @@ -970,7 +969,7 @@ int VideoOMX::getClockVideoandInit() error=OMX_SetConfig(omx_clock,OMX_IndexConfigTimeActiveRefClock,&refclock); if (error!=OMX_ErrorNone) { Log::getInstance()->log("Video", Log::DEBUG, "Clock OMX_IndexConfigTimeActiveRefClock failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -983,7 +982,7 @@ int VideoOMX::getClockVideoandInit() error=OMX_GetParameter(omx_clock,OMX_IndexParamOtherInit,&p_param); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "Init clock OMX_GetParameter failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1016,7 +1015,7 @@ int VideoOMX::getClockVideoandInit() } omx_clock_output_port=p_param.nStartPortNumber; - clock_mutex.Unlock(); + clock_mutex.unlock(); return 1; } @@ -1025,7 +1024,7 @@ void VideoOMX::clockUnpause() { OMX_ERRORTYPE error; Log::getInstance()->log("Video", Log::NOTICE, "enter Clockunpause"); - clock_mutex.Lock(); + clock_mutex.lock(); if (clock_references>0 && clockpaused) { OMX_TIME_CONFIG_SCALETYPE scale_type; memset(&scale_type,0,sizeof(scale_type)); @@ -1039,7 +1038,7 @@ void VideoOMX::clockUnpause() Log::getInstance()->log("Video", Log::NOTICE, "set playback speed ClockUnpause"); clockpaused=false; } - clock_mutex.Unlock(); + clock_mutex.unlock(); } @@ -1047,7 +1046,7 @@ void VideoOMX::clockPause() { OMX_ERRORTYPE error; Log::getInstance()->log("Video", Log::NOTICE, "enter ClockPause"); - clock_mutex.Lock(); + clock_mutex.lock(); if (clock_references>0 && !clockpaused) { OMX_TIME_CONFIG_SCALETYPE scale_type; memset(&scale_type,0,sizeof(scale_type)); @@ -1061,7 +1060,7 @@ void VideoOMX::clockPause() Log::getInstance()->log("Video", Log::NOTICE, "set playback speed ClockPause"); clockpaused=true; } - clock_mutex.Unlock(); + clock_mutex.unlock(); } @@ -1100,7 +1099,7 @@ int VideoOMX::AllocateCodecsOMX() } /* TODO end */ - clock_mutex.Lock(); + clock_mutex.lock(); if (h264) { error=OMX_GetHandle(&omx_vid_dec,L_VPE_OMX_H264_DECODER,NULL,&callbacks); } else { @@ -1109,7 +1108,7 @@ int VideoOMX::AllocateCodecsOMX() if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "Init OMX video decoder failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1123,7 +1122,7 @@ int VideoOMX::AllocateCodecsOMX() error=OMX_GetParameter(omx_vid_dec,OMX_IndexParamVideoInit,&p_param); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "Init OMX h264 decoder OMX_GetParameter failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1132,7 +1131,7 @@ int VideoOMX::AllocateCodecsOMX() if (!DisablePort(omx_vid_dec,omx_codec_input_port) || !DisablePort(omx_vid_dec,omx_codec_output_port)) { Log::getInstance()->log("Video", Log::DEBUG, "Disable Ports OMX video decoder failed"); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1148,7 +1147,7 @@ int VideoOMX::AllocateCodecsOMX() error=OMX_SetParameter(omx_vid_dec,OMX_IndexParamBrcmVideoDecodeErrorConcealment,&conceal); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "OMX_IndexParamBrcmVideoDecodeErrorConcealment failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1159,7 +1158,7 @@ int VideoOMX::AllocateCodecsOMX() if (error != OMX_ErrorNone) { Log::getInstance()->log("Video", Log::DEBUG, "Init OMX video deinterlacer failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1170,7 +1169,7 @@ int VideoOMX::AllocateCodecsOMX() Log::getInstance()->log("Video", Log::DEBUG, "Init OMX video deinterlacer OMX_GetParameter failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1181,7 +1180,7 @@ int VideoOMX::AllocateCodecsOMX() || !DisablePort(omx_vid_deint, omx_deint_output_port, true)) { Log::getInstance()->log("Video", Log::DEBUG, "Disable Ports OMX video deint failed"); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1192,7 +1191,7 @@ int VideoOMX::AllocateCodecsOMX() error=OMX_GetHandle(&omx_vid_sched,L_VPE_OMX_VIDEO_SCHED,NULL,&callbacks); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "Init OMX video scheduler failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1202,7 +1201,7 @@ int VideoOMX::AllocateCodecsOMX() error=OMX_GetParameter(omx_vid_sched,OMX_IndexParamVideoInit,&p_param); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "Init OMX video scheduler OMX_GetParameter failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1213,7 +1212,7 @@ int VideoOMX::AllocateCodecsOMX() error=OMX_GetParameter(omx_vid_sched,OMX_IndexParamOtherInit,&p_param); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "Init OMX video scheduler OMX_GetParameter failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1224,7 +1223,7 @@ int VideoOMX::AllocateCodecsOMX() if (!DisablePort(omx_vid_sched,omx_shed_input_port,true) || !DisablePort(omx_vid_sched,omx_shed_output_port,true) || !DisablePort(omx_vid_sched,omx_shed_clock_port,true)) { Log::getInstance()->log("Video", Log::DEBUG, "Disable Ports OMX video shed failed"); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1233,7 +1232,7 @@ int VideoOMX::AllocateCodecsOMX() error=OMX_GetHandle(&omx_vid_rend,L_VPE_OMX_VIDEO_REND,NULL,&callbacks); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "Init OMX video rend failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1241,7 +1240,7 @@ int VideoOMX::AllocateCodecsOMX() error=OMX_GetParameter(omx_vid_rend,OMX_IndexParamVideoInit,&p_param); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "Init OMX video rend OMX_GetParameter failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1252,7 +1251,7 @@ int VideoOMX::AllocateCodecsOMX() if (!DisablePort(omx_vid_rend,omx_rend_input_port,true) /*|| !DisablePort(omx_vid_rend,omx_rend_output_port)*/ ) { Log::getInstance()->log("Video", Log::DEBUG, "Disable Ports OMX video rend failed"); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1264,7 +1263,7 @@ int VideoOMX::AllocateCodecsOMX() error=OMX_SetupTunnel(omx_clock,omx_clock_output_port,omx_vid_sched,omx_shed_clock_port); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "OMX_Setup tunnel clock to sched failed %x %d %d", error,omx_clock_output_port,omx_shed_clock_port); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1272,7 +1271,7 @@ int VideoOMX::AllocateCodecsOMX() if (!EnablePort(omx_clock,omx_clock_output_port,false) || !EnablePort(omx_vid_sched,omx_shed_clock_port,false) ) { Log::getInstance()->log("Video", Log::DEBUG, "Enable Ports OMX clock shed failed"); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1281,7 +1280,7 @@ int VideoOMX::AllocateCodecsOMX() if (!ChangeComponentState(omx_vid_sched,OMX_StateIdle)) { Log::getInstance()->log("Video", Log::DEBUG, "vid_sched idle ChangeComponentState"); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1290,7 +1289,7 @@ int VideoOMX::AllocateCodecsOMX() if ( !CommandFinished(omx_vid_sched,OMX_CommandPortEnable,omx_shed_clock_port)) { - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1300,7 +1299,7 @@ int VideoOMX::AllocateCodecsOMX() if ( !CommandFinished(omx_clock,OMX_CommandPortEnable,omx_clock_output_port)) { - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1332,7 +1331,7 @@ int VideoOMX::AllocateCodecsOMX() error=OMX_SetParameter(omx_vid_dec,OMX_IndexParamVideoPortFormat,&ft_type); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "Init OMX_IndexParamVideoPortFormat failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1340,7 +1339,7 @@ int VideoOMX::AllocateCodecsOMX() if (!ChangeComponentState(omx_vid_dec,OMX_StateIdle)) { Log::getInstance()->log("Video", Log::DEBUG, "vid_dec ChangeComponentState"); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1354,7 +1353,7 @@ int VideoOMX::AllocateCodecsOMX() error=OMX_SetConfig(omx_vid_dec,OMX_IndexConfigBufferStall,&stall_conf); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "Init OMX_IndexConfigBufferStall failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1370,7 +1369,7 @@ int VideoOMX::AllocateCodecsOMX() error=OMX_SetConfig(omx_vid_dec,OMX_IndexConfigRequestCallback,&req_callback); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "Init OMX_IndexConfigRequestCallback failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1378,7 +1377,7 @@ int VideoOMX::AllocateCodecsOMX() if (!PrepareInputBufsOMX()) { - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1387,7 +1386,7 @@ int VideoOMX::AllocateCodecsOMX() error=OMX_SetupTunnel(omx_vid_dec,omx_codec_output_port,omx_vid_sched,omx_shed_input_port); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "OMX_Setup tunnel dec to sched failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1397,13 +1396,13 @@ int VideoOMX::AllocateCodecsOMX() if (!EnablePort(omx_vid_dec,omx_codec_output_port,false) || !EnablePort(omx_vid_sched,omx_shed_input_port,false) ) { Log::getInstance()->log("Video", Log::DEBUG, "Enable Ports OMX codec shed failed"); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } if ( !CommandFinished(omx_vid_dec,OMX_CommandPortEnable,omx_codec_output_port) || !CommandFinished(omx_vid_sched,OMX_CommandPortEnable,omx_shed_input_port)) { - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1413,7 +1412,7 @@ int VideoOMX::AllocateCodecsOMX() error=OMX_SetupTunnel(omx_vid_dec,omx_codec_output_port,omx_vid_deint,omx_deint_input_port); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "OMX_Setup tunnel dec to deint failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1423,20 +1422,20 @@ int VideoOMX::AllocateCodecsOMX() if (!EnablePort(omx_vid_dec,omx_codec_output_port,false) || !EnablePort(omx_vid_deint,omx_deint_input_port,false) ) { Log::getInstance()->log("Video", Log::DEBUG, "Enable Ports OMX codec deint failed"); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } if ( !CommandFinished(omx_vid_dec,OMX_CommandPortEnable,omx_codec_output_port) || !CommandFinished(omx_vid_deint,OMX_CommandPortEnable,omx_deint_input_port)) { - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } if (!ChangeComponentState(omx_vid_deint,OMX_StateIdle)) { Log::getInstance()->log("Video", Log::DEBUG, "vid_deint ChangeComponentState"); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1474,7 +1473,7 @@ int VideoOMX::AllocateCodecsOMX() error=OMX_SetConfig(omx_vid_deint,OMX_IndexConfigCommonImageFilterParameters,&imagefilter); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "Init OMX_IndexConfigCommonImageFilterParameters failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1483,7 +1482,7 @@ int VideoOMX::AllocateCodecsOMX() error=OMX_SetupTunnel(omx_vid_deint,omx_deint_output_port,omx_vid_sched,omx_shed_input_port); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "OMX_Setup tunnel deint to sched failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1491,13 +1490,13 @@ int VideoOMX::AllocateCodecsOMX() if (!EnablePort(omx_vid_deint,omx_deint_output_port,false) || !EnablePort(omx_vid_sched,omx_shed_input_port,false) ) { Log::getInstance()->log("Video", Log::DEBUG, "Enable Ports OMX deint shed failed"); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } if ( !CommandFinished(omx_vid_deint,OMX_CommandPortEnable,omx_deint_output_port) || !CommandFinished(omx_vid_sched,OMX_CommandPortEnable,omx_shed_input_port)) { - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1506,7 +1505,7 @@ int VideoOMX::AllocateCodecsOMX() if (!ChangeComponentState(omx_vid_dec,OMX_StateExecuting)) { Log::getInstance()->log("Video", Log::DEBUG, "omx_vid_dec ChangeComponentState Execute"); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1514,7 +1513,7 @@ int VideoOMX::AllocateCodecsOMX() error=OMX_SetupTunnel(omx_vid_sched,omx_shed_output_port,omx_vid_rend,omx_rend_input_port); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "OMX_Setup tunnel sched to rend failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1522,21 +1521,21 @@ int VideoOMX::AllocateCodecsOMX() if (!EnablePort(omx_vid_sched,omx_shed_output_port,false) || !EnablePort(omx_vid_rend,omx_rend_input_port,false) ) { Log::getInstance()->log("Video", Log::DEBUG, "Enable Ports OMX shed rend failed"); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } if (!CommandFinished(omx_vid_sched,OMX_CommandPortEnable,omx_shed_output_port) || !CommandFinished(omx_vid_rend,OMX_CommandPortEnable,omx_rend_input_port)) { - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } if (!ChangeComponentState(omx_vid_rend,OMX_StateIdle)) { Log::getInstance()->log("Video", Log::DEBUG, "vid_rend ChangeComponentState"); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1544,7 +1543,7 @@ int VideoOMX::AllocateCodecsOMX() if (dodeint) { if (!ChangeComponentState(omx_vid_deint,OMX_StateExecuting)) { Log::getInstance()->log("Video", Log::DEBUG, "vid_vid_deint ChangeComponentState"); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1554,14 +1553,14 @@ int VideoOMX::AllocateCodecsOMX() if (!ChangeComponentState(omx_vid_sched,OMX_StateExecuting)) { Log::getInstance()->log("Video", Log::DEBUG, "omx_vid_sched ChangeComponentState Execute"); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } if (!ChangeComponentState(omx_vid_rend,OMX_StateExecuting)) { Log::getInstance()->log("Video", Log::DEBUG, "omx_vid_rend ChangeComponentState Execute"); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1579,7 +1578,7 @@ int VideoOMX::AllocateCodecsOMX() error=OMX_SetConfig(omx_vid_rend,OMX_IndexConfigDisplayRegion,&dispconf); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "Init OMX_IndexConfigDisplayRegion failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; }*/ @@ -1589,7 +1588,7 @@ int VideoOMX::AllocateCodecsOMX() error=OMX_SetParameter(omx_vid_rend,OMX_IndexConfigDisplayRegion,&dispconf); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "Init OMX_IndexConfigDisplayRegion failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1602,7 +1601,7 @@ int VideoOMX::AllocateCodecsOMX() error=OMX_SetParameter(omx_vid_rend,OMX_IndexConfigDisplayRegion,&dispconf); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "Init OMX_IndexConfigDisplayRegion failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; }*/ @@ -1612,7 +1611,7 @@ int VideoOMX::AllocateCodecsOMX() iframemode=false; omx_running=true; - clock_mutex.Unlock(); + clock_mutex.unlock(); clockUnpause(); updateMode(); @@ -1629,17 +1628,17 @@ int VideoOMX::idleClock() { //OMX_ERRORTYPE error; OMX_STATETYPE temp_state; - clock_mutex.Lock(); + clock_mutex.lock(); OMX_GetState(omx_clock,&temp_state); if (temp_state!=OMX_StateIdle) { if (!ChangeComponentState(omx_clock,OMX_StateIdle)) { Log::getInstance()->log("Video", Log::DEBUG, "omx_clock ChangeComponentState Idle failed"); - clock_mutex.Unlock(); + clock_mutex.unlock(); return 0; } } - clock_mutex.Unlock(); + clock_mutex.unlock(); return 1; } @@ -1647,13 +1646,13 @@ int VideoOMX::setClockExecutingandRunning() { OMX_ERRORTYPE error; OMX_STATETYPE temp_state; - clock_mutex.Lock(); + clock_mutex.lock(); OMX_GetState(omx_clock,&temp_state); if (temp_state!=OMX_StateExecuting) { if (!ChangeComponentState(omx_clock,OMX_StateExecuting)) { Log::getInstance()->log("Video", Log::DEBUG, "omx_clock ChangeComponentState Execute failed"); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } @@ -1667,11 +1666,11 @@ int VideoOMX::setClockExecutingandRunning() error=OMX_SetConfig(omx_clock,OMX_IndexConfigTimeClockState,&clock_conf); if (error!=OMX_ErrorNone) { Log::getInstance()->log("Video", Log::DEBUG, "Clock IndexConfigTimeClockState failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); DeAllocateCodecsOMX(); return 0; } - clock_mutex.Unlock(); + clock_mutex.unlock(); return 1; } @@ -1771,7 +1770,7 @@ int VideoOMX::WaitForEvent(OMX_HANDLETYPE handle,OMX_U32 event, int wait) //need int i=0; int iend=(wait/5+1); while (i::iterator itty=omx_events.begin(); while (itty!=omx_events.end()) { @@ -1779,13 +1778,13 @@ int VideoOMX::WaitForEvent(OMX_HANDLETYPE handle,OMX_U32 event, int wait) //need if (current.handle==handle) { //this is ours if (current.event_type==OMX_EventError) { omx_events.erase(itty); - omx_event_mutex.Unlock(); + omx_event_mutex.unlock(); Log::getInstance()->log("Video", Log::DEBUG, "WaitForEvent Finished on Error"); return 0; } else if (current.event_type==event) { omx_events.erase(itty); - omx_event_mutex.Unlock(); + omx_event_mutex.unlock(); Log::getInstance()->log("Video", Log::DEBUG, "WaitForEvent Finished Completed"); return 1; } @@ -1793,7 +1792,7 @@ int VideoOMX::WaitForEvent(OMX_HANDLETYPE handle,OMX_U32 event, int wait) //need itty++; } - omx_event_mutex.Unlock(); + omx_event_mutex.unlock(); omx_event_ready_signal.waitForSignalTimed(10); //MILLISLEEP(2); i++; @@ -1806,16 +1805,16 @@ int VideoOMX::WaitForEvent(OMX_HANDLETYPE handle,OMX_U32 event, int wait) //need int VideoOMX::clearEvents() { - omx_event_mutex.Lock(); + omx_event_mutex.lock(); omx_events.clear(); - omx_event_mutex.Unlock(); + omx_event_mutex.unlock(); return 1; } int VideoOMX::clearEventsForComponent(OMX_HANDLETYPE handle) { - omx_event_mutex.Lock(); + omx_event_mutex.lock(); std::list::iterator itty=omx_events.begin(); while (itty!=omx_events.end()) { VPE_OMX_EVENT current=*itty; @@ -1826,15 +1825,15 @@ int VideoOMX::clearEventsForComponent(OMX_HANDLETYPE handle) itty++; } - omx_event_mutex.Unlock(); + omx_event_mutex.unlock(); return 1; } void VideoOMX::checkForStalledBuffers() { //Log::getInstance()->log("Video", Log::DEBUG, "Check stalled"); - clock_mutex.Lock(); - omx_event_mutex.Lock(); + clock_mutex.lock(); + omx_event_mutex.lock(); std::list::iterator itty=omx_events.begin(); while (itty!=omx_events.end()) { VPE_OMX_EVENT current=*itty; @@ -1851,8 +1850,8 @@ void VideoOMX::checkForStalledBuffers() error=OMX_GetConfig(omx_vid_dec,OMX_IndexConfigBufferStall,&stall_conf); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "Get OMX_IndexConfigBufferStall failed %x", error); - clock_mutex.Unlock(); - omx_event_mutex.Unlock(); + clock_mutex.unlock(); + omx_event_mutex.unlock(); return ; } if (stall_conf.bStalled==OMX_TRUE) { @@ -1867,8 +1866,8 @@ void VideoOMX::checkForStalledBuffers() } itty++; } - omx_event_mutex.Unlock(); - clock_mutex.Unlock(); + omx_event_mutex.unlock(); + clock_mutex.unlock(); } @@ -1878,7 +1877,7 @@ int VideoOMX::CommandFinished(OMX_HANDLETYPE handle,OMX_U32 command,OMX_U32 data { int i=0; while (i<200/*1000*/) { - omx_event_mutex.Lock(); + omx_event_mutex.lock(); std::list::iterator itty=omx_events.begin(); while (itty!=omx_events.end()) { @@ -1886,13 +1885,13 @@ int VideoOMX::CommandFinished(OMX_HANDLETYPE handle,OMX_U32 command,OMX_U32 data if (current.handle==handle) { //this is ours if (current.event_type==OMX_EventError) { omx_events.erase(itty); - omx_event_mutex.Unlock(); + omx_event_mutex.unlock(); Log::getInstance()->log("Video", Log::DEBUG, "Command Finished on Error %x",current.data1); return 0; } else if (current.event_type==OMX_EventCmdComplete && current.data1==command && current.data2==data2) { omx_events.erase(itty); - omx_event_mutex.Unlock(); + omx_event_mutex.unlock(); //Log::getInstance()->log("Video", Log::DEBUG, "Command Finished Completed"); return 1; } @@ -1900,7 +1899,7 @@ int VideoOMX::CommandFinished(OMX_HANDLETYPE handle,OMX_U32 command,OMX_U32 data itty++; } - omx_event_mutex.Unlock(); + omx_event_mutex.unlock(); omx_event_ready_signal.waitForSignalTimed(10); //MILLISLEEP(2); i++; @@ -1947,7 +1946,7 @@ int VideoOMX::PrepareInputBufsOMX() //needs to be called with locked mutex return 0; } - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); for (unsigned int i=0; i< port_def_type.nBufferCountActual;i++) { // unsigned char* new_buffer_data=(unsigned char*)malloc(port_def_type.nbufferSize); @@ -1955,13 +1954,13 @@ int VideoOMX::PrepareInputBufsOMX() //needs to be called with locked mutex /* error=OMX_Usebuffer(omx_vid_dec,&buf_head,omx_codec_input_port,NULL,port_def_type.nbufferSize,new_buffer_data); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "Use OMX_Usebuffer failed %x", error); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); return 0; }*/ error=OMX_AllocateBuffer(omx_vid_dec,&buf_head,omx_codec_input_port,NULL,port_def_type.nBufferSize); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "Use OMX_AllocateBuffer failed %x", error); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); return 0; } input_bufs_omx_all.push_back(buf_head); @@ -1971,7 +1970,7 @@ int VideoOMX::PrepareInputBufsOMX() //needs to be called with locked mutex firstsynched=false; cur_input_buf_omx=NULL; - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); Log::getInstance()->log("Video", Log::DEBUG, "PrepareInputBufsOMX mark3"); @@ -1988,21 +1987,21 @@ int VideoOMX::DestroyInputBufsOMX() //need s to be called with locked mutex OMX_ERRORTYPE error; cur_input_buf_omx=NULL; - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); for (UINT i=0; i< input_bufs_omx_all.size();i++) { // free(input_bufs_omx_all[i]->pBuffer); // input_bufs_omx_all[i]->pBuffer=NULL; error=OMX_FreeBuffer(omx_vid_dec,omx_codec_input_port,input_bufs_omx_all[i]); if (error!=OMX_ErrorNone){ Log::getInstance()->log("Video", Log::DEBUG, "Use OMX_FreeBuffer failed %x", error); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); return 0; } } input_bufs_omx_all.clear(); input_bufs_omx_free.clear(); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); return 1; } @@ -2154,7 +2153,7 @@ int VideoOMX::DeAllocateCodecsOMX() cur_input_buf_omx=NULL;//write out old data } - clock_mutex.Lock(); + clock_mutex.lock(); clearEvents(); if (omx_vid_dec) { // first stop the omx elements @@ -2162,10 +2161,10 @@ int VideoOMX::DeAllocateCodecsOMX() Log::getInstance()->log("Video", Log::DEBUG, "vid_dec ChangeComponentState"); } - clock_mutex.Unlock(); + clock_mutex.unlock(); idleClock(); - clock_mutex.Lock(); + clock_mutex.lock(); if (dodeint) { if (!ChangeComponentState(omx_vid_deint, OMX_StateIdle)) { @@ -2338,12 +2337,12 @@ int VideoOMX::DeAllocateCodecsOMX() error=OMX_FreeHandle(omx_vid_rend); if (dodeint) error=OMX_FreeHandle(omx_vid_deint); omx_vid_dec=NULL; - clock_mutex.Unlock(); + clock_mutex.unlock(); destroyClock(); if (error!=OMX_ErrorNone) { Log::getInstance()->log("Video", Log::DEBUG, "FreeHandle failed %d", error); } - } else clock_mutex.Unlock(); + } else clock_mutex.unlock(); Log::getInstance()->log("Video", Log::DEBUG, "leave deallocate codecs OMX"); return 1; @@ -2352,7 +2351,7 @@ int VideoOMX::DeAllocateCodecsOMX() void VideoOMX::destroyClock() { - clock_mutex.Lock(); + clock_mutex.lock(); if (clock_references>0) { clock_references--; if (clock_references==0) { @@ -2365,7 +2364,7 @@ void VideoOMX::destroyClock() } } - clock_mutex.Unlock(); + clock_mutex.unlock(); } @@ -2456,7 +2455,7 @@ ULLONG VideoOMX::getCurrentTimestamp() { int oldcanceltype; pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldcancelstate); pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldcanceltype); - clock_mutex.Lock(); + clock_mutex.lock(); OMX_ERRORTYPE error; OMX_TIME_CONFIG_CLOCKSTATETYPE clock_conf; memset(&clock_conf, 0, sizeof(clock_conf)); @@ -2485,7 +2484,7 @@ ULLONG VideoOMX::getCurrentTimestamp() { ncur_clock_time = cur_clock_time = temp * 10LL; } } - clock_mutex.Unlock(); + clock_mutex.unlock(); pthread_setcancelstate(oldcancelstate, NULL); pthread_setcanceltype(oldcanceltype, NULL); } @@ -2610,7 +2609,7 @@ void VideoOMX::FirstFrameFix() Demuxer* demux=Demuxer::getInstance(); pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldcancelstate); pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldcanceltype); - clock_mutex.Lock(); + clock_mutex.lock(); if (WaitForEvent(omx_vid_dec,OMX_EventPortSettingsChanged,0)){ WaitForEvent(omx_vid_deint,OMX_EventPortSettingsChanged,0); //clear old messages OMX_ERRORTYPE error; @@ -2624,7 +2623,7 @@ void VideoOMX::FirstFrameFix() if (error != OMX_ErrorNone) { Log::getInstance()->log("Video", Log::DEBUG, "OMX_IndexParamPortDefinition fix failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); return; } @@ -2668,7 +2667,7 @@ void VideoOMX::FirstFrameFix() if (error != OMX_ErrorNone) { Log::getInstance()->log("Video", Log::DEBUG, "Set OMX_IndexParamPortDefinition1 failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); pthread_setcancelstate(oldcancelstate, NULL); pthread_setcanceltype(oldcanceltype, NULL); return; @@ -2682,7 +2681,7 @@ void VideoOMX::FirstFrameFix() if (error != OMX_ErrorNone) { Log::getInstance()->log("Video", Log::DEBUG, "Set OMX_IndexParamPortDefinition1 failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); pthread_setcancelstate(oldcancelstate, NULL); pthread_setcanceltype(oldcanceltype, NULL); return; @@ -2699,7 +2698,7 @@ void VideoOMX::FirstFrameFix() if (error != OMX_ErrorNone) { Log::getInstance()->log("Video", Log::DEBUG, "Get OMX_IndexParamPortDefinition2 failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); pthread_setcancelstate(oldcancelstate, NULL); pthread_setcanceltype(oldcanceltype, NULL); return; @@ -2722,7 +2721,7 @@ void VideoOMX::FirstFrameFix() if (error != OMX_ErrorNone) { Log::getInstance()->log("Video", Log::DEBUG, "Set OMX_IndexParamPortDefinition3 failed %x", error); - clock_mutex.Unlock(); + clock_mutex.unlock(); pthread_setcancelstate(oldcancelstate, NULL); pthread_setcanceltype(oldcanceltype, NULL); return; @@ -2736,7 +2735,7 @@ void VideoOMX::FirstFrameFix() EnablePort(omx_vid_dec,omx_codec_output_port,true); EnablePort(omx_vid_sched,omx_shed_input_port,true); } - clock_mutex.Unlock(); + clock_mutex.unlock(); pthread_setcancelstate(oldcancelstate, NULL); pthread_setcanceltype(oldcanceltype, NULL); @@ -2768,7 +2767,7 @@ OMX_ERRORTYPE VideoOMX::ProtOMXEmptyThisBuffer(OMX_HANDLETYPE handle, OMX_BUFFER //pthread_testcancel(); pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldcancelstate); pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldcanceltype); - clock_mutex.Lock(); + clock_mutex.lock(); // Diagnosis code /* OMX_ERRORTYPE error; OMX_TIME_CONFIG_TIMESTAMPTYPE timestamp; @@ -2792,7 +2791,7 @@ OMX_ERRORTYPE VideoOMX::ProtOMXEmptyThisBuffer(OMX_HANDLETYPE handle, OMX_BUFFER Log::getInstance()->log("Video", Log::NOTICE, "OMXETB %x %lld %lld %x",handle,temp,temp2,buffer->nFlags);*/ OMX_ERRORTYPE ret_val; ret_val=OMX_EmptyThisBuffer(handle,buffer); - clock_mutex.Unlock(); + clock_mutex.unlock(); pthread_setcancelstate(oldcancelstate, NULL); pthread_setcanceltype(oldcanceltype, NULL); //pthread_testcancel(); @@ -2842,9 +2841,9 @@ bool VideoOMX::DrainTargetBufferFull() { //Check, if we have OMX output buffers bool full; - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); full=(input_bufs_omx_free.size()==0); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); checkForStalledBuffers(); // check if the decoder has a problem if (full && omx_vid_stalled && !omx_first_frame) { omx_vid_stalled=false; @@ -2855,10 +2854,10 @@ bool VideoOMX::DrainTargetBufferFull() pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldcancelstate); pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldcanceltype); - clock_mutex.Lock(); + clock_mutex.lock(); FlushRenderingPipe(); omx_first_frame=true; - clock_mutex.Unlock(); + clock_mutex.unlock(); pthread_setcancelstate(oldcancelstate, NULL); pthread_setcanceltype(oldcanceltype, NULL); @@ -2981,9 +2980,9 @@ UINT VideoOMX::DeliverMediaPacket(MediaPacket packet, } //Log::getInstance()->log("Video", Log::DEBUG, "DMP mark 6"); if (!cur_input_buf_omx) { - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); if (input_bufs_omx_free.size()==0) { - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); //Log::getInstance()->log("Video", Log::DEBUG, "Deliver MediaPacket no free sample"); //Log::getInstance()->log("Video", Log::DEBUG, "DMP mark 7"); return 0; // we do not have a free media sample @@ -2994,7 +2993,7 @@ UINT VideoOMX::DeliverMediaPacket(MediaPacket packet, cur_input_buf_omx->nOffset=0; cur_input_buf_omx->nTimeStamp=intToOMXTicks(0); input_bufs_omx_free.pop_front(); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); } @@ -3045,9 +3044,9 @@ UINT VideoOMX::DeliverMediaPacket(MediaPacket packet, PutBufferToPres(cur_input_buf_omx); cur_input_buf_omx=NULL; // get5 new buffer - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); if (input_bufs_omx_free.size()==0) { - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); // Log::getInstance()->log("Video", Log::DEBUG, "Deliver MediaPacket no free sample2"); return *samplepos; // we do not have a free media sample } @@ -3057,7 +3056,7 @@ UINT VideoOMX::DeliverMediaPacket(MediaPacket packet, cur_input_buf_omx->nFlags=OMX_BUFFERFLAG_TIME_UNKNOWN; cur_input_buf_omx->nTimeStamp=intToOMXTicks(0); input_bufs_omx_free.pop_front(); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); //Log::getInstance()->log("Video", Log::DEBUG, "DMP mark 10"); } @@ -3084,9 +3083,9 @@ bool VideoOMX::displayIFrame(const UCHAR* buffer, UINT length) { //int haveToCopy = length; if (!cur_input_buf_omx) { - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); if (input_bufs_omx_free.size() == 0) { - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); // Log::getInstance()->log("Video", Log::DEBUG, // "Deliver MediaPacket no free sample"); return false; // we do not have a free media sample @@ -3097,7 +3096,7 @@ bool VideoOMX::displayIFrame(const UCHAR* buffer, UINT length) { cur_input_buf_omx->nOffset = 0; cur_input_buf_omx->nTimeStamp = intToOMXTicks(0); input_bufs_omx_free.pop_front(); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); } int read_pos = 0; @@ -3141,9 +3140,9 @@ bool VideoOMX::displayIFrame(const UCHAR* buffer, UINT length) { while (count < 100 && omx_running && iframemode) { count++; - input_bufs_omx_mutex.Lock(); + input_bufs_omx_mutex.lock(); if (input_bufs_omx_free.size() == 0) { - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); // Log::getInstance()->log("Video", Log::DEBUG, // "Ifrane no free sample"); MILLISLEEP(5); @@ -3156,7 +3155,7 @@ bool VideoOMX::displayIFrame(const UCHAR* buffer, UINT length) { cur_input_buf_omx->nTimeStamp = intToOMXTicks(0); cur_input_buf_omx->nFlags|= OMX_BUFFERFLAG_TIME_UNKNOWN; input_bufs_omx_free.pop_front(); - input_bufs_omx_mutex.Unlock(); + input_bufs_omx_mutex.unlock(); break; } if (!cur_input_buf_omx) diff --git a/videoomx.h b/videoomx.h index a17b6b1..b3819b7 100644 --- a/videoomx.h +++ b/videoomx.h @@ -14,29 +14,24 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #ifndef VIDEOOMX_H #define VIDEOOMX_H -#include "mutex.h" -#include "signal.h" - - #include #include #include #include #include - #include - #include #include +#include +#include "signal.h" #include "defines.h" #include "video.h" @@ -222,8 +217,8 @@ class VideoOMX : public Video int idleClock(); int getClockAudioandInit(OMX_HANDLETYPE *p_omx_clock,OMX_U32 *p_omx_clock_output_port); int getClockVideoandInit(); - void LockClock() {clock_mutex.Lock();}; - void UnlockClock() {clock_mutex.Unlock();}; + void LockClock() {clock_mutex.lock();}; + void UnlockClock() {clock_mutex.unlock();}; OMX_ERRORTYPE ProtOMXEmptyThisBuffer(OMX_HANDLETYPE handle, OMX_BUFFERHEADERTYPE* buffer); void clockPause(); void clockUnpause(); @@ -233,7 +228,7 @@ class VideoOMX : public Video void interlaceSwitch4Demux(); - Mutex clock_mutex; //clock mutex is now responsible for all omx stuff + std::mutex clock_mutex; //clock mutex is now responsible for all omx stuff long long cur_clock_time; @@ -271,7 +266,7 @@ class VideoOMX : public Video std::vector input_bufs_omx_all; std::list input_bufs_omx_free; - Mutex input_bufs_omx_mutex; + std::mutex input_bufs_omx_mutex; OMX_BUFFERHEADERTYPE* cur_input_buf_omx; void PutBufferToPres(OMX_BUFFERHEADERTYPE* buffer); @@ -281,7 +276,7 @@ class VideoOMX : public Video bool omx_running; bool omx_first_frame; - Mutex omx_event_mutex; + std::mutex omx_event_mutex; Signal omx_event_ready_signal; std::list omx_events; -- 2.39.5