[MOVED FROM GST-P-FARSIGHT] Fixes the deadlock when pausing the dtmfsrc and rtpdtmfsr...
authorYouness Alaoui <youness.alaoui@collabora.co.uk>
Fri, 31 Aug 2007 23:44:13 +0000 (23:44 +0000)
committerEdward Hervey <bilboed@bilboed.com>
Sat, 21 Feb 2009 16:48:01 +0000 (17:48 +0100)
20070831234413-4f0f6-793cf35fc43636e7275258cc7063fc068f5efa0a.gz

gst/dtmf/gstdtmfsrc.c
gst/dtmf/gstdtmfsrc.h
gst/dtmf/gstrtpdtmfsrc.c
gst/dtmf/gstrtpdtmfsrc.h

index 1dd123f..0c13775 100644 (file)
@@ -554,6 +554,16 @@ gst_dtmf_src_stop (GstDTMFSrc *dtmfsrc)
     dtmfsrc->clock_id = NULL;
   }
 
+
+
+  g_async_queue_lock (dtmfsrc->event_queue);
+  event = g_malloc (sizeof(GstRTPDTMFSrcEvent));
+  event->event_type = RTP_DTMF_EVENT_TYPE_PAUSE_TASK;
+  g_async_queue_push_unlocked (dtmfsrc->event_queue, event);
+  g_async_queue_unlock (dtmfsrc->event_queue);
+
+  event = NULL;
+
   if (!gst_pad_pause_task (dtmfsrc->srcpad)) {
     GST_ERROR_OBJECT (dtmfsrc, "Failed to pause task on src pad");
     return;
@@ -768,6 +778,10 @@ gst_dtmf_src_push_next_tone_packet (GstDTMFSrc *dtmfsrc)
 
       event->packet_count = 0;
       dtmfsrc->last_event = event;
+    } else if (event->event_type == RTP_DTMF_EVENT_TYPE_PAUSE_TASK) {
+      g_free (event);
+      g_async_queue_unref (dtmfsrc->event_queue);
+      return;
     }
   } else if (dtmfsrc->last_event->packet_count  * dtmfsrc->interval >=
       MIN_DUTY_CYCLE) {
index 5a94270..15a1675 100644 (file)
@@ -52,7 +52,8 @@ typedef struct _GstDTMFSrcClass GstDTMFSrcClass;
 
 enum _GstDTMFEventType {
   DTMF_EVENT_TYPE_START,
-  DTMF_EVENT_TYPE_STOP
+  DTMF_EVENT_TYPE_STOP,
+  DTMF_EVENT_TYPE_PAUSE_TASK
 };
 
 typedef enum _GstDTMFEventType GstDTMFEventType;
index c2a6d1f..ff3f05b 100644 (file)
@@ -612,11 +612,20 @@ gst_rtp_dtmf_src_stop (GstRTPDTMFSrc *dtmfsrc)
     dtmfsrc->clock_id = NULL;
   }
 
+  g_async_queue_lock (dtmfsrc->event_queue);
+  event = g_malloc (sizeof(GstRTPDTMFSrcEvent));
+  event->event_type = RTP_DTMF_EVENT_TYPE_PAUSE_TASK;
+  g_async_queue_push_unlocked (dtmfsrc->event_queue, event);
+  g_async_queue_unlock (dtmfsrc->event_queue);
+
+  event = NULL;
+
   if (!gst_pad_pause_task (dtmfsrc->srcpad)) {
     GST_ERROR_OBJECT (dtmfsrc, "Failed to pause task on src pad");
     return;
   }
 
+
   if (dtmfsrc->last_event) {
     /* Don't forget to release the stream lock */
     gst_rtp_dtmf_src_set_stream_lock (dtmfsrc, FALSE);
@@ -632,10 +641,6 @@ gst_rtp_dtmf_src_stop (GstRTPDTMFSrc *dtmfsrc)
     event = g_async_queue_try_pop (dtmfsrc->event_queue);
   }
 
-  if (dtmfsrc->last_event) {
-    g_free (dtmfsrc->last_event);
-    dtmfsrc->last_event = NULL;
-  }
 
 }
 
@@ -813,6 +818,10 @@ gst_rtp_dtmf_src_push_next_rtp_packet (GstRTPDTMFSrc *dtmfsrc)
       event->sent_packets = 0;
 
       dtmfsrc->last_event = event;
+    } else if (event->event_type == RTP_DTMF_EVENT_TYPE_PAUSE_TASK) {
+      g_free (event);
+      g_async_queue_unref (dtmfsrc->event_queue);
+      return;
     }
   } else if (dtmfsrc->last_event->sent_packets * dtmfsrc->interval >=
       MIN_PULSE_DURATION){
index c5e2b11..66225ba 100644 (file)
@@ -61,7 +61,8 @@ typedef struct _GstRTPDTMFSrcClass GstRTPDTMFSrcClass;
 
 enum _GstRTPDTMFEventType {
   RTP_DTMF_EVENT_TYPE_START,
-  RTP_DTMF_EVENT_TYPE_STOP
+  RTP_DTMF_EVENT_TYPE_STOP,
+  RTP_DTMF_EVENT_TYPE_PAUSE_TASK
 };
 
 typedef enum _GstRTPDTMFEventType GstRTPDTMFEventType;