From: <wt...@ke...> - 2008-10-16 15:45:00
|
CVS Root: /cvs/gstreamer Module: gst-plugins-base Changes by: wtay Date: Thu Oct 16 2008 15:44:51 UTC Log message: * gst-libs/gst/audio/gstaudiosink.c: (audioringbuffer_thread_func), (gst_audioringbuffer_acquire), (gst_audioringbuffer_release), (gst_audioringbuffer_stop): Signal thread startup earlier so that we can immediatly go into pull mode when we have to and block on preroll. Modified files: . : ChangeLog gst-libs/gst/audio: gstaudiosink.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/ChangeLog.diff?r1=1.4164&r2=1.4165 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst-libs/gst/audio/gstaudiosink.c.diff?r1=1.30&r2=1.31 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-base/ChangeLog,v retrieving revision 1.4164 retrieving revision 1.4165 diff -u -d -r1.4164 -r1.4165 --- ChangeLog 16 Oct 2008 15:38:49 -0000 1.4164 +++ ChangeLog 16 Oct 2008 15:44:35 -0000 1.4165 @@ -1,5 +1,13 @@ 2008-10-16 Wim Taymans <wim...@co...> + * gst-libs/gst/audio/gstaudiosink.c: (audioringbuffer_thread_func), + (gst_audioringbuffer_acquire), (gst_audioringbuffer_release), + (gst_audioringbuffer_stop): + Signal thread startup earlier so that we can immediatly go into pull + mode when we have to and block on preroll. + +2008-10-16 Wim Taymans <wim...@co...> * gst-libs/gst/audio/gstringbuffer.c: (gst_ring_buffer_prepare_read): In pull mode we want the callback to prepull a buffer we can preroll on Index: gstaudiosink.c RCS file: /cvs/gstreamer/gst-plugins-base/gst-libs/gst/audio/gstaudiosink.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- gstaudiosink.c 26 Aug 2008 17:24:31 -0000 1.30 +++ gstaudiosink.c 16 Oct 2008 15:44:37 -0000 1.31 @@ -209,6 +209,11 @@ GST_DEBUG_OBJECT (sink, "enter thread"); + GST_OBJECT_LOCK (abuf); + GST_DEBUG_OBJECT (sink, "signal wait"); + GST_AUDIORING_BUFFER_SIGNAL (buf); + GST_OBJECT_UNLOCK (abuf); writefunc = csink->write; if (writefunc == NULL) goto no_function; @@ -218,6 +223,7 @@ guint8 *readptr; gint readseg; + /* buffer must be started */ if (gst_ring_buffer_prepare_read (buf, &readseg, &readptr, &len)) { gint written = 0; @@ -356,6 +362,7 @@ GstAudioSinkClass *csink; GstAudioRingBuffer *abuf; gboolean result = FALSE; + GError *error = NULL; sink = GST_AUDIO_SINK (GST_OBJECT_PARENT (buf)); csink = GST_AUDIO_SINK_GET_CLASS (sink); @@ -375,10 +382,17 @@ abuf = GST_AUDIORING_BUFFER_CAST (buf); abuf->running = TRUE; + GST_DEBUG_OBJECT (sink, "starting thread"); sink->thread = g_thread_create ((GThreadFunc) audioringbuffer_thread_func, buf, TRUE, - NULL); + &error); + if (!sink->thread || error != NULL) + goto thread_failed; + GST_DEBUG_OBJECT (sink, "waiting for thread"); + /* the object lock is taken */ GST_AUDIORING_BUFFER_WAIT (buf); + GST_DEBUG_OBJECT (sink, "thread is started"); return result; @@ -387,6 +401,17 @@ GST_DEBUG_OBJECT (sink, "could not prepare device"); return FALSE; } +thread_failed: + { + if (error) + GST_ERROR_OBJECT (sink, "could not create thread %s", error->message); + else + GST_ERROR_OBJECT (sink, "could not create thread for unknown reason"); + /* still unprepare */ + if (csink->unprepare) + result = csink->unprepare (sink); + return FALSE; + } } /* function is called with LOCK */ @@ -405,6 +430,7 @@ abuf->running = FALSE; GST_DEBUG_OBJECT (sink, "signal wait"); GST_AUDIORING_BUFFER_SIGNAL (buf); GST_OBJECT_UNLOCK (buf); /* join the thread */ |