mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
[MOVED FROM GST-P-FARSIGHT] Add another fix for a possible race condition
20070904225753-4f0f6-5ba8c4260c002bb27eb98e9faba3c15799357b57.gz
This commit is contained in:
parent
9c5331b747
commit
4eab02230d
4 changed files with 19 additions and 4 deletions
|
@ -334,6 +334,7 @@ gst_dtmf_src_init (GstDTMFSrc * dtmfsrc, gpointer g_class)
|
|||
dtmfsrc->last_event = NULL;
|
||||
|
||||
dtmfsrc->clock_id = NULL;
|
||||
dtmfsrc->task_paused = TRUE;
|
||||
|
||||
GST_DEBUG_OBJECT (dtmfsrc, "init done");
|
||||
}
|
||||
|
@ -536,7 +537,7 @@ gst_dtmf_src_start (GstDTMFSrc *dtmfsrc)
|
|||
GST_DEBUG_OBJECT (dtmfsrc,
|
||||
"caps %" GST_PTR_FORMAT " set on src pad", caps);
|
||||
|
||||
|
||||
dtmfsrc->task_paused = FALSE;
|
||||
if (!gst_pad_start_task (dtmfsrc->srcpad,
|
||||
(GstTaskFunction) gst_dtmf_src_push_next_tone_packet, dtmfsrc)) {
|
||||
GST_ERROR_OBJECT (dtmfsrc, "Failed to start task on src pad");
|
||||
|
@ -548,6 +549,7 @@ gst_dtmf_src_stop (GstDTMFSrc *dtmfsrc)
|
|||
{
|
||||
GstDTMFSrcEvent *event = NULL;
|
||||
|
||||
dtmfsrc->task_paused = TRUE;
|
||||
GST_OBJECT_LOCK (dtmfsrc);
|
||||
if (dtmfsrc->clock_id != NULL) {
|
||||
gst_clock_id_unschedule(dtmfsrc->clock_id);
|
||||
|
@ -684,7 +686,12 @@ gst_dtmf_src_wait_for_buffer_ts (GstDTMFSrc *dtmfsrc, GstBuffer * buf)
|
|||
GST_OBJECT_LOCK (dtmfsrc);
|
||||
dtmfsrc->clock_id = clock_id;
|
||||
GST_OBJECT_UNLOCK (dtmfsrc);
|
||||
clock_ret = gst_clock_id_wait (dtmfsrc->clock_id, NULL);
|
||||
|
||||
if (dtmfsrc->task_paused) {
|
||||
clock_ret = GST_CLOCK_UNSCHEDULED;
|
||||
} else {
|
||||
clock_ret = gst_clock_id_wait (dtmfsrc->clock_id, NULL);
|
||||
}
|
||||
|
||||
GST_OBJECT_LOCK (dtmfsrc);
|
||||
dtmfsrc->clock_id = NULL;
|
||||
|
|
|
@ -75,6 +75,7 @@ struct _GstDTMFSrc {
|
|||
GAsyncQueue* event_queue;
|
||||
GstDTMFSrcEvent* last_event;
|
||||
GstClockID clock_id;
|
||||
gboolean task_paused;
|
||||
|
||||
guint16 interval;
|
||||
GstClockTime timestamp;
|
||||
|
|
|
@ -338,7 +338,7 @@ gst_rtp_dtmf_src_init (GstRTPDTMFSrc * dtmfsrc, gpointer g_class)
|
|||
dtmfsrc->clock_rate = DEFAULT_CLOCK_RATE;
|
||||
dtmfsrc->interval = DEFAULT_PACKET_INTERVAL;
|
||||
dtmfsrc->packet_redundancy = DEFAULT_PACKET_REDUNDANCY;
|
||||
|
||||
dtmfsrc->task_paused = TRUE;
|
||||
|
||||
dtmfsrc->event_queue = g_async_queue_new ();
|
||||
dtmfsrc->last_event = NULL;
|
||||
|
@ -594,6 +594,7 @@ gst_rtp_dtmf_src_start (GstRTPDTMFSrc *dtmfsrc)
|
|||
{
|
||||
gst_rtp_dtmf_src_set_caps (dtmfsrc);
|
||||
|
||||
dtmfsrc->task_paused = FALSE;
|
||||
if (!gst_pad_start_task (dtmfsrc->srcpad,
|
||||
(GstTaskFunction) gst_rtp_dtmf_src_push_next_rtp_packet, dtmfsrc)) {
|
||||
GST_ERROR_OBJECT (dtmfsrc, "Failed to start task on src pad");
|
||||
|
@ -606,6 +607,7 @@ gst_rtp_dtmf_src_stop (GstRTPDTMFSrc *dtmfsrc)
|
|||
|
||||
GstRTPDTMFSrcEvent *event = NULL;
|
||||
|
||||
dtmfsrc->task_paused = TRUE;
|
||||
GST_OBJECT_LOCK (dtmfsrc);
|
||||
if (dtmfsrc->clock_id != NULL) {
|
||||
gst_clock_id_unschedule(dtmfsrc->clock_id);
|
||||
|
@ -690,7 +692,11 @@ gst_rtp_dtmf_src_wait_for_buffer_ts (GstRTPDTMFSrc *dtmfsrc, GstBuffer * buf)
|
|||
dtmfsrc->clock_id = clock_id;
|
||||
GST_OBJECT_UNLOCK (dtmfsrc);
|
||||
|
||||
clock_ret = gst_clock_id_wait (dtmfsrc->clock_id, NULL);
|
||||
if (dtmfsrc->task_paused) {
|
||||
clock_ret = GST_CLOCK_UNSCHEDULED;
|
||||
} else {
|
||||
clock_ret = gst_clock_id_wait (dtmfsrc->clock_id, NULL);
|
||||
}
|
||||
|
||||
GST_OBJECT_LOCK (dtmfsrc);
|
||||
dtmfsrc->clock_id = NULL;
|
||||
|
|
|
@ -89,6 +89,7 @@ struct _GstRTPDTMFSrc {
|
|||
GAsyncQueue* event_queue;
|
||||
GstRTPDTMFSrcEvent* last_event;
|
||||
GstClockID clock_id;
|
||||
gboolean task_paused;
|
||||
|
||||
GstClockTime timestamp;
|
||||
gboolean first_packet;
|
||||
|
|
Loading…
Reference in a new issue