[MOVED FROM GST-P-FARSIGHT] Add proper locking to mimdec

20080704220243-3e2dc-71c157d82999dfb41bd62b4064b1887ab22e84c1.gz
This commit is contained in:
Olivier Crete 2008-07-04 22:02:43 +00:00 committed by Olivier Crête
parent 7b80bac3ab
commit c57073ea3d
2 changed files with 12 additions and 0 deletions

View file

@ -164,6 +164,8 @@ gst_mimdec_chain (GstPad *pad, GstBuffer *in)
buf = GST_BUFFER (in); buf = GST_BUFFER (in);
gst_adapter_push (mimdec->adapter, buf); gst_adapter_push (mimdec->adapter, buf);
GST_OBJECT_LOCK (mimdec);
if (!GST_CLOCK_TIME_IS_VALID (mimdec->gst_timestamp)) if (!GST_CLOCK_TIME_IS_VALID (mimdec->gst_timestamp))
mimdec->gst_timestamp = GST_BUFFER_TIMESTAMP (in); mimdec->gst_timestamp = GST_BUFFER_TIMESTAMP (in);
@ -245,7 +247,9 @@ gst_mimdec_chain (GstPad *pad, GstBuffer *in)
event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME,
0, -1, 0); 0, -1, 0);
GST_OBJECT_UNLOCK (mimdec);
result = gst_pad_push_event (mimdec->srcpad, event); result = gst_pad_push_event (mimdec->srcpad, event);
GST_OBJECT_LOCK (mimdec);
if (!result) if (!result)
{ {
GST_WARNING_OBJECT (mimdec, "gst_pad_push_event failed"); GST_WARNING_OBJECT (mimdec, "gst_pad_push_event failed");
@ -298,13 +302,16 @@ gst_mimdec_chain (GstPad *pad, GstBuffer *in)
"height", G_TYPE_INT, height, NULL); "height", G_TYPE_INT, height, NULL);
gst_buffer_set_caps (out_buf, caps); gst_buffer_set_caps (out_buf, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
GST_OBJECT_UNLOCK (mimdec);
res = gst_pad_push (mimdec->srcpad, out_buf); res = gst_pad_push (mimdec->srcpad, out_buf);
GST_OBJECT_LOCK (mimdec);
gst_adapter_flush (mimdec->adapter, mimdec->payload_size); gst_adapter_flush (mimdec->adapter, mimdec->payload_size);
mimdec->have_header = FALSE; mimdec->have_header = FALSE;
} }
out: out:
GST_OBJECT_UNLOCK (mimdec);
gst_object_unref (mimdec); gst_object_unref (mimdec);
return res; return res;
@ -319,6 +326,7 @@ gst_mimdec_change_state (GstElement *element, GstStateChange transition)
case GST_STATE_CHANGE_READY_TO_NULL: case GST_STATE_CHANGE_READY_TO_NULL:
mimdec = GST_MIMDEC (element); mimdec = GST_MIMDEC (element);
if (mimdec->dec != NULL) { if (mimdec->dec != NULL) {
GST_OBJECT_LOCK (element);
mimic_close (mimdec->dec); mimic_close (mimdec->dec);
mimdec->dec = NULL; mimdec->dec = NULL;
mimdec->buffer_size = -1; mimdec->buffer_size = -1;
@ -327,6 +335,7 @@ gst_mimdec_change_state (GstElement *element, GstStateChange transition)
mimdec->gst_timestamp = GST_CLOCK_TIME_NONE; mimdec->gst_timestamp = GST_CLOCK_TIME_NONE;
mimdec->current_ts = -1; mimdec->current_ts = -1;
mimdec->last_ts = -1; mimdec->last_ts = -1;
GST_OBJECT_UNLOCK (element);
} }
break; break;
default: default:

View file

@ -48,8 +48,11 @@ struct _GstMimDec
GstElement element; GstElement element;
GstPad *sinkpad, *srcpad; GstPad *sinkpad, *srcpad;
/* Protected by stream lock */
GstAdapter *adapter; GstAdapter *adapter;
/* Protected by object lock */
MimCtx *dec; MimCtx *dec;
gint buffer_size; gint buffer_size;