From eab574a3b8362cceafc0417eab66b62edd2399e3 Mon Sep 17 00:00:00 2001 From: Michal Ratajsky Date: Thu, 20 Nov 2014 16:55:56 +0100 Subject: alsa: Emit "stream-added" after the stream element is added and the stream is gettable Fixes mate_mixer_context_get_stream() not working when the signal is received --- backends/alsa/alsa-device.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'backends/alsa') diff --git a/backends/alsa/alsa-device.c b/backends/alsa/alsa-device.c index 78d8bbc..f76478f 100644 --- a/backends/alsa/alsa-device.c +++ b/backends/alsa/alsa-device.c @@ -459,22 +459,13 @@ static void add_element (AlsaDevice *device, AlsaStream *stream, AlsaElement *element) { snd_mixer_elem_t *el; + gboolean add_stream = FALSE; if (alsa_element_load (element) == FALSE) return; - if (alsa_stream_has_controls_or_switches (stream) == FALSE) { - const gchar *name = - mate_mixer_stream_get_name (MATE_MIXER_STREAM (stream)); - - free_stream_list (device); - - /* Pretend the stream has just been created now that we are adding - * the first control */ - g_signal_emit_by_name (G_OBJECT (device), - "stream-added", - name); - } + if (alsa_stream_has_controls_or_switches (stream) == FALSE) + add_stream = TRUE; /* Add element to the stream depending on its type */ if (ALSA_IS_STREAM_CONTROL (element)) @@ -488,6 +479,19 @@ add_element (AlsaDevice *device, AlsaStream *stream, AlsaElement *element) return; } + if (add_stream == TRUE) { + const gchar *name = + mate_mixer_stream_get_name (MATE_MIXER_STREAM (stream)); + + free_stream_list (device); + + /* Pretend the stream has just been created now that we have added + * the first control */ + g_signal_emit_by_name (G_OBJECT (device), + "stream-added", + name); + } + el = alsa_element_get_snd_element (element); /* Register to receive callbacks for element changes */ -- cgit v1.2.1