ext/: Take proper locks when handling events.

Original commit message from CVS:
* ext/theora/theoradec.c: (theora_dec_src_query),
(theora_dec_sink_event):
* ext/theora/theoraenc.c: (theora_enc_sink_event),
(theora_enc_change_state):
* ext/vorbis/vorbisenc.c: (gst_vorbisenc_init),
(gst_vorbisenc_sink_event), (gst_vorbisenc_change_state):
Take proper locks when handling events.
This commit is contained in:
Wim Taymans 2005-10-27 11:33:09 +00:00
parent 2de274ea2c
commit 323ba80ff3
3 changed files with 32 additions and 9 deletions

View file

@ -1,3 +1,13 @@
2005-10-27 Wim Taymans <wim@fluendo.com>
* ext/theora/theoradec.c: (theora_dec_src_query),
(theora_dec_sink_event):
* ext/theora/theoraenc.c: (theora_enc_sink_event),
(theora_enc_change_state):
* ext/vorbis/vorbisenc.c: (gst_vorbisenc_init),
(gst_vorbisenc_sink_event), (gst_vorbisenc_change_state):
Take proper locks when handling events.
2005-10-27 Wim Taymans <wim@fluendo.com>
* gst/adder/gstadder.c: (gst_adder_query), (gst_adder_collected),

View file

@ -419,20 +419,27 @@ theora_enc_sink_event (GstPad * pad, GstEvent * event)
{
GstTheoraEnc *enc;
ogg_packet op;
gboolean res;
enc = GST_THEORA_ENC (GST_PAD_PARENT (pad));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
GST_STREAM_LOCK (pad);
/* push last packet with eos flag */
while (theora_encode_packetout (&enc->state, 1, &op)) {
GstClockTime out_time =
theora_granule_time (&enc->state, op.granulepos) * GST_SECOND;
theora_push_packet (enc, &op, out_time, GST_SECOND / enc->fps);
}
res = gst_pad_push_event (enc->srcpad, event);
GST_STREAM_UNLOCK (pad);
break;
default:
return gst_pad_event_default (pad, event);
res = gst_pad_push_event (enc->srcpad, event);
}
return res;
}
static GstFlowReturn
@ -721,11 +728,9 @@ theora_enc_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
GST_STREAM_LOCK (enc->sinkpad);
theora_clear (&enc->state);
theora_comment_clear (&enc->comment);
theora_info_clear (&enc->info);
GST_STREAM_UNLOCK (enc->sinkpad);
break;
case GST_STATE_CHANGE_READY_TO_NULL:
break;

View file

@ -550,8 +550,6 @@ gst_vorbisenc_init (GstVorbisEnc * vorbisenc)
vorbisenc->quality_set = FALSE;
vorbisenc->last_message = NULL;
vorbisenc->setup = FALSE;
vorbisenc->header_sent = FALSE;
}
@ -883,14 +881,17 @@ gst_vorbisenc_sink_event (GstPad * pad, GstEvent * event)
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
GST_STREAM_LOCK (pad);
/* Tell the library we're at end of stream so that it can handle
* the last frame and mark end of stream in the output properly */
GST_DEBUG_OBJECT (vorbisenc, "EOS, clearing state and sending event on");
gst_vorbisenc_clear (vorbisenc);
res = gst_pad_event_default (pad, event);
res = gst_pad_push_event (vorbisenc->srcpad, event);
GST_STREAM_UNLOCK (pad);
break;
case GST_EVENT_TAG:
GST_STREAM_LOCK (pad);
if (vorbisenc->tags) {
GstTagList *list;
@ -900,10 +901,11 @@ gst_vorbisenc_sink_event (GstPad * pad, GstEvent * event)
} else {
g_assert_not_reached ();
}
res = gst_pad_event_default (pad, event);
res = gst_pad_push_event (vorbisenc->srcpad, event);
GST_STREAM_UNLOCK (pad);
break;
default:
res = gst_pad_event_default (pad, event);
res = gst_pad_push_event (vorbisenc->srcpad, event);
break;
}
return res;
@ -1141,7 +1143,11 @@ gst_vorbisenc_change_state (GstElement * element, GstStateChange transition)
vorbisenc->tags = gst_tag_list_new ();
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
vorbisenc->setup = FALSE;
vorbisenc->header_sent = FALSE;
break;
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
break;
default:
break;
}
@ -1152,7 +1158,9 @@ gst_vorbisenc_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
gst_vorbisenc_clear (vorbisenc);
vorbis_block_clear (&vorbisenc->vb);
vorbis_dsp_clear (&vorbisenc->vd);
vorbis_info_clear (&vorbisenc->vi);
break;
case GST_STATE_CHANGE_READY_TO_NULL:
gst_tag_list_free (vorbisenc->tags);