mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
audiobase{sink,src}: Don't hold the object lock while calling create_ringbuffer() vfunc
The implementation of that vfunc might want to use the object lock for something too. It's generally not a good idea to keep the object lock while calling any function implemented elsewhere. Also the ringbuffer can only be NULL at this point, remove a useless if block. And in the sink actually hold the object lock while setting the ringbuffer on the instance. Code accessing this is expected to use the object lock, so do it here ourselves too.
This commit is contained in:
parent
c1776a9dd3
commit
ceb9de6e55
2 changed files with 36 additions and 10 deletions
|
@ -2187,14 +2187,22 @@ gst_audio_base_sink_change_state (GstElement * element,
|
||||||
GstAudioBaseSink *sink = GST_AUDIO_BASE_SINK (element);
|
GstAudioBaseSink *sink = GST_AUDIO_BASE_SINK (element);
|
||||||
|
|
||||||
switch (transition) {
|
switch (transition) {
|
||||||
case GST_STATE_CHANGE_NULL_TO_READY:
|
case GST_STATE_CHANGE_NULL_TO_READY:{
|
||||||
if (sink->ringbuffer == NULL) {
|
GstAudioRingBuffer *rb;
|
||||||
|
|
||||||
gst_audio_clock_reset (GST_AUDIO_CLOCK (sink->provided_clock), 0);
|
gst_audio_clock_reset (GST_AUDIO_CLOCK (sink->provided_clock), 0);
|
||||||
sink->ringbuffer = gst_audio_base_sink_create_ringbuffer (sink);
|
rb = gst_audio_base_sink_create_ringbuffer (sink);
|
||||||
}
|
if (rb == NULL)
|
||||||
|
goto create_failed;
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (sink);
|
||||||
|
sink->ringbuffer = rb;
|
||||||
|
GST_OBJECT_UNLOCK (sink);
|
||||||
|
|
||||||
if (!gst_audio_ring_buffer_open_device (sink->ringbuffer))
|
if (!gst_audio_ring_buffer_open_device (sink->ringbuffer))
|
||||||
goto open_failed;
|
goto open_failed;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||||
gst_audio_base_sink_reset_sync (sink);
|
gst_audio_base_sink_reset_sync (sink);
|
||||||
gst_audio_ring_buffer_set_flushing (sink->ringbuffer, FALSE);
|
gst_audio_ring_buffer_set_flushing (sink->ringbuffer, FALSE);
|
||||||
|
@ -2289,6 +2297,12 @@ gst_audio_base_sink_change_state (GstElement * element,
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
|
create_failed:
|
||||||
|
{
|
||||||
|
/* subclass must post a meaningful error message */
|
||||||
|
GST_DEBUG_OBJECT (sink, "create failed");
|
||||||
|
return GST_STATE_CHANGE_FAILURE;
|
||||||
|
}
|
||||||
open_failed:
|
open_failed:
|
||||||
{
|
{
|
||||||
/* subclass must post a meaningful error message */
|
/* subclass must post a meaningful error message */
|
||||||
|
|
|
@ -1124,17 +1124,23 @@ gst_audio_base_src_change_state (GstElement * element,
|
||||||
GstAudioBaseSrc *src = GST_AUDIO_BASE_SRC (element);
|
GstAudioBaseSrc *src = GST_AUDIO_BASE_SRC (element);
|
||||||
|
|
||||||
switch (transition) {
|
switch (transition) {
|
||||||
case GST_STATE_CHANGE_NULL_TO_READY:
|
case GST_STATE_CHANGE_NULL_TO_READY:{
|
||||||
|
GstAudioRingBuffer *rb;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (src, "NULL->READY");
|
GST_DEBUG_OBJECT (src, "NULL->READY");
|
||||||
GST_OBJECT_LOCK (src);
|
|
||||||
if (src->ringbuffer == NULL) {
|
|
||||||
gst_audio_clock_reset (GST_AUDIO_CLOCK (src->clock), 0);
|
gst_audio_clock_reset (GST_AUDIO_CLOCK (src->clock), 0);
|
||||||
src->ringbuffer = gst_audio_base_src_create_ringbuffer (src);
|
rb = gst_audio_base_src_create_ringbuffer (src);
|
||||||
}
|
if (rb == NULL)
|
||||||
|
goto create_failed;
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (src);
|
||||||
|
src->ringbuffer = rb;
|
||||||
GST_OBJECT_UNLOCK (src);
|
GST_OBJECT_UNLOCK (src);
|
||||||
|
|
||||||
if (!gst_audio_ring_buffer_open_device (src->ringbuffer))
|
if (!gst_audio_ring_buffer_open_device (src->ringbuffer))
|
||||||
goto open_failed;
|
goto open_failed;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||||
GST_DEBUG_OBJECT (src, "READY->PAUSED");
|
GST_DEBUG_OBJECT (src, "READY->PAUSED");
|
||||||
src->next_sample = -1;
|
src->next_sample = -1;
|
||||||
|
@ -1197,6 +1203,12 @@ gst_audio_base_src_change_state (GstElement * element,
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
|
create_failed:
|
||||||
|
{
|
||||||
|
/* subclass must post a meaningful error message */
|
||||||
|
GST_DEBUG_OBJECT (src, "create failed");
|
||||||
|
return GST_STATE_CHANGE_FAILURE;
|
||||||
|
}
|
||||||
open_failed:
|
open_failed:
|
||||||
{
|
{
|
||||||
/* subclass must post a meaningful error message */
|
/* subclass must post a meaningful error message */
|
||||||
|
|
Loading…
Reference in a new issue