diff options
| author | Thomas Reufer <thomas@reufer.ch> | 2015-03-21 23:29:40 +0100 |
|---|---|---|
| committer | Thomas Reufer <thomas@reufer.ch> | 2015-03-21 23:29:40 +0100 |
| commit | 5d0ea756502892250088df8316fd30f5c0a2769b (patch) | |
| tree | 2e71daa2f1b2210932afa9db1e7d8de9a8d8b147 | |
| parent | b212831c571836e7b8a3870fd5a70a3e75a9cf90 (diff) | |
| download | vdr-plugin-rpihddevice-5d0ea756502892250088df8316fd30f5c0a2769b.tar.gz vdr-plugin-rpihddevice-5d0ea756502892250088df8316fd30f5c0a2769b.tar.bz2 | |
improved locking for OMX buffer and event handling
| -rw-r--r-- | omx.c | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -93,16 +93,15 @@ public: Event* event = 0; while (true) { - m_mutex->Lock(); if (!m_events.empty()) { + m_mutex->Lock(); event = m_events.front(); m_events.pop(); m_mutex->Unlock(); break; } - m_mutex->Unlock(); - m_signal->Wait(); + m_signal->Wait(10); } return event; } @@ -1143,15 +1142,15 @@ void cOmx::SetDisplayRegion(int x, int y, int width, int height) OMX_BUFFERHEADERTYPE* cOmx::GetAudioBuffer(uint64_t pts) { - Lock(); - OMX_BUFFERHEADERTYPE* buf = 0; if (m_spareAudioBuffers) { + Lock(); buf = m_spareAudioBuffers; m_spareAudioBuffers = static_cast <OMX_BUFFERHEADERTYPE*>(buf->pAppPrivate); buf->pAppPrivate = 0; + Unlock(); } else buf = ilclient_get_input_buffer(m_comp[eAudioRender], 100, 0); @@ -1173,21 +1172,20 @@ OMX_BUFFERHEADERTYPE* cOmx::GetAudioBuffer(uint64_t pts) else m_freeAudioBuffers = false; - Unlock(); return buf; } OMX_BUFFERHEADERTYPE* cOmx::GetVideoBuffer(uint64_t pts) { - Lock(); - OMX_BUFFERHEADERTYPE* buf = 0; if (m_spareVideoBuffers) { + Lock(); buf = m_spareVideoBuffers; m_spareVideoBuffers = static_cast <OMX_BUFFERHEADERTYPE*>(buf->pAppPrivate); buf->pAppPrivate = 0; + Unlock(); } else buf = ilclient_get_input_buffer(m_comp[eVideoDecoder], 130, 0); @@ -1213,7 +1211,6 @@ OMX_BUFFERHEADERTYPE* cOmx::GetVideoBuffer(uint64_t pts) else m_freeVideoBuffers = false; - Unlock(); return buf; } @@ -1265,11 +1262,13 @@ bool cOmx::EmptyAudioBuffer(OMX_BUFFERHEADERTYPE *buf) m_setVideoDiscontinuity = true; buf->nFilledLen = 0; + + Lock(); buf->pAppPrivate = m_spareAudioBuffers; m_spareAudioBuffers = buf; + Unlock(); return false; } - return true; } @@ -1291,10 +1290,12 @@ bool cOmx::EmptyVideoBuffer(OMX_BUFFERHEADERTYPE *buf) m_setVideoStartTime = true; buf->nFilledLen = 0; + + Lock(); buf->pAppPrivate = m_spareVideoBuffers; m_spareVideoBuffers = buf; + Unlock(); return false; } - return true; } |
