summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/null/null-backend.c42
-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
-rw-r--r--examples/monitor.c10
-rw-r--r--libmatemixer/matemixer-backend-module.c2
7 files changed, 77 insertions, 23 deletions
diff --git a/backends/null/null-backend.c b/backends/null/null-backend.c
index 46c5fbf..05d06a8 100644
--- a/backends/null/null-backend.c
+++ b/backends/null/null-backend.c
@@ -15,8 +15,6 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-// XXX implement properties from MateMixerBackend
-
#include <glib.h>
#include <glib-object.h>
@@ -29,10 +27,22 @@
#define BACKEND_NAME "Null"
#define BACKEND_PRIORITY 0
+enum {
+ PROP_0,
+ PROP_STATE,
+ PROP_DEFAULT_INPUT,
+ PROP_DEFAULT_OUTPUT,
+ N_PROPERTIES
+};
+
static void mate_mixer_backend_interface_init (MateMixerBackendInterface *iface);
static void null_backend_class_init (NullBackendClass *klass);
static void null_backend_class_finalize (NullBackendClass *klass);
+static void null_backend_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec);
static void null_backend_init (NullBackend *null);
G_DEFINE_DYNAMIC_TYPE_EXTENDED (NullBackend, null_backend,
@@ -72,6 +82,14 @@ mate_mixer_backend_interface_init (MateMixerBackendInterface *iface)
static void
null_backend_class_init (NullBackendClass *klass)
{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->get_property = null_backend_get_property;
+
+ g_object_class_override_property (object_class, PROP_STATE, "state");
+ g_object_class_override_property (object_class, PROP_DEFAULT_INPUT, "default-input");
+ g_object_class_override_property (object_class, PROP_DEFAULT_OUTPUT, "default-output");
}
/* Called in the code generated by G_DEFINE_DYNAMIC_TYPE_EXTENDED() */
@@ -81,6 +99,26 @@ null_backend_class_finalize (NullBackendClass *klass)
}
static void
+null_backend_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (param_id) {
+ case PROP_STATE:
+ g_value_set_enum (value, MATE_MIXER_STATE_READY);
+ break;
+ case PROP_DEFAULT_INPUT:
+ case PROP_DEFAULT_OUTPUT:
+ g_value_set_object (value, NULL);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
null_backend_init (NullBackend *null)
{
}
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));
+}
diff --git a/examples/monitor.c b/examples/monitor.c
index a196b6a..7a3240b 100644
--- a/examples/monitor.c
+++ b/examples/monitor.c
@@ -269,10 +269,6 @@ int main (int argc, char *argv[])
{ NULL }
};
- /* Initialize the library, if the function returns FALSE, it is not usable */
- if (!mate_mixer_init ())
- return 1;
-
context = g_option_context_new ("- libmatemixer monitor");
g_option_context_add_main_entries (context, entries, NULL);
@@ -283,6 +279,10 @@ int main (int argc, char *argv[])
return 1;
}
+ /* Initialize the library, if the function returns FALSE, it is not usable */
+ if (!mate_mixer_init ())
+ return 1;
+
setlocale (LC_ALL, "");
/* Set up the controller, through which we access the main functionality */
@@ -300,7 +300,7 @@ int main (int argc, char *argv[])
else if (!strcmp (backend, "null"))
mate_mixer_control_set_backend_type (control, MATE_MIXER_BACKEND_NULL);
else
- g_printerr ("Sound system backend '%s' is unknown, it will be auto-detected.",
+ g_printerr ("Sound system backend '%s' is unknown, it will be auto-detected.\n",
backend);
g_free (backend);
diff --git a/libmatemixer/matemixer-backend-module.c b/libmatemixer/matemixer-backend-module.c
index 5825c13..e0707c1 100644
--- a/libmatemixer/matemixer-backend-module.c
+++ b/libmatemixer/matemixer-backend-module.c
@@ -121,7 +121,7 @@ mate_mixer_backend_module_set_property (GObject *object,
switch (param_id) {
case PROP_PATH:
- /* Construct-only string property */
+ /* Construct-only string */
module->priv->path = g_strdup (g_value_get_string (value));
break;
default: