gst-libs/gst/audio/gstaudiosink.c: Signal thread startup earlier so that we can immediatly go into pull mode when we ...

Original commit message from CVS:
* 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.
This commit is contained in:
Wim Taymans 2008-10-16 15:44:37 +00:00
parent 7bd29abb9d
commit 927999603a
2 changed files with 35 additions and 1 deletions

View file

@ -1,3 +1,11 @@
2008-10-16 Wim Taymans <wim.taymans@collabora.co.uk>
* 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.taymans@collabora.co.uk>
* gst-libs/gst/audio/gstringbuffer.c:

View file

@ -209,6 +209,11 @@ audioringbuffer_thread_func (GstRingBuffer * buf)
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 @@ audioringbuffer_thread_func (GstRingBuffer * buf)
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 @@ gst_audioringbuffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
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 @@ gst_audioringbuffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
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 @@ could_not_prepare:
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 @@ gst_audioringbuffer_release (GstRingBuffer * buf)
abuf->running = FALSE;
GST_DEBUG_OBJECT (sink, "signal wait");
GST_AUDIORING_BUFFER_SIGNAL (buf);
GST_OBJECT_UNLOCK (buf);
/* join the thread */