From 44f5c4d6c55389e427916c86a963de20191ad86b Mon Sep 17 00:00:00 2001 From: Michal Ratajsky Date: Mon, 4 Jan 2016 20:48:42 +0100 Subject: Make sure each stream has a default control to match documented behaviour --- libmatemixer/matemixer-stream.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libmatemixer/matemixer-stream.c b/libmatemixer/matemixer-stream.c index b5db39a..9110e22 100644 --- a/libmatemixer/matemixer-stream.c +++ b/libmatemixer/matemixer-stream.c @@ -393,9 +393,19 @@ mate_mixer_stream_get_switch (MateMixerStream *stream, const gchar *name) MateMixerStreamControl * mate_mixer_stream_get_default_control (MateMixerStream *stream) { + const GList *list; + g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), NULL); - return stream->priv->control; + if (stream->priv->control != NULL) + return stream->priv->control; + + /* If the stream does not have a default control, just return the first one */ + list = mate_mixer_stream_list_controls (stream); + if (list != NULL) + return MATE_MIXER_STREAM_CONTROL (list->data); + + return NULL; } /** -- cgit v1.2.1