diff --git a/OMXVideo.cpp b/OMXVideo.cpp index 7b611d4c..330f25d6 100644 --- a/OMXVideo.cpp +++ b/OMXVideo.cpp @@ -88,6 +88,7 @@ COMXVideo::~COMXVideo() bool COMXVideo::SendDecoderConfig() { + CSingleLock lock (m_critSection); OMX_ERRORTYPE omx_err = OMX_ErrorNone; /* send decoder config */ @@ -140,6 +141,7 @@ bool COMXVideo::NaluFormatStartCodes(enum AVCodecID codec, uint8_t *in_extradata bool COMXVideo::PortSettingsChanged() { + CSingleLock lock (m_critSection); OMX_ERRORTYPE omx_err = OMX_ErrorNone; if (m_settings_changed) @@ -333,6 +335,7 @@ bool COMXVideo::PortSettingsChanged() bool COMXVideo::Open(COMXStreamInfo &hints, OMXClock *clock, const CRect &DestRect, float display_aspect, EDEINTERLACEMODE deinterlace, bool hdmi_clock_sync, float fifo_size) { + CSingleLock lock (m_critSection); bool vflip = false; Close(); OMX_ERRORTYPE omx_err = OMX_ErrorNone; @@ -760,6 +763,7 @@ bool COMXVideo::Open(COMXStreamInfo &hints, OMXClock *clock, const CRect &DestRe void COMXVideo::Close() { + CSingleLock lock (m_critSection); m_omx_tunnel_clock.Deestablish(); m_omx_tunnel_decoder.Deestablish(); if(m_deinterlace) @@ -795,19 +799,22 @@ void COMXVideo::SetDropState(bool bDrop) unsigned int COMXVideo::GetFreeSpace() { + CSingleLock lock (m_critSection); return m_omx_decoder.GetInputBufferSpace(); } unsigned int COMXVideo::GetSize() { + CSingleLock lock (m_critSection); return m_omx_decoder.GetInputBufferSize(); } int COMXVideo::Decode(uint8_t *pData, int iSize, double pts) { + CSingleLock lock (m_critSection); OMX_ERRORTYPE omx_err; - if( m_drop_state ) + if( m_drop_state || !m_is_open ) return true; unsigned int demuxer_bytes = (unsigned int)iSize; @@ -896,6 +903,7 @@ int COMXVideo::Decode(uint8_t *pData, int iSize, double pts) void COMXVideo::Reset(void) { + CSingleLock lock (m_critSection); if(!m_is_open) return; @@ -910,6 +918,7 @@ void COMXVideo::Reset(void) /////////////////////////////////////////////////////////////////////////////////////////// void COMXVideo::SetVideoRect(const CRect& SrcRect, const CRect& DestRect) { + CSingleLock lock (m_critSection); if(!m_is_open) return; @@ -958,11 +967,13 @@ void COMXVideo::SetVideoRect(const CRect& SrcRect, const CRect& DestRect) int COMXVideo::GetInputBufferSize() { + CSingleLock lock (m_critSection); return m_omx_decoder.GetInputBufferSize(); } void COMXVideo::SubmitEOS() { + CSingleLock lock (m_critSection); if(!m_is_open) return; @@ -996,6 +1007,7 @@ void COMXVideo::SubmitEOS() bool COMXVideo::IsEOS() { + CSingleLock lock (m_critSection); if(!m_is_open) return true; if (!m_failed_eos && !m_omx_render.IsEOS()) @@ -1010,6 +1022,7 @@ bool COMXVideo::IsEOS() OMXPacket *COMXVideo::GetText() { + CSingleLock lock (m_critSection); OMX_BUFFERHEADERTYPE *omx_buffer = m_omx_text.GetOutputBuffer(0); OMXPacket *pkt = NULL; @@ -1037,6 +1050,7 @@ OMXPacket *COMXVideo::GetText() int COMXVideo::DecodeText(uint8_t *pData, int iSize, double dts, double pts) { + CSingleLock lock (m_critSection); OMX_ERRORTYPE omx_err; if (pData || iSize > 0) diff --git a/OMXVideo.h b/OMXVideo.h index c1f5fbf8..6c35dd4c 100644 --- a/OMXVideo.h +++ b/OMXVideo.h @@ -31,6 +31,7 @@ #include "OMXReader.h" #include "guilib/Geometry.h" +#include "utils/SingleLock.h" #define VIDEO_BUFFERS 60 @@ -113,6 +114,7 @@ class COMXVideo bool m_failed_eos; OMX_DISPLAYTRANSFORMTYPE m_transform; bool m_settings_changed; + CCriticalSection m_critSection; }; #endif