pulsesink: check for a stream

Don't try to change the stream volume (and other things) when we don't have a
stream yet. Just store the values for later.
This commit is contained in:
Wim Taymans 2009-04-09 23:43:58 +02:00 committed by Wim Taymans
parent ae83945349
commit 7d438518fb

View file

@ -311,6 +311,8 @@ gst_pulsering_context_subscribe_cb (pa_context * c,
pbuf = GST_PULSERING_BUFFER_CAST (userdata);
psink = GST_PULSESINK_CAST (GST_OBJECT_PARENT (pbuf));
GST_LOG_OBJECT (psink, "type %d, idx %u", t, idx);
if (t != (PA_SUBSCRIPTION_EVENT_SINK_INPUT | PA_SUBSCRIPTION_EVENT_CHANGE) &&
t != (PA_SUBSCRIPTION_EVENT_SINK_INPUT | PA_SUBSCRIPTION_EVENT_NEW))
return;
@ -1411,11 +1413,13 @@ gst_pulsesink_set_volume (GstPulseSink * psink, gdouble volume)
pa_threaded_mainloop_lock (psink->mainloop);
GST_DEBUG_OBJECT (psink, "setting volume to %f", volume);
psink->volume = volume;
psink->volume_set = TRUE;
pbuf = GST_PULSERING_BUFFER_CAST (GST_BASE_AUDIO_SINK (psink)->ringbuffer);
if (pbuf == NULL)
if (pbuf == NULL || pbuf->stream == NULL)
goto unlock;
gst_pulse_cvolume_from_linear (&v, pbuf->sample_spec.channels, volume);
@ -1651,14 +1655,12 @@ gst_pulsesink_change_title (GstPulseSink * psink, const gchar * t)
pa_threaded_mainloop_lock (psink->mainloop);
pbuf = GST_PULSERING_BUFFER_CAST (GST_BASE_AUDIO_SINK (psink)->ringbuffer);
if (pbuf == NULL)
goto no_buffer;
g_free (pbuf->stream_name);
pbuf->stream_name = g_strdup (t);
if (gst_pulsering_is_dead (psink, pbuf))
goto server_dead;
if (pbuf == NULL || pbuf->stream == NULL)
goto no_buffer;
if (!(o = pa_stream_set_name (pbuf->stream, pbuf->stream_name, NULL, NULL)))
goto name_failed;
@ -1677,11 +1679,6 @@ no_buffer:
GST_DEBUG_OBJECT (psink, "we have no ringbuffer");
goto unlock;
}
server_dead:
{
GST_DEBUG_OBJECT (psink, "the server is dead");
goto unlock;
}
name_failed:
{
GST_ELEMENT_ERROR (psink, RESOURCE, FAILED,
@ -1729,12 +1726,9 @@ gst_pulsesink_change_props (GstPulseSink * psink, GstTagList * l)
pa_threaded_mainloop_lock (psink->mainloop);
pbuf = GST_PULSERING_BUFFER_CAST (GST_BASE_AUDIO_SINK (psink)->ringbuffer);
if (pbuf == NULL)
if (pbuf == NULL || pbuf->stream == NULL)
goto no_buffer;
if (gst_pulsering_is_dead (psink, pbuf))
goto server_dead;
if (!(o = pa_stream_proplist_update (pbuf->stream, PA_UPDATE_REPLACE,
pl, NULL, NULL)))
goto update_failed;
@ -1760,11 +1754,6 @@ no_buffer:
GST_DEBUG_OBJECT (psink, "we have no ringbuffer");
goto unlock;
}
server_dead:
{
GST_DEBUG_OBJECT (psink, "the server is dead");
goto unlock;
}
update_failed:
{
GST_ELEMENT_ERROR (psink, RESOURCE, FAILED,