[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r31696 - Extractor/src/plugins
From: |
gnunet |
Subject: |
[GNUnet-SVN] r31696 - Extractor/src/plugins |
Date: |
Sun, 22 Dec 2013 21:53:26 +0100 |
Author: LRN
Date: 2013-12-22 21:53:25 +0100 (Sun, 22 Dec 2013)
New Revision: 31696
Modified:
Extractor/src/plugins/gstreamer_extractor.c
Log:
Change gstreamer plugin timeout logic
Modified: Extractor/src/plugins/gstreamer_extractor.c
===================================================================
--- Extractor/src/plugins/gstreamer_extractor.c 2013-12-22 20:53:23 UTC (rev
31695)
+++ Extractor/src/plugins/gstreamer_extractor.c 2013-12-22 20:53:25 UTC (rev
31696)
@@ -35,19 +35,12 @@
#define GST_CAT_DEFAULT gstreamer_extractor
/**
- * How often should we check for data timeout.
- * In milliseconds.
- */
-#define DATA_TIMEOUT_FREQUENCY 750 /* 750ms, hang up for 1.5s at most */
-
-/**
* Once discoverer has gone for that long without asking for data or
* asking to seek, or giving us discovered info, assume it hanged up
* and kill it.
- * In microseconds.
- * Keep this value a bit less than DATA_TIMEOUT_FREQUENCY
+ * In milliseconds.
*/
-#define DATA_TIMEOUT 1350000LL /* 1.35s */
+#define DATA_TIMEOUT 750 /* 750ms */
pthread_mutex_t pipe_mutex;
@@ -804,13 +797,6 @@
struct PrivStruct
{
/**
- * Tracks the time from the last IO request so that we can decide
- * to terminate processing if GStreamer just takes far too long.
- * Values are based on 'g_get_monotonic_time()', in milliseconds.
- */
- gint64 last_data_request_time;
-
- /**
* Current read-offset in the 'ec' context (based on our read/seek calls).
*/
guint64 offset;
@@ -857,7 +843,7 @@
size_t toc_pos;
/**
- *
+ * Identifier of the timeout event source
*/
guint timeout_id;
@@ -909,6 +895,16 @@
static GQuark duration_quark;
+static gboolean
+_data_timeout (struct PrivStruct *ps)
+{
+ GST_ERROR ("GstDiscoverer I/O timed out");
+ ps->timeout_id = 0;
+ g_main_loop_quit (ps->loop);
+ return FALSE;
+}
+
+
/**
* Implementation of GstElement's "need-data" callback. Reads data from
* the extraction context and passes it to GStreamer.
@@ -931,8 +927,9 @@
GST_DEBUG ("Request %u bytes", size);
- /* Update it now, in case we bail out due to error */
- ps->last_data_request_time = g_get_monotonic_time ();
+ if (ps->timeout_id > 0)
+ g_source_remove (ps->timeout_id);
+ ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout,
ps);
if ( (ps->length > 0) && (ps->offset >= ps->length) )
{
@@ -988,8 +985,9 @@
ps->offset = UINT64_MAX; /* set to invalid value */
}
- /* Update it again to account for time we spent fulfilling the request */
- ps->last_data_request_time = g_get_monotonic_time ();
+ if (ps->timeout_id > 0)
+ g_source_remove (ps->timeout_id);
+ ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout,
ps);
}
@@ -1011,7 +1009,9 @@
pthread_mutex_lock (&pipe_mutex);
ps->offset = ps->ec->seek (ps->ec->cls, position, SEEK_SET);
pthread_mutex_unlock (&pipe_mutex);
- ps->last_data_request_time = g_get_monotonic_time ();
+ if (ps->timeout_id > 0)
+ g_source_remove (ps->timeout_id);
+ ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout,
ps);
return ps->offset == position;
}
@@ -1935,7 +1935,9 @@
struct PrivStruct *ps)
{
send_discovered_info (info, ps);
- ps->last_data_request_time = g_get_monotonic_time ();
+ if (ps->timeout_id > 0)
+ g_source_remove (ps->timeout_id);
+ ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout,
ps);
}
@@ -1949,22 +1951,6 @@
}
-static gboolean
-_data_timeout (struct PrivStruct *ps)
-{
- gint64 now = g_get_monotonic_time ();
- if (now - ps->last_data_request_time > DATA_TIMEOUT)
- {
- GST_ERROR ("GstDiscoverer I/O timed out (last heard from discoverer on
%lld, now is %lld, difference is %lld > %lld",
- ps->last_data_request_time, now, now - ps->last_data_request_time,
DATA_TIMEOUT);
- ps->timeout_id = 0;
- g_main_loop_quit (ps->loop);
- return FALSE;
- }
- return TRUE;
-}
-
-
/**
* This callback is called when discoverer has constructed a source object to
* read from. Since we provided the appsrc:// uri to discoverer, this will be
@@ -2000,8 +1986,7 @@
* data */
g_signal_connect (ps->source, "need-data", G_CALLBACK (feed_data), ps);
g_signal_connect (ps->source, "seek-data", G_CALLBACK (seek_data), ps);
- ps->timeout_id = g_timeout_add (DATA_TIMEOUT_FREQUENCY, (GSourceFunc)
_data_timeout, ps);
- ps->last_data_request_time = g_get_monotonic_time ();
+ ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout,
ps);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r31696 - Extractor/src/plugins,
gnunet <=