ext/alsa/gstalsaclock.c: Sanity check, don't wait endlessly since the clock might...
authorRonald S. Bultje <rbultje@ronald.bitfreak.net>
Mon, 17 Jan 2005 12:45:27 +0000 (12:45 +0000)
committerRonald S. Bultje <rbultje@ronald.bitfreak.net>
Mon, 17 Jan 2005 12:45:27 +0000 (12:45 +0000)
Original commit message from CVS:
* ext/alsa/gstalsaclock.c: (gst_alsa_clock_wait):
Sanity check, don't wait endlessly since the clock might not
actually run at this point (which is a deadlock). Fixes #164069.

ChangeLog
ext/alsa/gstalsaclock.c

index d105008..cf54e5e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-01-17  Ronald S. Bultje  <rbultje@ronald.bitfreak.net>
+
+       * ext/alsa/gstalsaclock.c: (gst_alsa_clock_wait):
+         Sanity check, don't wait endlessly since the clock might not
+         actually run at this point (which is a deadlock). Fixes #164069.
+
 2005-01-16  Ronald S. Bultje  <rbultje@ronald.bitfreak.net>
 
        * gst/playback/gstplaybasebin.c: (probe_triggered):
index 6f50f84..beb502f 100644 (file)
@@ -166,9 +166,10 @@ gst_alsa_clock_get_resolution (GstClock * clock)
 static GstClockEntryStatus
 gst_alsa_clock_wait (GstClock * clock, GstClockEntry * entry)
 {
-  GstClockTime target, entry_time;
+  GstClockTime target, entry_time, glib_start, glib_cur;
   GstClockTimeDiff diff;
   GstAlsaClock *this = GST_ALSA_CLOCK (clock);
+  GTimeVal t;
 
   entry_time = gst_alsa_clock_get_internal_time (clock);
   diff = GST_CLOCK_ENTRY_TIME (entry) - gst_clock_get_time (clock);
@@ -192,10 +193,14 @@ gst_alsa_clock_wait (GstClock * clock, GstClockEntry * entry)
       GST_TIME_ARGS (target), GST_TIME_ARGS (GST_CLOCK_ENTRY_TIME (entry)),
       GST_TIME_ARGS (entry_time));
 
+  g_get_current_time (&t);
+  glib_cur = glib_start = GST_TIMEVAL_TO_TIME (t);
   while (gst_alsa_clock_get_internal_time (clock) < target &&
-      this->last_unlock < entry_time) {
+      this->last_unlock < entry_time && glib_start + diff * 1.5 > glib_cur) {
     g_usleep (gst_alsa_clock_get_resolution (clock) * G_USEC_PER_SEC /
         GST_SECOND);
+    g_get_current_time (&t);
+    glib_cur = GST_TIMEVAL_TO_TIME (t);
   }
 
   return entry->status;