summaryrefslogtreecommitdiff
path: root/backends/pulse/pulse-stream.c
diff options
context:
space:
mode:
authorMichal Ratajsky <[email protected]>2014-06-26 01:35:56 +0200
committerMichal Ratajsky <[email protected]>2014-06-26 01:35:56 +0200
commitf235385f34c81d4cd9092b94cb24670eb25421fa (patch)
tree489c2b9549302493da9b2d56b92aa4613722a90a /backends/pulse/pulse-stream.c
parent0362ccf20d51fa27d7febd0e6c0fa368f2f9e663 (diff)
downloadlibmatemixer-f235385f34c81d4cd9092b94cb24670eb25421fa.tar.bz2
libmatemixer-f235385f34c81d4cd9092b94cb24670eb25421fa.tar.xz
Minor fixes
Diffstat (limited to 'backends/pulse/pulse-stream.c')
-rw-r--r--backends/pulse/pulse-stream.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/backends/pulse/pulse-stream.c b/backends/pulse/pulse-stream.c
index 4daff23..32e7047 100644
--- a/backends/pulse/pulse-stream.c
+++ b/backends/pulse/pulse-stream.c
@@ -154,6 +154,8 @@ static gint64 stream_get_base_volume (MateMixerStream
static gboolean stream_set_cvolume (MateMixerStream *stream,
pa_cvolume *volume);
+static gint stream_compare_ports (gconstpointer a,
+ gconstpointer b);
static void
mate_mixer_stream_interface_init (MateMixerStreamInterface *iface)
@@ -272,7 +274,7 @@ pulse_stream_set_property (GObject *object,
stream->priv->index = g_value_get_uint (value);
break;
case PROP_CONNECTION:
- /* Construct-only object property */
+ /* Construct-only object */
stream->priv->connection = g_value_dup_object (value);
break;
default:
@@ -373,7 +375,7 @@ pulse_stream_finalize (GObject *object)
guint32
pulse_stream_get_index (PulseStream *stream)
{
- g_return_val_if_fail (PULSE_IS_STREAM (stream), FALSE);
+ g_return_val_if_fail (PULSE_IS_STREAM (stream), 0);
return stream->priv->index;
}
@@ -534,11 +536,15 @@ pulse_stream_update_ports (PulseStream *stream, GList *ports)
{
g_return_val_if_fail (PULSE_IS_STREAM (stream), FALSE);
- // XXX sort them
if (stream->priv->ports)
g_list_free_full (stream->priv->ports, g_object_unref);
- stream->priv->ports = ports;
+ if (ports)
+ stream->priv->ports = g_list_sort (ports, stream_compare_ports);
+ else
+ stream->priv->ports = NULL;
+
+ g_object_notify (G_OBJECT (stream), "ports");
return TRUE;
}
@@ -642,7 +648,7 @@ stream_set_mute (MateMixerStream *stream, gboolean mute)
static guint
stream_get_num_channels (MateMixerStream *stream)
{
- g_return_val_if_fail (PULSE_IS_STREAM (stream), FALSE);
+ g_return_val_if_fail (PULSE_IS_STREAM (stream), 0);
return PULSE_STREAM (stream)->priv->volume.channels;
}
@@ -650,7 +656,7 @@ stream_get_num_channels (MateMixerStream *stream)
static gint64
stream_get_volume (MateMixerStream *stream)
{
- g_return_val_if_fail (PULSE_IS_STREAM (stream), FALSE);
+ g_return_val_if_fail (PULSE_IS_STREAM (stream), 0);
return (gint64) pa_cvolume_max (&PULSE_STREAM (stream)->priv->volume);
}
@@ -1112,3 +1118,18 @@ stream_set_cvolume (MateMixerStream *stream, pa_cvolume *volume)
}
return TRUE;
}
+
+static gint
+stream_compare_ports (gconstpointer a, gconstpointer b)
+{
+ MateMixerPort *p1 = MATE_MIXER_PORT (a);
+ MateMixerPort *p2 = MATE_MIXER_PORT (b);
+
+ gint ret = (gint) (mate_mixer_port_get_priority (p2) -
+ mate_mixer_port_get_priority (p1));
+ if (ret != 0)
+ return ret;
+ else
+ return strcmp (mate_mixer_port_get_name (p1),
+ mate_mixer_port_get_name (p2));
+}