summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Reufer <thomas@reufer.ch>2015-04-03 09:10:21 +0200
committerThomas Reufer <thomas@reufer.ch>2015-04-03 09:10:21 +0200
commit2489f02be75dc364326aaa587099c0d6a428d406 (patch)
treef699e9548360d6eedd776eafd3f6f7dddce62575
parenta9ebdad06ae4238465698746a9fd3e27b87d2033 (diff)
downloadvdr-plugin-rpihddevice-2489f02be75dc364326aaa587099c0d6a428d406.tar.gz
vdr-plugin-rpihddevice-2489f02be75dc364326aaa587099c0d6a428d406.tar.bz2
completed OMX locking for audio path
-rw-r--r--ilclient/ilclient.c10
-rw-r--r--omx.c34
2 files changed, 24 insertions, 20 deletions
diff --git a/ilclient/ilclient.c b/ilclient/ilclient.c
index 66d70a8..49f758b 100644
--- a/ilclient/ilclient.c
+++ b/ilclient/ilclient.c
@@ -321,8 +321,8 @@ int ilclient_create_component(ILCLIENT_T *client, COMPONENT_T **comp, char *name
(*comp)->flags = flags;
callbacks.EventHandler = ilclient_event_handler;
- callbacks.EmptyBufferDone = flags & ILCLIENT_ENABLE_INPUT_BUFFERS ? ilclient_empty_buffer_done : ilclient_empty_buffer_done_error;
- callbacks.FillBufferDone = flags & ILCLIENT_ENABLE_OUTPUT_BUFFERS ? ilclient_fill_buffer_done : ilclient_fill_buffer_done_error;
+ callbacks.EmptyBufferDone = (flags & ILCLIENT_ENABLE_INPUT_BUFFERS) ? ilclient_empty_buffer_done : ilclient_empty_buffer_done_error;
+ callbacks.FillBufferDone = (flags & ILCLIENT_ENABLE_OUTPUT_BUFFERS) ? ilclient_fill_buffer_done : ilclient_fill_buffer_done_error;
error = OMX_GetHandle(&(*comp)->comp, component_name, *comp, &callbacks);
@@ -1015,7 +1015,6 @@ int ilclient_setup_tunnel(TUNNEL_T *tunnel, unsigned int portStream, int timeout
OMX_ERRORTYPE error;
OMX_PARAM_U32TYPE param;
OMX_STATETYPE state;
- int32_t status;
int enable_error;
// source component must at least be idle, not loaded
@@ -1027,7 +1026,7 @@ int ilclient_setup_tunnel(TUNNEL_T *tunnel, unsigned int portStream, int timeout
// wait for the port parameter changed from the source port
if(timeout)
{
- status = ilclient_wait_for_event(tunnel->source, OMX_EventPortSettingsChanged,
+ int32_t status = ilclient_wait_for_event(tunnel->source, OMX_EventPortSettingsChanged,
tunnel->source_port, 0, -1, 1,
ILCLIENT_PARAMETER_CHANGED | ILCLIENT_EVENT_ERROR, timeout);
@@ -1112,7 +1111,6 @@ int ilclient_wait_for_event(COMPONENT_T *comp, OMX_EVENTTYPE event,
OMX_U32 nData1, int ignore1, OMX_IN OMX_U32 nData2, int ignore2,
int event_flag, int suspend)
{
- int32_t status;
uint32_t set;
while (ilclient_remove_event(comp, event, nData1, ignore1, nData2, ignore2) < 0)
@@ -1152,7 +1150,7 @@ int ilclient_wait_for_event(COMPONENT_T *comp, OMX_EVENTTYPE event,
return ilclient_remove_event(comp, event, nData1, ignore1, nData2, ignore2) == 0 ? 0 : -3;
}
- status = vcos_event_flags_get(&comp->event, event_flag, VCOS_OR_CONSUME,
+ int32_t status = vcos_event_flags_get(&comp->event, event_flag, VCOS_OR_CONSUME,
suspend, &set);
if (status != 0)
return -1;
diff --git a/omx.c b/omx.c
index 03478ac..af39d1e 100644
--- a/omx.c
+++ b/omx.c
@@ -846,6 +846,8 @@ void cOmx::StopVideo(void)
void cOmx::StopAudio(void)
{
+ Lock();
+
// put audio render onto idle
ilclient_flush_tunnels(&m_tun[eClockToAudioRender], 1);
ilclient_disable_tunnel(&m_tun[eClockToAudioRender]);
@@ -854,6 +856,7 @@ void cOmx::StopAudio(void)
m_spareAudioBuffers, NULL, NULL);
m_spareAudioBuffers = 0;
+ Unlock();
}
void cOmx::SetVideoErrorConcealment(bool startWithValidFrame)
@@ -868,6 +871,8 @@ void cOmx::SetVideoErrorConcealment(bool startWithValidFrame)
void cOmx::FlushAudio(void)
{
+ Lock();
+
if (OMX_SendCommand(ILC_GET_HANDLE(m_comp[eAudioRender]), OMX_CommandFlush, 100, NULL) != OMX_ErrorNone)
ELOG("failed to flush audio render!");
@@ -876,6 +881,7 @@ void cOmx::FlushAudio(void)
VCOS_EVENT_FLAGS_SUSPEND);
ilclient_flush_tunnels(&m_tun[eClockToAudioRender], 1);
+ Unlock();
}
void cOmx::FlushVideo(bool flushRender)
@@ -1163,15 +1169,14 @@ 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);
@@ -1193,20 +1198,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);
@@ -1232,6 +1237,7 @@ OMX_BUFFERHEADERTYPE* cOmx::GetVideoBuffer(uint64_t pts)
else
m_freeVideoBuffers = false;
+ Unlock();
return buf;
}
@@ -1267,6 +1273,8 @@ bool cOmx::EmptyAudioBuffer(OMX_BUFFERHEADERTYPE *buf)
if (!buf)
return false;
+ Lock();
+ bool ret = true;
#ifdef DEBUG_BUFFERS
DumpBuffer(buf, "A");
#endif
@@ -1283,14 +1291,12 @@ bool cOmx::EmptyAudioBuffer(OMX_BUFFERHEADERTYPE *buf)
m_setVideoDiscontinuity = true;
buf->nFilledLen = 0;
-
- Lock();
buf->pAppPrivate = m_spareAudioBuffers;
m_spareAudioBuffers = buf;
- Unlock();
- return false;
+ ret = false;
}
- return true;
+ Unlock();
+ return ret;
}
bool cOmx::EmptyVideoBuffer(OMX_BUFFERHEADERTYPE *buf)
@@ -1298,6 +1304,8 @@ bool cOmx::EmptyVideoBuffer(OMX_BUFFERHEADERTYPE *buf)
if (!buf)
return false;
+ Lock();
+ bool ret = true;
#ifdef DEBUG_BUFFERS
DumpBuffer(buf, "V");
#endif
@@ -1311,12 +1319,10 @@ bool cOmx::EmptyVideoBuffer(OMX_BUFFERHEADERTYPE *buf)
m_setVideoStartTime = true;
buf->nFilledLen = 0;
-
- Lock();
buf->pAppPrivate = m_spareVideoBuffers;
m_spareVideoBuffers = buf;
- Unlock();
- return false;
+ ret = false;
}
- return true;
+ Unlock();
+ return ret;
}