summaryrefslogtreecommitdiff
path: root/backends/pulse
diff options
context:
space:
mode:
Diffstat (limited to 'backends/pulse')
-rw-r--r--backends/pulse/pulse-device.c2
-rw-r--r--backends/pulse/pulse-helpers.h1
-rw-r--r--backends/pulse/pulse-monitor.c10
-rw-r--r--backends/pulse/pulse-stream.c33
4 files changed, 31 insertions, 15 deletions
diff --git a/backends/pulse/pulse-device.c b/backends/pulse/pulse-device.c
index d15972e..4a6e438 100644
--- a/backends/pulse/pulse-device.c
+++ b/backends/pulse/pulse-device.c
@@ -208,7 +208,7 @@ pulse_device_set_property (GObject *object,
device->priv->index = g_value_get_uint (value);
break;
case PROP_CONNECTION:
- /* Construct-only object property */
+ /* Construct-only object */
device->priv->connection = g_value_dup_object (value);
break;
default:
diff --git a/backends/pulse/pulse-helpers.h b/backends/pulse/pulse-helpers.h
index 978fd38..efc8fc9 100644
--- a/backends/pulse/pulse-helpers.h
+++ b/backends/pulse/pulse-helpers.h
@@ -19,7 +19,6 @@
#define PULSE_HELPERS_H
#include <glib.h>
-#include <glib-object.h>
#include <libmatemixer/matemixer-enums.h>
diff --git a/backends/pulse/pulse-monitor.c b/backends/pulse/pulse-monitor.c
index 21613d0..4b83368 100644
--- a/backends/pulse/pulse-monitor.c
+++ b/backends/pulse/pulse-monitor.c
@@ -149,7 +149,7 @@ pulse_monitor_disable (PulseMonitor *monitor)
gboolean
pulse_monitor_is_enabled (PulseMonitor *monitor)
{
- g_return_if_fail (PULSE_IS_MONITOR (monitor));
+ g_return_val_if_fail (PULSE_IS_MONITOR (monitor), FALSE);
return monitor->priv->enabled;
}
@@ -171,7 +171,7 @@ pulse_monitor_update_index (PulseMonitor *monitor,
if (pulse_monitor_is_enabled (monitor)) {
pulse_monitor_disable (monitor);
- /* Unset the Pulse stream to let enable recreate it */
+ /* Unset the Pulse stream to let enabling recreate it */
g_clear_pointer (&monitor->priv->stream, pa_stream_unref);
pulse_monitor_enable (monitor);
@@ -247,13 +247,9 @@ static void
monitor_read_cb (pa_stream *stream, size_t length, void *userdata)
{
const void *data;
- int ret;
- ret = pa_stream_peek (stream, &data, &length);
- if (ret < 0) {
- g_debug ("Failed to read PulseAudio stream data: %s", pa_strerror (ret));
+ if (pa_stream_peek (stream, &data, &length) < 0)
return;
- }
if (data) {
gdouble v = ((const gfloat *) data)[length / sizeof (gfloat) - 1];
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));
+}