mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
pulse: Make sure the stream is uncorked in the write function
If the caps changes, the sink is reset without transitioning through a PAUSED->PLAYING state change, resulting in a corked stream. This avoids the problem by checking that the stream is uncorked when writing samples to it.
This commit is contained in:
parent
335891c757
commit
120e6bfc5c
1 changed files with 23 additions and 4 deletions
|
@ -872,6 +872,7 @@ static guint
|
||||||
gst_pulsesink_write (GstAudioSink * asink, gpointer data, guint length)
|
gst_pulsesink_write (GstAudioSink * asink, gpointer data, guint length)
|
||||||
{
|
{
|
||||||
GstPulseSink *pulsesink = GST_PULSESINK (asink);
|
GstPulseSink *pulsesink = GST_PULSESINK (asink);
|
||||||
|
pa_operation *o = NULL;
|
||||||
size_t sum = 0;
|
size_t sum = 0;
|
||||||
|
|
||||||
/* FIXME post message rather than using a signal (as mixer interface) */
|
/* FIXME post message rather than using a signal (as mixer interface) */
|
||||||
|
@ -882,6 +883,25 @@ gst_pulsesink_write (GstAudioSink * asink, gpointer data, guint length)
|
||||||
|
|
||||||
pulsesink->in_write = TRUE;
|
pulsesink->in_write = TRUE;
|
||||||
|
|
||||||
|
/* Make sure the stream is uncorked - it might not be on a caps change */
|
||||||
|
if (pa_stream_is_corked (pulsesink->stream)) {
|
||||||
|
if (!(o = pa_stream_cork (pulsesink->stream, FALSE, NULL, NULL))) {
|
||||||
|
GST_ELEMENT_ERROR (pulsesink, RESOURCE, FAILED,
|
||||||
|
("pa_stream_cork() failed: %s",
|
||||||
|
pa_strerror (pa_context_errno (pulsesink->context))), (NULL));
|
||||||
|
goto unlock_and_fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (pa_operation_get_state (o) == PA_OPERATION_RUNNING) {
|
||||||
|
if (gst_pulsesink_is_dead (pulsesink))
|
||||||
|
goto unlock_and_fail;
|
||||||
|
pa_threaded_mainloop_wait (pulsesink->mainloop);
|
||||||
|
}
|
||||||
|
|
||||||
|
pa_operation_unref (o);
|
||||||
|
o = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
while (length > 0) {
|
while (length > 0) {
|
||||||
size_t l;
|
size_t l;
|
||||||
|
|
||||||
|
@ -933,6 +953,9 @@ unlock_and_fail:
|
||||||
pulsesink->did_reset = FALSE;
|
pulsesink->did_reset = FALSE;
|
||||||
pulsesink->in_write = FALSE;
|
pulsesink->in_write = FALSE;
|
||||||
|
|
||||||
|
if (o)
|
||||||
|
pa_operation_unref (o);
|
||||||
|
|
||||||
pa_threaded_mainloop_unlock (pulsesink->mainloop);
|
pa_threaded_mainloop_unlock (pulsesink->mainloop);
|
||||||
return (guint) - 1;
|
return (guint) - 1;
|
||||||
}
|
}
|
||||||
|
@ -1194,7 +1217,6 @@ gst_pulsesink_pause (GstPulseSink * pulsesink, gboolean b)
|
||||||
goto unlock;
|
goto unlock;
|
||||||
|
|
||||||
if (!(o = pa_stream_cork (pulsesink->stream, b, NULL, NULL))) {
|
if (!(o = pa_stream_cork (pulsesink->stream, b, NULL, NULL))) {
|
||||||
|
|
||||||
GST_ELEMENT_ERROR (pulsesink, RESOURCE, FAILED,
|
GST_ELEMENT_ERROR (pulsesink, RESOURCE, FAILED,
|
||||||
("pa_stream_cork() failed: %s",
|
("pa_stream_cork() failed: %s",
|
||||||
pa_strerror (pa_context_errno (pulsesink->context))), (NULL));
|
pa_strerror (pa_context_errno (pulsesink->context))), (NULL));
|
||||||
|
@ -1202,15 +1224,12 @@ gst_pulsesink_pause (GstPulseSink * pulsesink, gboolean b)
|
||||||
}
|
}
|
||||||
|
|
||||||
while (pa_operation_get_state (o) == PA_OPERATION_RUNNING) {
|
while (pa_operation_get_state (o) == PA_OPERATION_RUNNING) {
|
||||||
|
|
||||||
if (gst_pulsesink_is_dead (pulsesink))
|
if (gst_pulsesink_is_dead (pulsesink))
|
||||||
goto unlock;
|
goto unlock;
|
||||||
|
|
||||||
pa_threaded_mainloop_wait (pulsesink->mainloop);
|
pa_threaded_mainloop_wait (pulsesink->mainloop);
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock:
|
unlock:
|
||||||
|
|
||||||
if (o)
|
if (o)
|
||||||
pa_operation_unref (o);
|
pa_operation_unref (o);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue