From: <rb...@fr...> - 2005-03-26 15:24:50
|
CVS Root: /cvs/gstreamer Module: gstreamer Changes by: rbultje Date: Sat Mar 26 2005 07:24:43 PST Branch: BRANCH-GSTREAMER-0_8 Log message: * gst/elements/gstfdsrc.c: (gst_fdsrc_class_init), (gst_fdsrc_change_state), (gst_fdsrc_release_locks), (gst_fdsrc_get): * gst/elements/gstfdsrc.h: Fix hang on state-change with blocking input (#149791). Modified files: . : ChangeLog gst/elements : gstfdsrc.c gstfdsrc.h Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/ChangeLog.diff?r1=1.966.2.33&r2=1.966.2.34 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/elements/gstfdsrc.c.diff?r1=1.41.4.2&r2=1.41.4.3 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/elements/gstfdsrc.h.diff?r1=1.13.4.1&r2=1.13.4.2 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gstreamer/ChangeLog,v retrieving revision 1.966.2.33 retrieving revision 1.966.2.34 diff -u -d -r1.966.2.33 -r1.966.2.34 --- ChangeLog 26 Mar 2005 00:13:33 -0000 1.966.2.33 +++ ChangeLog 26 Mar 2005 15:24:31 -0000 1.966.2.34 @@ -1,3 +1,11 @@ +2005-03-26 Ronald S. Bultje <rb...@ro...> + + * gst/elements/gstfdsrc.c: (gst_fdsrc_class_init), + (gst_fdsrc_change_state), (gst_fdsrc_release_locks), + (gst_fdsrc_get): + * gst/elements/gstfdsrc.h: + Fix hang on state-change with blocking input (#149791). 2005-03-25 David Schleef <ds...@sc...> * gst/gstcpu.c: (illegal_instruction_handler), Index: gstfdsrc.c RCS file: /cvs/gstreamer/gstreamer/gst/elements/gstfdsrc.c,v retrieving revision 1.41.4.2 retrieving revision 1.41.4.3 diff -u -d -r1.41.4.2 -r1.41.4.3 --- gstfdsrc.c 14 Mar 2005 19:14:05 -0000 1.41.4.2 +++ gstfdsrc.c 26 Mar 2005 15:24:31 -0000 1.41.4.3 @@ -101,6 +101,7 @@ GValue * value, GParamSpec * pspec); static GstElementStateReturn gst_fdsrc_change_state (GstElement * element); +static gboolean gst_fdsrc_release_locks (GstElement * element); static GstData *gst_fdsrc_get (GstPad * pad); @@ -142,6 +143,7 @@ gobject_class->dispose = gst_fdsrc_dispose; gstelement_class->change_state = gst_fdsrc_change_state; + gstelement_class->release_locks = gst_fdsrc_release_locks; } static void @@ -179,19 +181,16 @@ GstFdSrc *src = GST_FDSRC (element); switch (GST_STATE_TRANSITION (element)) { - case GST_STATE_NULL_TO_READY: - break; - case GST_STATE_READY_TO_NULL: case GST_STATE_READY_TO_PAUSED: src->curoffset = 0; break; - case GST_STATE_PAUSED_TO_READY: default: } + /* in any case, an interrupt succeeds if we get here */ + src->interrupted = FALSE; if (GST_ELEMENT_CLASS (parent_class)->change_state) return GST_ELEMENT_CLASS (parent_class)->change_state (element); @@ -255,6 +254,16 @@ +static gboolean +gst_fdsrc_release_locks (GstElement * element) +{ + GstFdSrc *src = GST_FDSRC (element); + src->interrupted = TRUE; + return TRUE; +} static GstData * gst_fdsrc_get (GstPad * pad) { @@ -264,7 +273,7 @@ #ifndef HAVE_WIN32 fd_set readfds; - struct timeval t, *tp = &t; + struct timeval t; gint retval; #endif @@ -277,16 +286,24 @@ FD_ZERO (&readfds); FD_SET (src->fd, &readfds); - if (src->timeout != 0) { - GST_TIME_TO_TIMEVAL (src->timeout, t); - } else - tp = NULL; - + /* loop until data is available, or a timeout is set. Re-enter + * loop if we got a timeout without a timeout set, or if we + * received an interrupt event. */ do { - retval = select (src->fd + 1, &readfds, NULL, NULL, tp); - } while (retval == -1 && errno == EINTR); /* retry if interrupted */ + if (src->timeout != 0) { + GST_TIME_TO_TIMEVAL (src->timeout, t); + } else { + GST_TIME_TO_TIMEVAL (1000000000, t); + } - if (retval == -1) { + retval = select (src->fd + 1, &readfds, NULL, NULL, &t); + } while (!src->interrupted && + ((retval == -1 && errno == EINTR) || (retval == 0 && src->timeout == 0))); + if (src->interrupted) { + GST_DEBUG_OBJECT (src, "received interrupt"); + return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT)); + } else if (retval == -1) { GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), ("select on file descriptor: %s.", g_strerror (errno))); gst_element_set_eos (GST_ELEMENT (src)); Index: gstfdsrc.h RCS file: /cvs/gstreamer/gstreamer/gst/elements/gstfdsrc.h,v retrieving revision 1.13.4.1 retrieving revision 1.13.4.2 diff -u -d -r1.13.4.1 -r1.13.4.2 --- gstfdsrc.h 14 Mar 2005 19:14:05 -0000 1.13.4.1 +++ gstfdsrc.h 26 Mar 2005 15:24:31 -0000 1.13.4.2 @@ -51,6 +51,7 @@ /* fd */ gint fd; + gboolean interrupted; gchar *uri; gulong curoffset; /* current offset in file */ |