summaryrefslogtreecommitdiff
path: root/libmatemixer
diff options
context:
space:
mode:
authorMichal Ratajsky <[email protected]>2014-08-18 20:49:17 +0200
committerMichal Ratajsky <[email protected]>2014-08-18 20:49:17 +0200
commit5f20ab328add9442082277a57c23273a3a2125ed (patch)
treefb458ba63f25db35de6b5a9c9acf0f967020107f /libmatemixer
parent94d24482d8b1013947c0e2dac7330180b6ae02f6 (diff)
downloadlibmatemixer-5f20ab328add9442082277a57c23273a3a2125ed.tar.bz2
libmatemixer-5f20ab328add9442082277a57c23273a3a2125ed.tar.xz
Global update
Diffstat (limited to 'libmatemixer')
-rw-r--r--libmatemixer/Makefile.am14
-rw-r--r--libmatemixer/matemixer-app-info-private.h51
-rw-r--r--libmatemixer/matemixer-app-info.c142
-rw-r--r--libmatemixer/matemixer-app-info.h (renamed from libmatemixer/matemixer-backend-private.h)24
-rw-r--r--libmatemixer/matemixer-backend-module.c1
-rw-r--r--libmatemixer/matemixer-backend-module.h2
-rw-r--r--libmatemixer/matemixer-backend.c359
-rw-r--r--libmatemixer/matemixer-backend.h113
-rw-r--r--libmatemixer/matemixer-client-stream.c373
-rw-r--r--libmatemixer/matemixer-client-stream.h91
-rw-r--r--libmatemixer/matemixer-context.c216
-rw-r--r--libmatemixer/matemixer-context.h112
-rw-r--r--libmatemixer/matemixer-device-profile-private.h44
-rw-r--r--libmatemixer/matemixer-device-profile.c370
-rw-r--r--libmatemixer/matemixer-device-profile.h67
-rw-r--r--libmatemixer/matemixer-device.c182
-rw-r--r--libmatemixer/matemixer-device.h76
-rw-r--r--libmatemixer/matemixer-enum-types.c127
-rw-r--r--libmatemixer/matemixer-enum-types.h24
-rw-r--r--libmatemixer/matemixer-enums.h145
-rw-r--r--libmatemixer/matemixer-private.h13
-rw-r--r--libmatemixer/matemixer-stored-control.c52
-rw-r--r--libmatemixer/matemixer-stored-control.h59
-rw-r--r--libmatemixer/matemixer-stream-control-private.h4
-rw-r--r--libmatemixer/matemixer-stream-control.c436
-rw-r--r--libmatemixer/matemixer-stream-control.h193
-rw-r--r--libmatemixer/matemixer-stream-private.h32
-rw-r--r--libmatemixer/matemixer-stream.c311
-rw-r--r--libmatemixer/matemixer-stream.h55
-rw-r--r--libmatemixer/matemixer-switch-option-private.h2
-rw-r--r--libmatemixer/matemixer-switch-option.c2
-rw-r--r--libmatemixer/matemixer-switch-option.h12
-rw-r--r--libmatemixer/matemixer-switch-private.h1
-rw-r--r--libmatemixer/matemixer-switch.c144
-rw-r--r--libmatemixer/matemixer-switch.h22
-rw-r--r--libmatemixer/matemixer-toggle.c40
-rw-r--r--libmatemixer/matemixer-toggle.h23
-rw-r--r--libmatemixer/matemixer-types.h3
-rw-r--r--libmatemixer/matemixer.c5
-rw-r--r--libmatemixer/matemixer.h7
40 files changed, 1906 insertions, 2043 deletions
diff --git a/libmatemixer/Makefile.am b/libmatemixer/Makefile.am
index 8858b90..d7075cb 100644
--- a/libmatemixer/Makefile.am
+++ b/libmatemixer/Makefile.am
@@ -10,11 +10,12 @@ libmatemixer_includedir = $(includedir)/libmatemixer
libmatemixer_include_HEADERS = \
matemixer.h \
- matemixer-client-stream.h \
+ matemixer-app-info.h \
matemixer-context.h \
matemixer-device.h \
- matemixer-device-profile.h \
matemixer-enums.h \
+ matemixer-enum-types.h \
+ matemixer-stored-control.h \
matemixer-stream.h \
matemixer-stream-control.h \
matemixer-switch.h \
@@ -28,19 +29,18 @@ libmatemixer_la_CFLAGS = $(GLIB_CFLAGS)
libmatemixer_la_SOURCES = \
matemixer.c \
matemixer-private.h \
+ matemixer-app-info.c \
+ matemixer-app-info-private.h \
matemixer-backend.c \
matemixer-backend.h \
- matemixer-backend-private.h \
matemixer-backend-module.c \
matemixer-backend-module.h \
- matemixer-client-stream.c \
matemixer-context.c \
matemixer-device.c \
- matemixer-device-profile.c \
- matemixer-device-profile-private.h \
matemixer-enum-types.c \
- matemixer-enum-types.h \
+ matemixer-stored-control.c \
matemixer-stream.c \
+ matemixer-stream-private.h \
matemixer-stream-control.c \
matemixer-stream-control-private.h \
matemixer-switch.c \
diff --git a/libmatemixer/matemixer-app-info-private.h b/libmatemixer/matemixer-app-info-private.h
new file mode 100644
index 0000000..486b163
--- /dev/null
+++ b/libmatemixer/matemixer-app-info-private.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MATEMIXER_APP_INFO_PRIVATE_H
+#define MATEMIXER_APP_INFO_PRIVATE_H
+
+#include <glib.h>
+
+#include "matemixer-types.h"
+
+G_BEGIN_DECLS
+
+struct _MateMixerAppInfo
+{
+ gchar *name;
+ gchar *id;
+ gchar *version;
+ gchar *icon;
+};
+
+MateMixerAppInfo *_mate_mixer_app_info_new (void);
+
+void _mate_mixer_app_info_set_name (MateMixerAppInfo *info,
+ const gchar *name);
+void _mate_mixer_app_info_set_id (MateMixerAppInfo *info,
+ const gchar *id);
+void _mate_mixer_app_info_set_version (MateMixerAppInfo *info,
+ const gchar *version);
+void _mate_mixer_app_info_set_icon (MateMixerAppInfo *info,
+ const gchar *icon);
+
+MateMixerAppInfo *_mate_mixer_app_info_copy (MateMixerAppInfo *info);
+void _mate_mixer_app_info_free (MateMixerAppInfo *info);
+
+G_END_DECLS
+
+#endif /* MATEMIXER_APP_INFO_PRIVATE_H */
diff --git a/libmatemixer/matemixer-app-info.c b/libmatemixer/matemixer-app-info.c
new file mode 100644
index 0000000..369f148
--- /dev/null
+++ b/libmatemixer/matemixer-app-info.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "matemixer-app-info.h"
+#include "matemixer-app-info-private.h"
+
+G_DEFINE_BOXED_TYPE (MateMixerAppInfo, mate_mixer_app_info,
+ _mate_mixer_app_info_copy,
+ _mate_mixer_app_info_free)
+
+/**
+ * mate_mixer_app_info_get_name:
+ * @device: a #MateMixerAppInfo
+ */
+const gchar *
+mate_mixer_app_info_get_name (MateMixerAppInfo *info)
+{
+ g_return_val_if_fail (info != NULL, NULL);
+
+ return info->name;
+}
+
+/**
+ * mate_mixer_app_info_get_id:
+ * @device: a #MateMixerAppInfo
+ */
+const gchar *
+mate_mixer_app_info_get_id (MateMixerAppInfo *info)
+{
+ g_return_val_if_fail (info != NULL, NULL);
+
+ return info->id;
+}
+
+/**
+ * mate_mixer_app_info_get_version:
+ * @device: a #MateMixerAppInfo
+ */
+const gchar *
+mate_mixer_app_info_get_version (MateMixerAppInfo *info)
+{
+ g_return_val_if_fail (info != NULL, NULL);
+
+ return info->version;
+}
+
+/**
+ * mate_mixer_app_info_get_icon:
+ * @device: a #MateMixerAppInfo
+ */
+const gchar *
+mate_mixer_app_info_get_icon (MateMixerAppInfo *info)
+{
+ g_return_val_if_fail (info != NULL, NULL);
+
+ return info->icon;
+}
+
+MateMixerAppInfo *
+_mate_mixer_app_info_new (void)
+{
+ return g_slice_new0 (MateMixerAppInfo);
+}
+
+void
+_mate_mixer_app_info_set_name (MateMixerAppInfo *info, const gchar *name)
+{
+ g_return_if_fail (info != NULL);
+
+ g_free (info->name);
+
+ info->name = g_strdup (name);
+}
+
+void
+_mate_mixer_app_info_set_id (MateMixerAppInfo *info, const gchar *id)
+{
+ g_return_if_fail (info != NULL);
+
+ g_free (info->id);
+
+ info->id = g_strdup (id);
+}
+
+void
+_mate_mixer_app_info_set_version (MateMixerAppInfo *info, const gchar *version)
+{
+ g_return_if_fail (info != NULL);
+
+ g_free (info->version);
+
+ info->version = g_strdup (version);
+}
+
+void
+_mate_mixer_app_info_set_icon (MateMixerAppInfo *info, const gchar *icon)
+{
+ g_return_if_fail (info != NULL);
+
+ g_free (info->icon);
+
+ info->icon = g_strdup (icon);
+}
+
+MateMixerAppInfo *
+_mate_mixer_app_info_copy (MateMixerAppInfo *info)
+{
+ MateMixerAppInfo *info2;
+
+ info2 = _mate_mixer_app_info_new ();
+ info2->name = g_strdup (info->name);
+ info2->id = g_strdup (info->id);
+ info2->version = g_strdup (info->version);
+ info2->icon = g_strdup (info->icon);
+
+ return info2;
+}
+
+void
+_mate_mixer_app_info_free (MateMixerAppInfo *info)
+{
+ g_free (info->name);
+ g_free (info->id);
+ g_free (info->version);
+ g_free (info->icon);
+
+ g_slice_free (MateMixerAppInfo, info);
+}
diff --git a/libmatemixer/matemixer-backend-private.h b/libmatemixer/matemixer-app-info.h
index b5de8ae..eedc1c7 100644
--- a/libmatemixer/matemixer-backend-private.h
+++ b/libmatemixer/matemixer-app-info.h
@@ -15,26 +15,26 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MATEMIXER_BACKEND_PRIVATE_H
-#define MATEMIXER_BACKEND_PRIVATE_H
+#ifndef MATEMIXER_APP_INFO_H
+#define MATEMIXER_APP_INFO_H
#include <glib.h>
+#include <glib-object.h>
-#include "matemixer-backend.h"
-#include "matemixer-enums.h"
-#include "matemixer-stream.h"
+#include "matemixer-types.h"
G_BEGIN_DECLS
-void _mate_mixer_backend_set_state (MateMixerBackend *backend,
- MateMixerState state);
+#define MATE_MIXER_TYPE_APP_INFO (mate_mixer_app_info_get_type ())
+#define MATE_MIXER_APP_INFO(o) ((MateMixerAppInfo *) o)
-void _mate_mixer_backend_set_default_input_stream (MateMixerBackend *backend,
- MateMixerStream *stream);
+GType mate_mixer_app_info_get_type (void) G_GNUC_CONST;
-void _mate_mixer_backend_set_default_output_stream (MateMixerBackend *backend,
- MateMixerStream *stream);
+const gchar *mate_mixer_app_info_get_name (MateMixerAppInfo *info);
+const gchar *mate_mixer_app_info_get_id (MateMixerAppInfo *info);
+const gchar *mate_mixer_app_info_get_version (MateMixerAppInfo *info);
+const gchar *mate_mixer_app_info_get_icon (MateMixerAppInfo *info);
G_END_DECLS
-#endif /* MATEMIXER_BACKEND_PRIVATE_H */
+#endif /* MATEMIXER_APP_INFO_H */
diff --git a/libmatemixer/matemixer-backend-module.c b/libmatemixer/matemixer-backend-module.c
index 0e7716e..bd71de0 100644
--- a/libmatemixer/matemixer-backend-module.c
+++ b/libmatemixer/matemixer-backend-module.c
@@ -19,7 +19,6 @@
#include <glib-object.h>
#include <gmodule.h>
-#include "matemixer-backend.h"
#include "matemixer-backend-module.h"
/* Initialize backend */
diff --git a/libmatemixer/matemixer-backend-module.h b/libmatemixer/matemixer-backend-module.h
index e1dfd8d..dc95633 100644
--- a/libmatemixer/matemixer-backend-module.h
+++ b/libmatemixer/matemixer-backend-module.h
@@ -21,7 +21,7 @@
#include <glib.h>
#include <glib-object.h>
-#include <libmatemixer/matemixer-enums.h>
+#include "matemixer-enums.h"
G_BEGIN_DECLS
diff --git a/libmatemixer/matemixer-backend.c b/libmatemixer/matemixer-backend.c
index fab0883..b8177e3 100644
--- a/libmatemixer/matemixer-backend.c
+++ b/libmatemixer/matemixer-backend.c
@@ -20,16 +20,16 @@
#include <glib-object.h>
#include "matemixer-backend.h"
-#include "matemixer-backend-private.h"
+#include "matemixer-device.h"
#include "matemixer-enums.h"
#include "matemixer-enum-types.h"
#include "matemixer-stream.h"
+#include "matemixer-stream-control.h"
+#include "matemixer-stored-control.h"
struct _MateMixerBackendPrivate
{
- GList *devices;
- GList *streams;
- GList *stored_streams;
+ GHashTable *devices;
MateMixerStream *default_input;
MateMixerStream *default_output;
MateMixerState state;
@@ -51,8 +51,8 @@ enum {
DEVICE_REMOVED,
STREAM_ADDED,
STREAM_REMOVED,
- STORED_STREAM_ADDED,
- STORED_STREAM_REMOVED,
+ STORED_CONTROL_ADDED,
+ STORED_CONTROL_REMOVED,
N_SIGNALS
};
@@ -72,22 +72,19 @@ static void mate_mixer_backend_set_property (GObject *object,
GParamSpec *pspec);
static void mate_mixer_backend_dispose (GObject *object);
+static void mate_mixer_backend_finalize (GObject *object);
G_DEFINE_ABSTRACT_TYPE (MateMixerBackend, mate_mixer_backend, G_TYPE_OBJECT)
-static void device_added (MateMixerBackend *backend, const gchar *name);
-static void device_removed (MateMixerBackend *backend, const gchar *name);
+static void device_added (MateMixerBackend *backend,
+ const gchar *name);
+static void device_removed (MateMixerBackend *backend,
+ const gchar *name);
-static void device_stream_added (MateMixerDevice *device,
- const gchar *name);
-static void device_stream_removed (MateMixerDevice *device,
- const gchar *name);
-
-static void free_devices (MateMixerBackend *backend);
-static void free_streams (MateMixerBackend *backend);
-static void free_stored_streams (MateMixerBackend *backend);
-static void stream_removed (MateMixerBackend *backend,
- const gchar *name);
+static void device_stream_added (MateMixerBackend *backend,
+ const gchar *name);
+static void device_stream_removed (MateMixerBackend *backend,
+ const gchar *name);
static void
mate_mixer_backend_class_init (MateMixerBackendClass *klass)
@@ -96,6 +93,7 @@ mate_mixer_backend_class_init (MateMixerBackendClass *klass)
object_class = G_OBJECT_CLASS (klass);
object_class->dispose = mate_mixer_backend_dispose;
+ object_class->finalize = mate_mixer_backend_finalize;
object_class->get_property = mate_mixer_backend_get_property;
object_class->set_property = mate_mixer_backend_set_property;
@@ -129,7 +127,7 @@ mate_mixer_backend_class_init (MateMixerBackendClass *klass)
signals[DEVICE_ADDED] =
g_signal_new ("device-added",
G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
+ G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (MateMixerBackendClass, device_added),
NULL,
NULL,
@@ -141,7 +139,7 @@ mate_mixer_backend_class_init (MateMixerBackendClass *klass)
signals[DEVICE_REMOVED] =
g_signal_new ("device-removed",
G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
+ G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (MateMixerBackendClass, device_removed),
NULL,
NULL,
@@ -153,7 +151,7 @@ mate_mixer_backend_class_init (MateMixerBackendClass *klass)
signals[STREAM_ADDED] =
g_signal_new ("stream-added",
G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
+ G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (MateMixerBackendClass, stream_added),
NULL,
NULL,
@@ -165,7 +163,7 @@ mate_mixer_backend_class_init (MateMixerBackendClass *klass)
signals[STREAM_REMOVED] =
g_signal_new ("stream-removed",
G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
+ G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (MateMixerBackendClass, stream_removed),
NULL,
NULL,
@@ -174,11 +172,11 @@ mate_mixer_backend_class_init (MateMixerBackendClass *klass)
1,
G_TYPE_STRING);
- signals[STORED_STREAM_ADDED] =
- g_signal_new ("stored-stream-added",
+ signals[STORED_CONTROL_ADDED] =
+ g_signal_new ("stored-control-added",
G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (MateMixerBackendClass, stored_stream_added),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (MateMixerBackendClass, stored_control_added),
NULL,
NULL,
g_cclosure_marshal_VOID__STRING,
@@ -186,11 +184,11 @@ mate_mixer_backend_class_init (MateMixerBackendClass *klass)
1,
G_TYPE_STRING);
- signals[STORED_STREAM_REMOVED] =
- g_signal_new ("stored-stream-removed",
+ signals[STORED_CONTROL_REMOVED] =
+ g_signal_new ("stored-control-removed",
G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (MateMixerBackendClass, stored_stream_removed),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (MateMixerBackendClass, stored_control_removed),
NULL,
NULL,
g_cclosure_marshal_VOID__STRING,
@@ -215,11 +213,9 @@ mate_mixer_backend_get_property (GObject *object,
case PROP_STATE:
g_value_set_enum (value, backend->priv->state);
break;
-
case PROP_DEFAULT_INPUT_STREAM:
g_value_set_object (value, backend->priv->default_input);
break;
-
case PROP_DEFAULT_OUTPUT_STREAM:
g_value_set_object (value, backend->priv->default_output);
break;
@@ -244,7 +240,6 @@ mate_mixer_backend_set_property (GObject *object,
case PROP_DEFAULT_INPUT_STREAM:
mate_mixer_backend_set_default_input_stream (backend, g_value_get_object (value));
break;
-
case PROP_DEFAULT_OUTPUT_STREAM:
mate_mixer_backend_set_default_output_stream (backend, g_value_get_object (value));
break;
@@ -262,10 +257,11 @@ mate_mixer_backend_init (MateMixerBackend *backend)
MATE_MIXER_TYPE_BACKEND,
MateMixerBackendPrivate);
- g_signal_connect (G_OBJECT (backend),
- "device-added",
- G_CALLBACK (free_devices),
- NULL);
+ backend->priv->devices = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ g_object_unref);
+
g_signal_connect (G_OBJECT (backend),
"device-added",
G_CALLBACK (device_added),
@@ -273,32 +269,8 @@ mate_mixer_backend_init (MateMixerBackend *backend)
g_signal_connect (G_OBJECT (backend),
"device-removed",
- G_CALLBACK (free_devices),
- NULL);
- g_signal_connect (G_OBJECT (backend),
- "device-removed",
G_CALLBACK (device_removed),
NULL);
-
- g_signal_connect (G_OBJECT (backend),
- "stream-added",
- G_CALLBACK (free_streams),
- NULL);
- g_signal_connect (G_OBJECT (backend),
- "stream-removed",
- G_CALLBACK (free_streams),
- NULL);
-
- g_signal_connect (G_OBJECT (backend),
- "stored-stream-added",
- G_CALLBACK (free_stored_streams),
- NULL);
- g_signal_connect (G_OBJECT (backend),
- "stored-stream-removed",
- G_CALLBACK (free_stored_streams),
- NULL);
-
- // XXX also free when changing state
}
static void
@@ -308,18 +280,28 @@ mate_mixer_backend_dispose (GObject *object)
backend = MATE_MIXER_BACKEND (object);
- free_devices (backend);
- free_streams (backend);
- free_stored_streams (backend);
-
g_clear_object (&backend->priv->default_input);
g_clear_object (&backend->priv->default_output);
+ g_hash_table_remove_all (backend->priv->devices);
+
G_OBJECT_CLASS (mate_mixer_backend_parent_class)->dispose (object);
}
+static void
+mate_mixer_backend_finalize (GObject *object)
+{
+ MateMixerBackend *backend;
+
+ backend = MATE_MIXER_BACKEND (object);
+
+ g_hash_table_unref (backend->priv->devices);
+
+ G_OBJECT_CLASS (mate_mixer_backend_parent_class)->finalize (object);
+}
+
void
-mate_mixer_backend_set_data (MateMixerBackend *backend, MateMixerBackendData *data)
+mate_mixer_backend_set_app_info (MateMixerBackend *backend, MateMixerAppInfo *info)
{
MateMixerBackendClass *klass;
@@ -327,8 +309,21 @@ mate_mixer_backend_set_data (MateMixerBackend *backend, MateMixerBackendData *da
klass = MATE_MIXER_BACKEND_GET_CLASS (backend);
- if (klass->set_data != NULL)
- klass->set_data (backend, data);
+ if (klass->set_app_info != NULL)
+ klass->set_app_info (backend, info);
+}
+
+void
+mate_mixer_backend_set_server_address (MateMixerBackend *backend, const gchar *address)
+{
+ MateMixerBackendClass *klass;
+
+ g_return_if_fail (MATE_MIXER_IS_BACKEND (backend));
+
+ klass = MATE_MIXER_BACKEND_GET_CLASS (backend);
+
+ if (klass->set_server_address != NULL)
+ klass->set_server_address (backend, address);
}
gboolean
@@ -369,72 +364,117 @@ mate_mixer_backend_get_flags (MateMixerBackend *backend)
return backend->priv->flags;
}
-const GList *
-mate_mixer_backend_list_devices (MateMixerBackend *backend)
+MateMixerDevice *
+mate_mixer_backend_get_device (MateMixerBackend *backend, const gchar *name)
{
+ const GList *list;
+
g_return_val_if_fail (MATE_MIXER_IS_BACKEND (backend), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
- if (backend->priv->devices == NULL) {
- MateMixerBackendClass *klass;
+ list = mate_mixer_backend_list_devices (backend);
+ while (list != NULL) {
+ MateMixerDevice *device = MATE_MIXER_DEVICE (list->data);
- klass = MATE_MIXER_BACKEND_GET_CLASS (backend);
+ if (strcmp (name, mate_mixer_device_get_name (device)) == 0)
+ return device;
- if (klass->list_devices != NULL)
- backend->priv->devices = klass->list_devices (backend);
+ list = list->next;
}
-
- return backend->priv->devices;
+ return NULL;
}
-const GList *
-mate_mixer_backend_list_streams (MateMixerBackend *backend)
+MateMixerStream *
+mate_mixer_backend_get_stream (MateMixerBackend *backend, const gchar *name)
{
+ const GList *list;
+
g_return_val_if_fail (MATE_MIXER_IS_BACKEND (backend), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
- if (backend->priv->streams == NULL) {
- MateMixerBackendClass *klass;
+ list = mate_mixer_backend_list_streams (backend);
+ while (list != NULL) {
+ MateMixerStream *stream = MATE_MIXER_STREAM (list->data);
- klass = MATE_MIXER_BACKEND_GET_CLASS (backend);
+ if (strcmp (name, mate_mixer_stream_get_name (stream)) == 0)
+ return stream;
- if (klass->list_streams != NULL)
- backend->priv->streams = klass->list_streams (backend);
+ list = list->next;
}
+ return NULL;
+}
+
+MateMixerStoredControl *
+mate_mixer_backend_get_stored_control (MateMixerBackend *backend, const gchar *name)
+{
+ const GList *list;
+
+ g_return_val_if_fail (MATE_MIXER_IS_BACKEND (backend), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+
+ list = mate_mixer_backend_list_stored_controls (backend);
+ while (list != NULL) {
+ MateMixerStreamControl *control = MATE_MIXER_STREAM_CONTROL (list->data);
- return backend->priv->streams;
+ if (strcmp (name, mate_mixer_stream_control_get_name (control)) == 0)
+ return MATE_MIXER_STORED_CONTROL (control);
+
+ list = list->next;
+ }
+ return NULL;
}
const GList *
-mate_mixer_backend_list_stored_streams (MateMixerBackend *backend)
+mate_mixer_backend_list_devices (MateMixerBackend *backend)
{
+ MateMixerBackendClass *klass;
+
g_return_val_if_fail (MATE_MIXER_IS_BACKEND (backend), NULL);
- if (backend->priv->stored_streams == NULL) {
- MateMixerBackendClass *klass;
+ klass = MATE_MIXER_BACKEND_GET_CLASS (backend);
- klass = MATE_MIXER_BACKEND_GET_CLASS (backend);
+ if G_LIKELY (klass->list_devices != NULL)
+ return klass->list_devices (backend);
- if (klass->list_stored_streams != NULL)
- backend->priv->stored_streams = klass->list_stored_streams (backend);
- }
+ return NULL;
+}
+
+const GList *
+mate_mixer_backend_list_streams (MateMixerBackend *backend)
+{
+ MateMixerBackendClass *klass;
+
+ g_return_val_if_fail (MATE_MIXER_IS_BACKEND (backend), NULL);
- return backend->priv->stored_streams;
+ klass = MATE_MIXER_BACKEND_GET_CLASS (backend);
+
+ if G_LIKELY (klass->list_streams != NULL)
+ return klass->list_streams (backend);
+
+ return NULL;
}
-MateMixerStream *
-mate_mixer_backend_get_default_input_stream (MateMixerBackend *backend)
+const GList *
+mate_mixer_backend_list_stored_controls (MateMixerBackend *backend)
{
- MateMixerStream *stream = NULL;
+ MateMixerBackendClass *klass;
g_return_val_if_fail (MATE_MIXER_IS_BACKEND (backend), NULL);
- g_object_get (G_OBJECT (backend),
- "default-input-stream", &stream,
- NULL);
+ klass = MATE_MIXER_BACKEND_GET_CLASS (backend);
- if (stream != NULL)
- g_object_unref (stream);
+ if (klass->list_stored_controls != NULL)
+ return klass->list_stored_controls (backend);
- return stream;
+ return NULL;
+}
+
+MateMixerStream *
+mate_mixer_backend_get_default_input_stream (MateMixerBackend *backend)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_BACKEND (backend), NULL);
+
+ return backend->priv->default_input;
}
gboolean
@@ -462,18 +502,9 @@ mate_mixer_backend_set_default_input_stream (MateMixerBackend *backend,
MateMixerStream *
mate_mixer_backend_get_default_output_stream (MateMixerBackend *backend)
{
- MateMixerStream *stream = NULL;
-
g_return_val_if_fail (MATE_MIXER_IS_BACKEND (backend), NULL);
- g_object_get (G_OBJECT (backend),
- "default-output-stream", &stream,
- NULL);
-
- if (stream != NULL)
- g_object_unref (stream);
-
- return stream;
+ return backend->priv->default_output;
}
gboolean
@@ -503,87 +534,97 @@ device_added (MateMixerBackend *backend, const gchar *name)
{
MateMixerDevice *device;
- // device = mate_mixer_backend_get_device (backend, name);
+ device = mate_mixer_backend_get_device (backend, name);
+ if G_UNLIKELY (device == NULL) {
+ g_warn_if_reached ();
+ return;
+ }
-/*
- g_signal_connect (G_OBJECT (device),
- "stream-added",
- G_CALLBACK (device_stream_added));
- */
+ /* Keep the device in a hash table as it won't be possible to retrieve
+ * it when the remove signal is received */
+ g_hash_table_insert (backend->priv->devices,
+ g_strdup (name),
+ g_object_ref (device));
+
+ /* Connect to the stream signals from devices so we can forward them on
+ * the backend */
+ g_signal_connect_swapped (G_OBJECT (device),
+ "stream-added",
+ G_CALLBACK (device_stream_added),
+ backend);
+ g_signal_connect_swapped (G_OBJECT (device),
+ "stream-removed",
+ G_CALLBACK (device_stream_removed),
+ backend);
}
static void
device_removed (MateMixerBackend *backend, const gchar *name)
{
+ MateMixerDevice *device;
+
+ device = g_hash_table_lookup (backend->priv->devices, name);
+ if G_UNLIKELY (device == NULL) {
+ g_warn_if_reached ();
+ return;
+ }
+
+ g_signal_handlers_disconnect_by_func (G_OBJECT (device),
+ G_CALLBACK (device_stream_added),
+ backend);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (device),
+ G_CALLBACK (device_stream_removed),
+ backend);
+
+ g_hash_table_remove (backend->priv->devices, name);
}
static void
-device_stream_added (MateMixerDevice *device, const gchar *name)
+device_stream_added (MateMixerBackend *backend, const gchar *name)
{
- g_signal_emit (G_OBJECT (device),
+ g_signal_emit (G_OBJECT (backend),
signals[STREAM_ADDED],
0,
name);
}
static void
-device_stream_removed (MateMixerDevice *device, const gchar *name)
+device_stream_removed (MateMixerBackend *backend, const gchar *name)
{
- g_signal_emit (G_OBJECT (device),
+ g_signal_emit (G_OBJECT (backend),
signals[STREAM_REMOVED],
0,
name);
}
-static void
-free_devices (MateMixerBackend *backend)
-{
- if (backend->priv->devices == NULL)
- return;
-
- g_list_free_full (backend->priv->devices, g_object_unref);
-
- backend->priv->devices = NULL;
-}
-
-static void
-free_streams (MateMixerBackend *backend)
+/* Protected functions */
+void
+_mate_mixer_backend_set_state (MateMixerBackend *backend, MateMixerState state)
{
- if (backend->priv->streams == NULL)
- return;
-
- g_list_free_full (backend->priv->streams, g_object_unref);
-
- backend->priv->streams = NULL;
-}
+ g_return_if_fail (MATE_MIXER_IS_BACKEND (backend));
-static void
-free_stored_streams (MateMixerBackend *backend)
-{
- if (backend->priv->stored_streams == NULL)
+ if (backend->priv->state == state)
return;
- g_list_free_full (backend->priv->stored_streams, g_object_unref);
+ backend->priv->state = state;
- backend->priv->stored_streams = NULL;
+ g_object_notify_by_pspec (G_OBJECT (backend), properties[PROP_STATE]);
}
-/* Protected */
void
-_mate_mixer_backend_set_state (MateMixerBackend *backend, MateMixerState state)
+_mate_mixer_backend_set_flags (MateMixerBackend *backend, MateMixerBackendFlags flags)
{
- if (backend->priv->state == state)
- return;
-
- backend->priv->state = state;
+ g_return_if_fail (MATE_MIXER_IS_BACKEND (backend));
- g_object_notify_by_pspec (G_OBJECT (backend), properties[PROP_STATE]);
+ backend->priv->flags = flags;
}
void
_mate_mixer_backend_set_default_input_stream (MateMixerBackend *backend,
MateMixerStream *stream)
{
+ g_return_if_fail (MATE_MIXER_IS_BACKEND (backend));
+
if (backend->priv->default_input == stream)
return;
@@ -598,13 +639,16 @@ _mate_mixer_backend_set_default_input_stream (MateMixerBackend *backend,
g_debug ("Default input stream changed to %s",
(stream != NULL) ? mate_mixer_stream_get_name (stream) : "none");
- g_object_notify_by_pspec (G_OBJECT (backend), properties[PROP_DEFAULT_INPUT_STREAM]);
+ g_object_notify_by_pspec (G_OBJECT (backend),
+ properties[PROP_DEFAULT_INPUT_STREAM]);
}
void
_mate_mixer_backend_set_default_output_stream (MateMixerBackend *backend,
MateMixerStream *stream)
{
+ g_return_if_fail (MATE_MIXER_IS_BACKEND (backend));
+
if (backend->priv->default_output == stream)
return;
@@ -619,5 +663,6 @@ _mate_mixer_backend_set_default_output_stream (MateMixerBackend *backend,
g_debug ("Default output stream changed to %s",
(stream != NULL) ? mate_mixer_stream_get_name (stream) : "none");
- g_object_notify_by_pspec (G_OBJECT (backend), properties[PROP_DEFAULT_OUTPUT_STREAM]);
+ g_object_notify_by_pspec (G_OBJECT (backend),
+ properties[PROP_DEFAULT_OUTPUT_STREAM]);
}
diff --git a/libmatemixer/matemixer-backend.h b/libmatemixer/matemixer-backend.h
index 1c918c9..41ffb40 100644
--- a/libmatemixer/matemixer-backend.h
+++ b/libmatemixer/matemixer-backend.h
@@ -21,8 +21,8 @@
#include <glib.h>
#include <glib-object.h>
-#include <libmatemixer/matemixer-enums.h>
-#include <libmatemixer/matemixer-types.h>
+#include "matemixer-enums.h"
+#include "matemixer-types.h"
G_BEGIN_DECLS
@@ -41,7 +41,6 @@ G_BEGIN_DECLS
typedef struct _MateMixerBackend MateMixerBackend;
typedef struct _MateMixerBackendClass MateMixerBackendClass;
-typedef struct _MateMixerBackendData MateMixerBackendData;
typedef struct _MateMixerBackendPrivate MateMixerBackendPrivate;
struct _MateMixerBackend
@@ -57,67 +56,81 @@ struct _MateMixerBackendClass
GObjectClass parent_class;
/*< private >*/
- void (*set_data) (MateMixerBackend *backend,
- MateMixerBackendData *data);
+ void (*set_app_info) (MateMixerBackend *backend,
+ MateMixerAppInfo *info);
+ void (*set_server_address) (MateMixerBackend *backend,
+ const gchar *address);
- gboolean (*open) (MateMixerBackend *backend);
- void (*close) (MateMixerBackend *backend);
+ gboolean (*open) (MateMixerBackend *backend);
+ void (*close) (MateMixerBackend *backend);
- GList *(*list_devices) (MateMixerBackend *backend);
- GList *(*list_streams) (MateMixerBackend *backend);
- GList *(*list_stored_streams) (MateMixerBackend *backend);
+ const GList *(*list_devices) (MateMixerBackend *backend);
+ const GList *(*list_streams) (MateMixerBackend *backend);
+ const GList *(*list_stored_controls) (MateMixerBackend *backend);
- gboolean (*set_default_input_stream) (MateMixerBackend *backend,
- MateMixerStream *stream);
- gboolean (*set_default_output_stream) (MateMixerBackend *backend,
- MateMixerStream *stream);
+ gboolean (*set_default_input_stream) (MateMixerBackend *backend,
+ MateMixerStream *stream);
+ gboolean (*set_default_output_stream) (MateMixerBackend *backend,
+ MateMixerStream *stream);
/* Signals */
- void (*device_added) (MateMixerBackend *backend,
- const gchar *name);
- void (*device_removed) (MateMixerBackend *backend,
- const gchar *name);
- void (*stream_added) (MateMixerBackend *backend,
- const gchar *name);
- void (*stream_removed) (MateMixerBackend *backend,
- const gchar *name);
- void (*stored_stream_added) (MateMixerBackend *backend,
- const gchar *name);
- void (*stored_stream_removed) (MateMixerBackend *backend,
- const gchar *name);
+ void (*device_added) (MateMixerBackend *backend,
+ const gchar *name);
+ void (*device_removed) (MateMixerBackend *backend,
+ const gchar *name);
+ void (*stream_added) (MateMixerBackend *backend,
+ const gchar *name);
+ void (*stream_removed) (MateMixerBackend *backend,
+ const gchar *name);
+ void (*stored_control_added) (MateMixerBackend *backend,
+ const gchar *name);
+ void (*stored_control_removed) (MateMixerBackend *backend,
+ const gchar *name);
};
-struct _MateMixerBackendData
-{
- gchar *app_name;
- gchar *app_id;
- gchar *app_version;
- gchar *app_icon;
- gchar *server_address;
-};
+GType mate_mixer_backend_get_type (void) G_GNUC_CONST;
+
+void mate_mixer_backend_set_app_info (MateMixerBackend *backend,
+ MateMixerAppInfo *info);
+void mate_mixer_backend_set_server_address (MateMixerBackend *backend,
+ const gchar *address);
+
+gboolean mate_mixer_backend_open (MateMixerBackend *backend);
+void mate_mixer_backend_close (MateMixerBackend *backend);
+
+MateMixerState mate_mixer_backend_get_state (MateMixerBackend *backend);
+MateMixerBackendFlags mate_mixer_backend_get_flags (MateMixerBackend *backend);
-GType mate_mixer_backend_get_type (void) G_GNUC_CONST;
+MateMixerDevice * mate_mixer_backend_get_device (MateMixerBackend *backend,
+ const gchar *name);
+MateMixerStream * mate_mixer_backend_get_stream (MateMixerBackend *backend,
+ const gchar *name);
+MateMixerStoredControl *mate_mixer_backend_get_stored_control (MateMixerBackend *backend,
+ const gchar *name);
-void mate_mixer_backend_set_data (MateMixerBackend *backend,
- MateMixerBackendData *data);
+const GList * mate_mixer_backend_list_devices (MateMixerBackend *backend);
+const GList * mate_mixer_backend_list_streams (MateMixerBackend *backend);
+const GList * mate_mixer_backend_list_stored_controls (MateMixerBackend *backend);
-gboolean mate_mixer_backend_open (MateMixerBackend *backend);
-void mate_mixer_backend_close (MateMixerBackend *backend);
+MateMixerStream * mate_mixer_backend_get_default_input_stream (MateMixerBackend *backend);
+gboolean mate_mixer_backend_set_default_input_stream (MateMixerBackend *backend,
+ MateMixerStream *stream);
-MateMixerState mate_mixer_backend_get_state (MateMixerBackend *backend);
-MateMixerBackendFlags mate_mixer_backend_get_flags (MateMixerBackend *backend);
+MateMixerStream * mate_mixer_backend_get_default_output_stream (MateMixerBackend *backend);
+gboolean mate_mixer_backend_set_default_output_stream (MateMixerBackend *backend,
+ MateMixerStream *stream);
-const GList * mate_mixer_backend_list_devices (MateMixerBackend *backend);
-const GList * mate_mixer_backend_list_streams (MateMixerBackend *backend);
-const GList * mate_mixer_backend_list_stored_streams (MateMixerBackend *backend);
+/* Protected functions */
+void _mate_mixer_backend_set_state (MateMixerBackend *backend,
+ MateMixerState state);
+void _mate_mixer_backend_set_flags (MateMixerBackend *backend,
+ MateMixerBackendFlags flags);
-MateMixerStream * mate_mixer_backend_get_default_input_stream (MateMixerBackend *backend);
-gboolean mate_mixer_backend_set_default_input_stream (MateMixerBackend *backend,
- MateMixerStream *stream);
+void _mate_mixer_backend_set_default_input_stream (MateMixerBackend *backend,
+ MateMixerStream *stream);
-MateMixerStream * mate_mixer_backend_get_default_output_stream (MateMixerBackend *backend);
-gboolean mate_mixer_backend_set_default_output_stream (MateMixerBackend *backend,
- MateMixerStream *stream);
+void _mate_mixer_backend_set_default_output_stream (MateMixerBackend *backend,
+ MateMixerStream *stream);
G_END_DECLS
diff --git a/libmatemixer/matemixer-client-stream.c b/libmatemixer/matemixer-client-stream.c
deleted file mode 100644
index fc34622..0000000
--- a/libmatemixer/matemixer-client-stream.c
+++ /dev/null
@@ -1,373 +0,0 @@
-/*
- * Copyright (C) 2014 Michal Ratajsky <[email protected]>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the licence, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include "matemixer-client-stream.h"
-#include "matemixer-enums.h"
-#include "matemixer-enum-types.h"
-#include "matemixer-stream.h"
-
-/**
- * SECTION:matemixer-client-stream
- * @short_description: Interface providing extra functionality for client streams
- * @see_also: #MateMixerStream
- * @include: libmatemixer/matemixer.h
- *
- * #MateMixerClientStream represents a special kind of stream, which belongs
- * to a parent input or output stream.
- *
- * A typical example of a client stream is a stream provided by an application.
- */
-
-struct _MateMixerClientStreamPrivate
-{
- gchar *app_name;
- gchar *app_id;
- gchar *app_version;
- gchar *app_icon;
- MateMixerStream *parent;
- MateMixerClientStreamFlags client_flags;
- MateMixerClientStreamRole client_role;
-};
-
-enum {
- PROP_0,
- PROP_CLIENT_FLAGS,
- PROP_CLIENT_ROLE,
- PROP_PARENT,
- PROP_APP_NAME,
- PROP_APP_ID,
- PROP_APP_VERSION,
- PROP_APP_ICON,
- N_PROPERTIES
-};
-
-static GParamSpec *properties[N_PROPERTIES] = { NULL, };
-
-static void mate_mixer_client_stream_class_init (MateMixerClientStreamClass *klass);
-
-static void mate_mixer_client_stream_init (MateMixerClientStream *client);
-
-static void mate_mixer_client_stream_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec);
-static void mate_mixer_client_stream_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec);
-
-static void mate_mixer_client_stream_dispose (GObject *object);
-static void mate_mixer_client_stream_finalize (GObject *object);
-
-G_DEFINE_ABSTRACT_TYPE (MateMixerClientStream, mate_mixer_client_stream, MATE_MIXER_TYPE_STREAM)
-
-static void
-mate_mixer_client_stream_class_init (MateMixerClientStreamClass *klass)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = mate_mixer_client_stream_dispose;
- object_class->finalize = mate_mixer_client_stream_finalize;
- object_class->get_property = mate_mixer_client_stream_get_property;
- object_class->set_property = mate_mixer_client_stream_set_property;
-
- properties[PROP_CLIENT_FLAGS] =
- g_param_spec_flags ("client-flags",
- "Client flags",
- "Capability flags of the client stream",
- MATE_MIXER_TYPE_CLIENT_STREAM_FLAGS,
- MATE_MIXER_CLIENT_STREAM_NO_FLAGS,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS);
-
- properties[PROP_CLIENT_ROLE] =
- g_param_spec_enum ("role",
- "Role",
- "Role of the client stream",
- MATE_MIXER_TYPE_CLIENT_STREAM_ROLE,
- MATE_MIXER_CLIENT_STREAM_ROLE_NONE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS);
-
- properties[PROP_PARENT] =
- g_param_spec_object ("parent",
- "Parent",
- "Parent stream of the client stream",
- MATE_MIXER_TYPE_STREAM,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS);
-
- properties[PROP_APP_NAME] =
- g_param_spec_string ("app-name",
- "App name",
- "Name of the client stream application",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS);
-
- properties[PROP_APP_ID] =
- g_param_spec_string ("app-id",
- "App ID",
- "Identifier of the client stream application",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS);
-
- properties[PROP_APP_VERSION] =
- g_param_spec_string ("app-version",
- "App version",
- "Version of the client stream application",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS);
-
- properties[PROP_APP_ICON] =
- g_param_spec_string ("app-icon",
- "App icon",
- "Icon name of the client stream application",
- NULL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties (object_class, N_PROPERTIES, properties);
-}
-
-static void
-mate_mixer_client_stream_init (MateMixerClientStream *client)
-{
- client->priv = G_TYPE_INSTANCE_GET_PRIVATE (client,
- MATE_MIXER_TYPE_CLIENT_STREAM,
- MateMixerClientStreamPrivate);
-}
-
-static void
-mate_mixer_client_stream_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec)
-{
-}
-
-static void
-mate_mixer_client_stream_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
-{
-}
-
-static void
-mate_mixer_client_stream_dispose (GObject *object)
-{
- MateMixerClientStream *client;
-
- client = MATE_MIXER_CLIENT_STREAM (object);
-
- g_clear_object (&client->priv->parent);
-
- G_OBJECT_CLASS (mate_mixer_client_stream_parent_class)->dispose (object);
-}
-
-static void
-mate_mixer_client_stream_finalize (GObject *object)
-{
- MateMixerClientStream *client;
-
- client = MATE_MIXER_CLIENT_STREAM (object);
-
- g_free (client->priv->app_name);
- g_free (client->priv->app_id);
- g_free (client->priv->app_version);
- g_free (client->priv->app_icon);
-
- G_OBJECT_CLASS (mate_mixer_client_stream_parent_class)->finalize (object);
-}
-
-/**
- * mate_mixer_client_stream_get_flags:
- * @client: a #MateMixerClientStream
- *
- */
-MateMixerClientStreamFlags
-mate_mixer_client_stream_get_flags (MateMixerClientStream *client)
-{
- g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), MATE_MIXER_CLIENT_STREAM_NO_FLAGS);
-
- return client->priv->client_flags;
-}
-
-/**
- * mate_mixer_client_stream_get_role:
- * @client: a #MateMixerClientStream
- *
- */
-MateMixerClientStreamRole
-mate_mixer_client_stream_get_role (MateMixerClientStream *client)
-{
- g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), MATE_MIXER_CLIENT_STREAM_ROLE_NONE);
-
- return client->priv->client_role;
-}
-
-/**
- * mate_mixer_client_stream_get_parent:
- * @client: a #MateMixerClientStream
- *
- * Gets the parent stream of the client stream.
- *
- * Returns: a #MateMixerStream or %NULL if the parent stream is not known.
- */
-MateMixerStream *
-mate_mixer_client_stream_get_parent (MateMixerClientStream *client)
-{
- g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), NULL);
-
- return client->priv->parent;
-}
-
-/**
- * mate_mixer_client_stream_set_parent:
- * @client: a #MateMixerClientStream
- * @parent: a #MateMixerStream
- *
- * Changes the parent stream of the client stream. The parent stream must be a
- * non-client input or output stream.
- *
- * Returns: %TRUE on success or %FALSE on failure.
- */
-gboolean
-mate_mixer_client_stream_set_parent (MateMixerClientStream *client, MateMixerStream *parent)
-{
- g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), FALSE);
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (parent), FALSE);
-
- if (client->priv->parent != parent) {
- MateMixerClientStreamClass *klass;
-
- klass = MATE_MIXER_CLIENT_STREAM_GET_CLASS (client);
-
- if (klass->set_parent == NULL ||
- klass->set_parent (client, parent) == FALSE)
- return FALSE;
-
- if (client->priv->parent != NULL)
- g_object_unref (client->priv->parent);
-
- client->priv->parent = g_object_ref (parent);
- }
-
- return TRUE;
-}
-
-/**
- * mate_mixer_client_stream_remove:
- * @client: a #MateMixerClientStream
- *
- * Removes the client stream.
- *
- * Returns: %TRUE on success or %FALSE on failure.
- */
-gboolean
-mate_mixer_client_stream_remove (MateMixerClientStream *client)
-{
- MateMixerClientStreamClass *klass;
-
- g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), FALSE);
-
- klass = MATE_MIXER_CLIENT_STREAM_GET_CLASS (client);
-
- if (klass->remove != NULL)
- return klass->remove (client);
-
- return FALSE;
-}
-
-/**
- * mate_mixer_client_stream_get_app_name:
- * @client: a #MateMixerClientStream
- *
- * Gets the name of the application in case the stream is an application
- * stream.
- *
- * Returns: a string on success, or %NULL if the stream is not an application
- * stream or if the application does not provide a name.
- */
-const gchar *
-mate_mixer_client_stream_get_app_name (MateMixerClientStream *client)
-{
- g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), NULL);
-
- return client->priv->app_name;
-}
-
-/**
- * mate_mixer_client_stream_get_app_id:
- * @client: a #MateMixerClientStream
- *
- * Gets the identifier (e.g. org.example.app) of the application in case the
- * stream is an application stream.
- *
- * Returns: a string on success, or %NULL if the stream is not an application
- * stream or if the application does not provide an identifier.
- */
-const gchar *
-mate_mixer_client_stream_get_app_id (MateMixerClientStream *client)
-{
- g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), NULL);
-
- return client->priv->app_id;
-}
-
-/**
- * mate_mixer_client_stream_get_app_version:
- * @client: a #MateMixerClientStream
- *
- * Gets the version of the application in case the stream is an application
- * stream.
- *
- * Returns: a string on success, or %NULL if the stream is not an application
- * stream or if the application does not provide a version string.
- */
-const gchar *
-mate_mixer_client_stream_get_app_version (MateMixerClientStream *client)
-{
- g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), NULL);
-
- return client->priv->app_version;
-}
-
-/**
- * mate_mixer_client_stream_get_app_icon:
- * @client: a #MateMixerClientStream
- *
- * Gets the XDG icon name of the application in case the stream is an
- * application stream.
- *
- * Returns: a string on success, or %NULL if the stream is not an application
- * stream or if the application does not provide an icon name.
- */
-const gchar *
-mate_mixer_client_stream_get_app_icon (MateMixerClientStream *client)
-{
- g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), NULL);
-
- return client->priv->app_icon;
-}
diff --git a/libmatemixer/matemixer-client-stream.h b/libmatemixer/matemixer-client-stream.h
deleted file mode 100644
index 43ab3f0..0000000
--- a/libmatemixer/matemixer-client-stream.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2014 Michal Ratajsky <[email protected]>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the licence, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef MATEMIXER_CLIENT_STREAM_H
-#define MATEMIXER_CLIENT_STREAM_H
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include <libmatemixer/matemixer-enums.h>
-#include <libmatemixer/matemixer-types.h>
-
-G_BEGIN_DECLS
-
-#define MATE_MIXER_TYPE_CLIENT_STREAM \
- (mate_mixer_client_stream_get_type ())
-#define MATE_MIXER_CLIENT_STREAM(o) \
- (G_TYPE_CHECK_INSTANCE_CAST ((o), MATE_MIXER_TYPE_CLIENT_STREAM, MateMixerClientStream))
-#define MATE_MIXER_IS_CLIENT_STREAM(o) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((o), MATE_MIXER_TYPE_CLIENT_STREAM))
-#define MATE_MIXER_CLIENT_STREAM_CLASS(k) \
- (G_TYPE_CHECK_CLASS_CAST ((k), MATE_MIXER_TYPE_CLIENT_STREAM, MateMixerClientStreamClass))
-#define MATE_MIXER_IS_CLIENT_STREAM_CLASS(k) \
- (G_TYPE_CHECK_CLASS_TYPE ((k), MATE_MIXER_TYPE_CLIENT_STREAM))
-#define MATE_MIXER_CLIENT_STREAM_GET_CLASS(o) \
- (G_TYPE_INSTANCE_GET_CLASS ((o), MATE_MIXER_TYPE_CLIENT_STREAM, MateMixerClientStreamClass))
-
-typedef struct _MateMixerClientStreamClass MateMixerClientStreamClass;
-typedef struct _MateMixerClientStreamPrivate MateMixerClientStreamPrivate;
-
-struct _MateMixerClientStream
-{
- GObject *parent;
-
- /*< private >*/
- MateMixerClientStreamPrivate *priv;
-};
-
-struct _MateMixerClientStreamClass
-{
- GTypeInterface parent_iface;
-
- /*< private >*/
- MateMixerClientStreamFlags (*get_flags) (MateMixerClientStream *client);
- MateMixerClientStreamRole (*get_role) (MateMixerClientStream *client);
-
- MateMixerStream *(*get_parent) (MateMixerClientStream *client);
- gboolean (*set_parent) (MateMixerClientStream *client,
- MateMixerStream *stream);
-
- gboolean (*remove) (MateMixerClientStream *client);
-
- const gchar *(*get_app_name) (MateMixerClientStream *client);
- const gchar *(*get_app_id) (MateMixerClientStream *client);
- const gchar *(*get_app_version) (MateMixerClientStream *client);
- const gchar *(*get_app_icon) (MateMixerClientStream *client);
-};
-
-GType mate_mixer_client_stream_get_type (void) G_GNUC_CONST;
-
-MateMixerClientStreamFlags mate_mixer_client_stream_get_flags (MateMixerClientStream *client);
-MateMixerClientStreamRole mate_mixer_client_stream_get_role (MateMixerClientStream *client);
-
-MateMixerStream * mate_mixer_client_stream_get_parent (MateMixerClientStream *client);
-gboolean mate_mixer_client_stream_set_parent (MateMixerClientStream *client,
- MateMixerStream *parent);
-
-gboolean mate_mixer_client_stream_remove (MateMixerClientStream *client);
-
-const gchar * mate_mixer_client_stream_get_app_name (MateMixerClientStream *client);
-const gchar * mate_mixer_client_stream_get_app_id (MateMixerClientStream *client);
-const gchar * mate_mixer_client_stream_get_app_version (MateMixerClientStream *client);
-const gchar * mate_mixer_client_stream_get_app_icon (MateMixerClientStream *client);
-
-G_END_DECLS
-
-#endif /* MATEMIXER_CLIENT_STREAM_H */
diff --git a/libmatemixer/matemixer-context.c b/libmatemixer/matemixer-context.c
index a485a06..bb28b18 100644
--- a/libmatemixer/matemixer-context.c
+++ b/libmatemixer/matemixer-context.c
@@ -22,7 +22,6 @@
#include "matemixer.h"
#include "matemixer-backend.h"
#include "matemixer-backend-module.h"
-#include "matemixer-client-stream.h"
#include "matemixer-context.h"
#include "matemixer-enums.h"
#include "matemixer-enum-types.h"
@@ -38,9 +37,10 @@
struct _MateMixerContextPrivate
{
gboolean backend_chosen;
+ gchar *server_address;
MateMixerState state;
MateMixerBackend *backend;
- MateMixerBackendData backend_data;
+ MateMixerAppInfo *app_info;
MateMixerBackendType backend_type;
MateMixerBackendModule *module;
};
@@ -65,8 +65,8 @@ enum {
DEVICE_REMOVED,
STREAM_ADDED,
STREAM_REMOVED,
- STORED_STREAM_ADDED,
- STORED_STREAM_REMOVED,
+ STORED_CONTROL_ADDED,
+ STORED_CONTROL_REMOVED,
N_SIGNALS
};
@@ -107,10 +107,10 @@ static void on_backend_stream_removed (MateMixerBackend *backe
const gchar *name,
MateMixerContext *context);
-static void on_backend_stored_stream_added (MateMixerBackend *backend,
+static void on_backend_stored_control_added (MateMixerBackend *backend,
const gchar *name,
MateMixerContext *context);
-static void on_backend_stored_stream_removed (MateMixerBackend *backend,
+static void on_backend_stored_control_removed (MateMixerBackend *backend,
const gchar *name,
MateMixerContext *context);
@@ -303,17 +303,17 @@ mate_mixer_context_class_init (MateMixerContextClass *klass)
G_TYPE_STRING);
/**
- * MateMixerContext::stored-stream-added:
+ * MateMixerContext::stored-control-added:
* @context: a #MateMixerContext
- * @name: name of the added stored stream
+ * @name: name of the added stored control
*
- * The signal is emitted each time a stored stream is created.
+ * The signal is emitted each time a stored control is created.
*/
- signals[STORED_STREAM_ADDED] =
+ signals[STORED_CONTROL_ADDED] =
g_signal_new ("stored-control-added",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (MateMixerContextClass, stored_stream_added),
+ G_STRUCT_OFFSET (MateMixerContextClass, stored_control_added),
NULL,
NULL,
g_cclosure_marshal_VOID__STRING,
@@ -322,17 +322,17 @@ mate_mixer_context_class_init (MateMixerContextClass *klass)
G_TYPE_STRING);
/**
- * MateMixerContext::stream-removed:
+ * MateMixerContext::stored-control-removed:
* @context: a #MateMixerContext
- * @name: name of the removed stream
+ * @name: name of the removed control
*
- * The signal is emitted each time a stream is removed.
+ * The signal is emitted each time a control is removed.
*/
- signals[STORED_STREAM_REMOVED] =
- g_signal_new ("stored-stream-removed",
+ signals[STORED_CONTROL_REMOVED] =
+ g_signal_new ("stored-control-removed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (MateMixerContextClass, stored_stream_removed),
+ G_STRUCT_OFFSET (MateMixerContextClass, stored_control_removed),
NULL,
NULL,
g_cclosure_marshal_VOID__STRING,
@@ -355,19 +355,19 @@ mate_mixer_context_get_property (GObject *object,
switch (param_id) {
case PROP_APP_NAME:
- g_value_set_string (value, context->priv->backend_data.app_name);
+ g_value_set_string (value, mate_mixer_app_info_get_name (context->priv->app_info));
break;
case PROP_APP_ID:
- g_value_set_string (value, context->priv->backend_data.app_id);
+ g_value_set_string (value, mate_mixer_app_info_get_id (context->priv->app_info));
break;
case PROP_APP_VERSION:
- g_value_set_string (value, context->priv->backend_data.app_version);
+ g_value_set_string (value, mate_mixer_app_info_get_version (context->priv->app_info));
break;
case PROP_APP_ICON:
- g_value_set_string (value, context->priv->backend_data.app_icon);
+ g_value_set_string (value, mate_mixer_app_info_get_icon (context->priv->app_info));
break;
case PROP_SERVER_ADDRESS:
- g_value_set_string (value, context->priv->backend_data.server_address);
+ g_value_set_string (value, context->priv->server_address);
break;
case PROP_STATE:
g_value_set_enum (value, context->priv->state);
@@ -378,6 +378,7 @@ mate_mixer_context_get_property (GObject *object,
case PROP_DEFAULT_OUTPUT_STREAM:
g_value_set_object (value, mate_mixer_context_get_default_output_stream (context));
break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -416,6 +417,7 @@ mate_mixer_context_set_property (GObject *object,
case PROP_DEFAULT_OUTPUT_STREAM:
mate_mixer_context_set_default_output_stream (context, g_value_get_object (value));
break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -428,12 +430,18 @@ mate_mixer_context_init (MateMixerContext *context)
context->priv = G_TYPE_INSTANCE_GET_PRIVATE (context,
MATE_MIXER_TYPE_CONTEXT,
MateMixerContextPrivate);
+
+ context->priv->app_info = _mate_mixer_app_info_new ();
}
static void
mate_mixer_context_dispose (GObject *object)
{
- close_context (MATE_MIXER_CONTEXT (object));
+ MateMixerContext *context;
+
+ context = MATE_MIXER_CONTEXT (object);
+
+ close_context (context);
G_OBJECT_CLASS (mate_mixer_context_parent_class)->dispose (object);
}
@@ -445,11 +453,9 @@ mate_mixer_context_finalize (GObject *object)
context = MATE_MIXER_CONTEXT (object);
- g_free (context->priv->backend_data.app_name);
- g_free (context->priv->backend_data.app_id);
- g_free (context->priv->backend_data.app_version);
- g_free (context->priv->backend_data.app_icon);
- g_free (context->priv->backend_data.server_address);
+ _mate_mixer_app_info_free (context->priv->app_info);
+
+ g_free (context->priv->server_address);
G_OBJECT_CLASS (mate_mixer_context_parent_class)->finalize (object);
}
@@ -504,7 +510,7 @@ mate_mixer_context_set_backend_type (MateMixerContext *context,
context->priv->state == MATE_MIXER_STATE_READY)
return FALSE;
- modules = _mate_mixer_get_modules ();
+ modules = _mate_mixer_list_modules ();
while (modules != NULL) {
module = MATE_MIXER_BACKEND_MODULE (modules->data);
@@ -542,13 +548,11 @@ mate_mixer_context_set_app_name (MateMixerContext *context, const gchar *app_nam
context->priv->state == MATE_MIXER_STATE_READY)
return FALSE;
- if (g_strcmp0 (context->priv->backend_data.app_name, app_name) != 0) {
- g_free (context->priv->backend_data.app_name);
+ _mate_mixer_app_info_set_name (context->priv->app_info, app_name);
- context->priv->backend_data.app_name = g_strdup (app_name);
+ g_object_notify_by_pspec (G_OBJECT (context),
+ properties[PROP_APP_NAME]);
- g_object_notify_by_pspec (G_OBJECT (context), properties[PROP_APP_NAME]);
- }
return TRUE;
}
@@ -575,13 +579,11 @@ mate_mixer_context_set_app_id (MateMixerContext *context, const gchar *app_id)
context->priv->state == MATE_MIXER_STATE_READY)
return FALSE;
- if (g_strcmp0 (context->priv->backend_data.app_id, app_id) != 0) {
- g_free (context->priv->backend_data.app_id);
+ _mate_mixer_app_info_set_id (context->priv->app_info, app_id);
- context->priv->backend_data.app_id = g_strdup (app_id);
+ g_object_notify_by_pspec (G_OBJECT (context),
+ properties[PROP_APP_ID]);
- g_object_notify_by_pspec (G_OBJECT (context), properties[PROP_APP_ID]);
- }
return TRUE;
}
@@ -608,13 +610,11 @@ mate_mixer_context_set_app_version (MateMixerContext *context, const gchar *app_
context->priv->state == MATE_MIXER_STATE_READY)
return FALSE;
- if (g_strcmp0 (context->priv->backend_data.app_version, app_version) != 0) {
- g_free (context->priv->backend_data.app_version);
+ _mate_mixer_app_info_set_version (context->priv->app_info, app_version);
- context->priv->backend_data.app_version = g_strdup (app_version);
+ g_object_notify_by_pspec (G_OBJECT (context),
+ properties[PROP_APP_VERSION]);
- g_object_notify_by_pspec (G_OBJECT (context), properties[PROP_APP_VERSION]);
- }
return TRUE;
}
@@ -641,13 +641,11 @@ mate_mixer_context_set_app_icon (MateMixerContext *context, const gchar *app_ico
context->priv->state == MATE_MIXER_STATE_READY)
return FALSE;
- if (g_strcmp0 (context->priv->backend_data.app_icon, app_icon) != 0) {
- g_free (context->priv->backend_data.app_icon);
+ _mate_mixer_app_info_set_icon (context->priv->app_info, app_icon);
- context->priv->backend_data.app_icon = g_strdup (app_icon);
+ g_object_notify_by_pspec (G_OBJECT (context),
+ properties[PROP_APP_ICON]);
- g_object_notify_by_pspec (G_OBJECT (context), properties[PROP_APP_ICON]);
- }
return TRUE;
}
@@ -675,13 +673,13 @@ mate_mixer_context_set_server_address (MateMixerContext *context, const gchar *a
context->priv->state == MATE_MIXER_STATE_READY)
return FALSE;
- if (g_strcmp0 (context->priv->backend_data.server_address, address) != 0) {
- g_free (context->priv->backend_data.server_address);
+ g_free (context->priv->server_address);
- context->priv->backend_data.server_address = g_strdup (address);
+ context->priv->server_address = g_strdup (address);
+
+ g_object_notify_by_pspec (G_OBJECT (context),
+ properties[PROP_SERVER_ADDRESS]);
- g_object_notify_by_pspec (G_OBJECT (context), properties[PROP_SERVER_ADDRESS]);
- }
return TRUE;
}
@@ -727,7 +725,7 @@ mate_mixer_context_open (MateMixerContext *context)
/* We are going to choose the first backend to try. It will be either the one
* specified by the application or the one with the highest priority */
- modules = _mate_mixer_get_modules ();
+ modules = _mate_mixer_list_modules ();
if (context->priv->backend_type != MATE_MIXER_BACKEND_UNKNOWN) {
while (modules != NULL) {
@@ -758,7 +756,8 @@ mate_mixer_context_open (MateMixerContext *context)
context->priv->module = g_object_ref (module);
context->priv->backend = g_object_new (info->g_type, NULL);
- mate_mixer_backend_set_data (context->priv->backend, &context->priv->backend_data);
+ mate_mixer_backend_set_app_info (context->priv->backend, context->priv->app_info);
+ mate_mixer_backend_set_server_address (context->priv->backend, context->priv->server_address);
g_debug ("Trying to open backend %s", info->name);
@@ -848,21 +847,13 @@ mate_mixer_context_get_state (MateMixerContext *context)
MateMixerDevice *
mate_mixer_context_get_device (MateMixerContext *context, const gchar *name)
{
- GList *list;
-
g_return_val_if_fail (MATE_MIXER_IS_CONTEXT (context), NULL);
g_return_val_if_fail (name != NULL, NULL);
- list = (GList *) mate_mixer_context_list_devices (context);
- while (list != NULL) {
- MateMixerDevice *device = MATE_MIXER_DEVICE (list->data);
-
- if (strcmp (name, mate_mixer_device_get_name (device)) == 0)
- return device;
+ if (context->priv->state != MATE_MIXER_STATE_READY)
+ return NULL;
- list = list->next;
- }
- return NULL;
+ return mate_mixer_backend_get_device (MATE_MIXER_BACKEND (context->priv->backend), name);
}
/**
@@ -877,50 +868,34 @@ mate_mixer_context_get_device (MateMixerContext *context, const gchar *name)
MateMixerStream *
mate_mixer_context_get_stream (MateMixerContext *context, const gchar *name)
{
- GList *list;
-
g_return_val_if_fail (MATE_MIXER_IS_CONTEXT (context), NULL);
g_return_val_if_fail (name != NULL, NULL);
- list = (GList *) mate_mixer_context_list_streams (context);
- while (list != NULL) {
- MateMixerStream *stream = MATE_MIXER_STREAM (list->data);
-
- if (strcmp (name, mate_mixer_stream_get_name (stream)) == 0)
- return stream;
+ if (context->priv->state != MATE_MIXER_STATE_READY)
+ return NULL;
- list = list->next;
- }
- return NULL;
+ return mate_mixer_backend_get_stream (MATE_MIXER_BACKEND (context->priv->backend), name);
}
/**
- * mate_mixer_context_get_stored_stream:
+ * mate_mixer_context_get_stored_control:
* @context: a #MateMixerContext
- * @name: a stream name
+ * @name: a stored control name
*
- * Gets the stream with the given name.
+ * Gets the stored control with the given name.
*
- * Returns: a #MateMixerStream or %NULL if there is no such stream.
+ * Returns: a #MateMixerStoredControl or %NULL if there is no such control.
*/
-MateMixerStream *
-mate_mixer_context_get_stored_stream (MateMixerContext *context, const gchar *name)
+MateMixerStoredControl *
+mate_mixer_context_get_stored_control (MateMixerContext *context, const gchar *name)
{
- GList *list;
-
g_return_val_if_fail (MATE_MIXER_IS_CONTEXT (context), NULL);
g_return_val_if_fail (name != NULL, NULL);
- list = (GList *) mate_mixer_context_list_stored_streams (context);
- while (list != NULL) {
- MateMixerStream *stream = MATE_MIXER_STREAM (list->data);
-
- if (strcmp (name, mate_mixer_stream_get_name (stream)) == 0)
- return stream;
+ if (context->priv->state != MATE_MIXER_STATE_READY)
+ return NULL;
- list = list->next;
- }
- return NULL;
+ return mate_mixer_backend_get_stored_control (MATE_MIXER_BACKEND (context->priv->backend), name);
}
/**
@@ -972,19 +947,19 @@ mate_mixer_context_list_streams (MateMixerContext *context)
}
/**
- * mate_mixer_context_list_stored_streams:
+ * mate_mixer_context_list_stored_controls:
* @context: a #MateMixerContext
*
*/
const GList *
-mate_mixer_context_list_stored_streams (MateMixerContext *context)
+mate_mixer_context_list_stored_controls (MateMixerContext *context)
{
g_return_val_if_fail (MATE_MIXER_IS_CONTEXT (context), NULL);
if (context->priv->state != MATE_MIXER_STATE_READY)
return NULL;
- return mate_mixer_backend_list_stored_streams (MATE_MIXER_BACKEND (context->priv->backend));
+ return mate_mixer_backend_list_stored_controls (MATE_MIXER_BACKEND (context->priv->backend));
}
/**
@@ -1028,11 +1003,7 @@ mate_mixer_context_set_default_input_stream (MateMixerContext *context,
if (context->priv->state != MATE_MIXER_STATE_READY)
return FALSE;
- if (MATE_MIXER_IS_CLIENT_STREAM (stream)) {
- g_warning ("Unable to set client stream as the default input stream");
- return FALSE;
- }
- if (!(mate_mixer_stream_get_flags (stream) & MATE_MIXER_STREAM_INPUT)) {
+ if (mate_mixer_stream_get_direction (stream) != MATE_MIXER_DIRECTION_INPUT) {
g_warning ("Unable to set non-input stream as the default input stream");
return FALSE;
}
@@ -1081,11 +1052,7 @@ mate_mixer_context_set_default_output_stream (MateMixerContext *context,
if (context->priv->state != MATE_MIXER_STATE_READY)
return FALSE;
- if (MATE_MIXER_IS_CLIENT_STREAM (stream)) {
- g_warning ("Unable to set client stream as the default output stream");
- return FALSE;
- }
- if (!(mate_mixer_stream_get_flags (stream) & MATE_MIXER_STREAM_OUTPUT)) {
+ if (mate_mixer_stream_get_direction (stream) != MATE_MIXER_DIRECTION_OUTPUT) {
g_warning ("Unable to set non-output stream as the default output stream");
return FALSE;
}
@@ -1231,23 +1198,23 @@ on_backend_stream_removed (MateMixerBackend *backend,
}
static void
-on_backend_stored_stream_added (MateMixerBackend *backend,
- const gchar *name,
- MateMixerContext *context)
+on_backend_stored_control_added (MateMixerBackend *backend,
+ const gchar *name,
+ MateMixerContext *context)
{
g_signal_emit (G_OBJECT (context),
- signals[STORED_STREAM_ADDED],
+ signals[STORED_CONTROL_ADDED],
0,
name);
}
static void
-on_backend_stored_stream_removed (MateMixerBackend *backend,
- const gchar *name,
- MateMixerContext *context)
+on_backend_stored_control_removed (MateMixerBackend *backend,
+ const gchar *name,
+ MateMixerContext *context)
{
g_signal_emit (G_OBJECT (context),
- signals[STORED_STREAM_REMOVED],
+ signals[STORED_CONTROL_REMOVED],
0,
name);
}
@@ -1276,7 +1243,7 @@ try_next_backend (MateMixerContext *context)
const GList *modules;
const MateMixerBackendInfo *info = NULL;
- modules = _mate_mixer_get_modules ();
+ modules = _mate_mixer_list_modules ();
while (modules != NULL) {
if (context->priv->module == modules->data) {
@@ -1301,7 +1268,8 @@ try_next_backend (MateMixerContext *context)
context->priv->module = g_object_ref (module);
context->priv->backend = g_object_new (info->g_type, NULL);
- mate_mixer_backend_set_data (context->priv->backend, &context->priv->backend_data);
+ mate_mixer_backend_set_app_info (context->priv->backend, context->priv->app_info);
+ mate_mixer_backend_set_server_address (context->priv->backend, context->priv->server_address);
g_debug ("Trying to open backend %s", info->name);
@@ -1359,20 +1327,20 @@ change_state (MateMixerContext *context, MateMixerState state)
G_CALLBACK (on_backend_stream_removed),
context);
g_signal_connect (G_OBJECT (context->priv->backend),
- "stored-stream-added",
- G_CALLBACK (on_backend_stored_stream_added),
+ "stored-control-added",
+ G_CALLBACK (on_backend_stored_control_added),
context);
g_signal_connect (G_OBJECT (context->priv->backend),
- "stored-stream-removed",
- G_CALLBACK (on_backend_stored_stream_removed),
+ "stored-control-removed",
+ G_CALLBACK (on_backend_stored_control_removed),
context);
g_signal_connect (G_OBJECT (context->priv->backend),
- "notify::default-input",
+ "notify::default-input-stream",
G_CALLBACK (on_backend_default_input_stream_notify),
context);
g_signal_connect (G_OBJECT (context->priv->backend),
- "notify::default-output",
+ "notify::default-output-stream",
G_CALLBACK (on_backend_default_output_stream_notify),
context);
diff --git a/libmatemixer/matemixer-context.h b/libmatemixer/matemixer-context.h
index 3370570..30d9363 100644
--- a/libmatemixer/matemixer-context.h
+++ b/libmatemixer/matemixer-context.h
@@ -66,64 +66,64 @@ struct _MateMixerContextClass
GObjectClass parent_class;
/*< private >*/
- void (*device_added) (MateMixerContext *context,
- const gchar *name);
- void (*device_removed) (MateMixerContext *context,
- const gchar *name);
- void (*stream_added) (MateMixerContext *context,
- const gchar *name);
- void (*stream_removed) (MateMixerContext *context,
- const gchar *name);
- void (*stored_stream_added) (MateMixerContext *context,
- const gchar *name);
- void (*stored_stream_removed) (MateMixerContext *context,
- const gchar *name);
+ void (*device_added) (MateMixerContext *context,
+ const gchar *name);
+ void (*device_removed) (MateMixerContext *context,
+ const gchar *name);
+ void (*stream_added) (MateMixerContext *context,
+ const gchar *name);
+ void (*stream_removed) (MateMixerContext *context,
+ const gchar *name);
+ void (*stored_control_added) (MateMixerContext *context,
+ const gchar *name);
+ void (*stored_control_removed) (MateMixerContext *context,
+ const gchar *name);
};
-GType mate_mixer_context_get_type (void) G_GNUC_CONST;
-
-MateMixerContext * mate_mixer_context_new (void);
-
-gboolean mate_mixer_context_set_backend_type (MateMixerContext *context,
- MateMixerBackendType backend_type);
-gboolean mate_mixer_context_set_app_name (MateMixerContext *context,
- const gchar *app_name);
-gboolean mate_mixer_context_set_app_id (MateMixerContext *context,
- const gchar *app_id);
-gboolean mate_mixer_context_set_app_version (MateMixerContext *context,
- const gchar *app_version);
-gboolean mate_mixer_context_set_app_icon (MateMixerContext *context,
- const gchar *app_icon);
-gboolean mate_mixer_context_set_server_address (MateMixerContext *context,
- const gchar *address);
-
-gboolean mate_mixer_context_open (MateMixerContext *context);
-void mate_mixer_context_close (MateMixerContext *context);
-
-MateMixerState mate_mixer_context_get_state (MateMixerContext *context);
-
-MateMixerDevice * mate_mixer_context_get_device (MateMixerContext *context,
- const gchar *name);
-MateMixerStream * mate_mixer_context_get_stream (MateMixerContext *context,
- const gchar *name);
-MateMixerStream * mate_mixer_context_get_stored_stream (MateMixerContext *context,
- const gchar *name);
-
-const GList * mate_mixer_context_list_devices (MateMixerContext *context);
-const GList * mate_mixer_context_list_streams (MateMixerContext *context);
-const GList * mate_mixer_context_list_stored_streams (MateMixerContext *context);
-
-MateMixerStream * mate_mixer_context_get_default_input_stream (MateMixerContext *context);
-gboolean mate_mixer_context_set_default_input_stream (MateMixerContext *context,
- MateMixerStream *stream);
-
-MateMixerStream * mate_mixer_context_get_default_output_stream (MateMixerContext *context);
-gboolean mate_mixer_context_set_default_output_stream (MateMixerContext *context,
- MateMixerStream *stream);
-
-const gchar * mate_mixer_context_get_backend_name (MateMixerContext *context);
-MateMixerBackendType mate_mixer_context_get_backend_type (MateMixerContext *context);
-MateMixerBackendFlags mate_mixer_context_get_backend_flags (MateMixerContext *context);
+GType mate_mixer_context_get_type (void) G_GNUC_CONST;
+
+MateMixerContext * mate_mixer_context_new (void);
+
+gboolean mate_mixer_context_set_backend_type (MateMixerContext *context,
+ MateMixerBackendType backend_type);
+gboolean mate_mixer_context_set_app_name (MateMixerContext *context,
+ const gchar *app_name);
+gboolean mate_mixer_context_set_app_id (MateMixerContext *context,
+ const gchar *app_id);
+gboolean mate_mixer_context_set_app_version (MateMixerContext *context,
+ const gchar *app_version);
+gboolean mate_mixer_context_set_app_icon (MateMixerContext *context,
+ const gchar *app_icon);
+gboolean mate_mixer_context_set_server_address (MateMixerContext *context,
+ const gchar *address);
+
+gboolean mate_mixer_context_open (MateMixerContext *context);
+void mate_mixer_context_close (MateMixerContext *context);
+
+MateMixerState mate_mixer_context_get_state (MateMixerContext *context);
+
+MateMixerDevice * mate_mixer_context_get_device (MateMixerContext *context,
+ const gchar *name);
+MateMixerStream * mate_mixer_context_get_stream (MateMixerContext *context,
+ const gchar *name);
+MateMixerStoredControl *mate_mixer_context_get_stored_control (MateMixerContext *context,
+ const gchar *name);
+
+const GList * mate_mixer_context_list_devices (MateMixerContext *context);
+const GList * mate_mixer_context_list_streams (MateMixerContext *context);
+const GList * mate_mixer_context_list_stored_controls (MateMixerContext *context);
+
+MateMixerStream * mate_mixer_context_get_default_input_stream (MateMixerContext *context);
+gboolean mate_mixer_context_set_default_input_stream (MateMixerContext *context,
+ MateMixerStream *stream);
+
+MateMixerStream * mate_mixer_context_get_default_output_stream (MateMixerContext *context);
+gboolean mate_mixer_context_set_default_output_stream (MateMixerContext *context,
+ MateMixerStream *stream);
+
+const gchar * mate_mixer_context_get_backend_name (MateMixerContext *context);
+MateMixerBackendType mate_mixer_context_get_backend_type (MateMixerContext *context);
+MateMixerBackendFlags mate_mixer_context_get_backend_flags (MateMixerContext *context);
G_END_DECLS
diff --git a/libmatemixer/matemixer-device-profile-private.h b/libmatemixer/matemixer-device-profile-private.h
deleted file mode 100644
index 44f2853..0000000
--- a/libmatemixer/matemixer-device-profile-private.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2014 Michal Ratajsky <[email protected]>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the licence, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef MATEMIXER_DEVICE_PROFILE_PRIVATE_H
-#define MATEMIXER_DEVICE_PROFILE_PRIVATE_H
-
-#include <glib.h>
-
-#include "matemixer-device-profile.h"
-
-G_BEGIN_DECLS
-
-MateMixerDeviceProfile *_mate_mixer_device_profile_new (const gchar *name,
- const gchar *description,
- guint priority,
- guint input_streams,
- guint output_streams);
-
-gboolean _mate_mixer_device_profile_set_label (MateMixerDeviceProfile *profile,
- const gchar *label);
-gboolean _mate_mixer_device_profile_set_priority (MateMixerDeviceProfile *profile,
- guint priority);
-gboolean _mate_mixer_device_profile_set_num_input_streams (MateMixerDeviceProfile *profile,
- guint num);
-gboolean _mate_mixer_device_profile_set_num_output_streams (MateMixerDeviceProfile *profile,
- guint num);
-
-G_END_DECLS
-
-#endif /* MATEMIXER_DEVICE_PROFILE_PRIVATE_H */
diff --git a/libmatemixer/matemixer-device-profile.c b/libmatemixer/matemixer-device-profile.c
deleted file mode 100644
index d841ff2..0000000
--- a/libmatemixer/matemixer-device-profile.c
+++ /dev/null
@@ -1,370 +0,0 @@
-/*
- * Copyright (C) 2014 Michal Ratajsky <[email protected]>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the licence, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include "matemixer-device-profile.h"
-#include "matemixer-device-profile-private.h"
-
-/**
- * SECTION:matemixer-device-profile
- * @short_description: Device profile
- * @include: libmatemixer/matemixer.h
- */
-
-struct _MateMixerDeviceProfilePrivate
-{
- gchar *name;
- gchar *label;
- guint priority;
- guint num_input_streams;
- guint num_output_streams;
-};
-
-enum {
- PROP_0,
- PROP_NAME,
- PROP_LABEL,
- PROP_PRIORITY,
- PROP_NUM_INPUT_STREAMS,
- PROP_NUM_OUTPUT_STREAMS,
- N_PROPERTIES
-};
-
-static GParamSpec *properties[N_PROPERTIES] = { NULL, };
-
-static void mate_mixer_device_profile_class_init (MateMixerDeviceProfileClass *klass);
-
-static void mate_mixer_device_profile_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec);
-static void mate_mixer_device_profile_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec);
-
-static void mate_mixer_device_profile_init (MateMixerDeviceProfile *profile);
-static void mate_mixer_device_profile_finalize (GObject *object);
-
-G_DEFINE_TYPE (MateMixerDeviceProfile, mate_mixer_device_profile, G_TYPE_OBJECT);
-
-static void
-mate_mixer_device_profile_class_init (MateMixerDeviceProfileClass *klass)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = mate_mixer_device_profile_finalize;
- object_class->get_property = mate_mixer_device_profile_get_property;
- object_class->set_property = mate_mixer_device_profile_set_property;
-
- properties[PROP_NAME] =
- g_param_spec_string ("name",
- "Name",
- "Name of the profile",
- NULL,
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS);
-
- properties[PROP_LABEL] =
- g_param_spec_string ("label",
- "Label",
- "Label of the profile",
- NULL,
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS);
-
- properties[PROP_PRIORITY] =
- g_param_spec_uint ("priority",
- "Priority",
- "Priority of the profile",
- 0,
- G_MAXUINT,
- 0,
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS);
-
- properties[PROP_NUM_INPUT_STREAMS] =
- g_param_spec_uint ("num-input-streams",
- "Number of input streams",
- "Number of input streams in the profile",
- 0,
- G_MAXUINT,
- 0,
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS);
-
- properties[PROP_NUM_OUTPUT_STREAMS] =
- g_param_spec_uint ("num-output-streams",
- "Number of output streams",
- "Number of output streams in the profile",
- 0,
- G_MAXUINT,
- 0,
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS);
-
- g_object_class_install_properties (object_class, N_PROPERTIES, properties);
-
- g_type_class_add_private (object_class, sizeof (MateMixerDeviceProfilePrivate));
-}
-
-static void
-mate_mixer_device_profile_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec)
-{
- MateMixerDeviceProfile *profile;
-
- profile = MATE_MIXER_DEVICE_PROFILE (object);
-
- switch (param_id) {
- case PROP_NAME:
- g_value_set_string (value, profile->priv->name);
- break;
-
- case PROP_LABEL:
- g_value_set_string (value, profile->priv->label);
- break;
-
- case PROP_PRIORITY:
- g_value_set_uint (value, profile->priv->priority);
- break;
-
- case PROP_NUM_INPUT_STREAMS:
- g_value_set_uint (value, profile->priv->num_input_streams);
- break;
-
- case PROP_NUM_OUTPUT_STREAMS:
- g_value_set_uint (value, profile->priv->num_output_streams);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-static void
-mate_mixer_device_profile_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- MateMixerDeviceProfile *profile;
-
- profile = MATE_MIXER_DEVICE_PROFILE (object);
-
- switch (param_id) {
- case PROP_NAME:
- /* Construct-only string */
- profile->priv->name = g_strdup (g_value_get_string (value));
- break;
-
- case PROP_LABEL:
- /* Construct-only string */
- profile->priv->label = g_strdup (g_value_get_string (value));
- break;
-
- case PROP_PRIORITY:
- profile->priv->priority = g_value_get_uint (value);
- break;
-
- case PROP_NUM_INPUT_STREAMS:
- profile->priv->num_input_streams = g_value_get_uint (value);
- break;
-
- case PROP_NUM_OUTPUT_STREAMS:
- profile->priv->num_output_streams = g_value_get_uint (value);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-static void
-mate_mixer_device_profile_init (MateMixerDeviceProfile *profile)
-{
- profile->priv = G_TYPE_INSTANCE_GET_PRIVATE (profile,
- MATE_MIXER_TYPE_DEVICE_PROFILE,
- MateMixerDeviceProfilePrivate);
-}
-
-static void
-mate_mixer_device_profile_finalize (GObject *object)
-{
- MateMixerDeviceProfile *profile;
-
- profile = MATE_MIXER_DEVICE_PROFILE (object);
-
- g_free (profile->priv->name);
- g_free (profile->priv->label);
-
- G_OBJECT_CLASS (mate_mixer_device_profile_parent_class)->finalize (object);
-}
-
-/**
- * mate_mixer_device_profile_get_name:
- * @profile: a #MateMixerDeviceProfile
- */
-const gchar *
-mate_mixer_device_profile_get_name (MateMixerDeviceProfile *profile)
-{
- g_return_val_if_fail (MATE_MIXER_IS_DEVICE_PROFILE (profile), NULL);
-
- return profile->priv->name;
-}
-
-/**
- * mate_mixer_device_profile_get_label:
- * @profile: a #MateMixerDeviceProfile
- */
-const gchar *
-mate_mixer_device_profile_get_label (MateMixerDeviceProfile *profile)
-{
- g_return_val_if_fail (MATE_MIXER_IS_DEVICE_PROFILE (profile), NULL);
-
- return profile->priv->label;
-}
-
-/**
- * mate_mixer_device_profile_get_priority:
- * @profile: a #MateMixerDeviceProfile
- */
-guint
-mate_mixer_device_profile_get_priority (MateMixerDeviceProfile *profile)
-{
- g_return_val_if_fail (MATE_MIXER_IS_DEVICE_PROFILE (profile), 0);
-
- return profile->priv->priority;
-}
-
-/**
- * mate_mixer_device_profile_get_num_input_streams:
- * @profile: a #MateMixerDeviceProfile
- */
-guint
-mate_mixer_device_profile_get_num_input_streams (MateMixerDeviceProfile *profile)
-{
- g_return_val_if_fail (MATE_MIXER_IS_DEVICE_PROFILE (profile), 0);
-
- return profile->priv->num_input_streams;
-}
-
-/**
- * mate_mixer_device_profile_get_num_output_streams:
- * @profile: a #MateMixerDeviceProfile
- */
-guint
-mate_mixer_device_profile_get_num_output_streams (MateMixerDeviceProfile *profile)
-{
- g_return_val_if_fail (MATE_MIXER_IS_DEVICE_PROFILE (profile), 0);
-
- return profile->priv->num_output_streams;
-}
-
-MateMixerDeviceProfile *
-_mate_mixer_device_profile_new (const gchar *name,
- const gchar *label,
- guint priority,
- guint input_streams,
- guint output_streams)
-{
- return g_object_new (MATE_MIXER_TYPE_DEVICE_PROFILE,
- "name", name,
- "label", label,
- "priority", priority,
- "num-input-streams", input_streams,
- "num-output-streams", output_streams,
- NULL);
-}
-
-gboolean
-_mate_mixer_device_profile_set_label (MateMixerDeviceProfile *profile,
- const gchar *label)
-{
- g_return_val_if_fail (MATE_MIXER_IS_DEVICE_PROFILE (profile), FALSE);
-
- if (g_strcmp0 (profile->priv->label, label) != 0) {
- g_free (profile->priv->label);
-
- profile->priv->label = g_strdup (label);
-
- g_object_notify_by_pspec (G_OBJECT (profile), properties[PROP_LABEL]);
- return TRUE;
- }
-
- return FALSE;
-}
-
-gboolean
-_mate_mixer_device_profile_set_priority (MateMixerDeviceProfile *profile,
- guint priority)
-{
- g_return_val_if_fail (MATE_MIXER_IS_DEVICE_PROFILE (profile), FALSE);
-
- if (profile->priv->priority != priority) {
- profile->priv->priority = priority;
-
- g_object_notify_by_pspec (G_OBJECT (profile), properties[PROP_PRIORITY]);
- return TRUE;
- }
-
- return FALSE;
-}
-
-gboolean
-_mate_mixer_device_profile_set_num_input_streams (MateMixerDeviceProfile *profile,
- guint num)
-{
- g_return_val_if_fail (MATE_MIXER_IS_DEVICE_PROFILE (profile), FALSE);
-
- if (profile->priv->num_input_streams != num) {
- profile->priv->num_input_streams = num;
-
- g_object_notify_by_pspec (G_OBJECT (profile), properties[PROP_NUM_INPUT_STREAMS]);
- return TRUE;
- }
-
- return FALSE;
-}
-
-gboolean
-_mate_mixer_device_profile_set_num_output_streams (MateMixerDeviceProfile *profile,
- guint num)
-{
- g_return_val_if_fail (MATE_MIXER_IS_DEVICE_PROFILE (profile), FALSE);
-
- if (profile->priv->num_output_streams != num) {
- profile->priv->num_output_streams = num;
-
- g_object_notify_by_pspec (G_OBJECT (profile), properties[PROP_NUM_OUTPUT_STREAMS]);
- return TRUE;
- }
-
- return FALSE;
-}
diff --git a/libmatemixer/matemixer-device-profile.h b/libmatemixer/matemixer-device-profile.h
deleted file mode 100644
index 8e4221a..0000000
--- a/libmatemixer/matemixer-device-profile.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2014 Michal Ratajsky <[email protected]>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the licence, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef MATEMIXER_DEVICE_PROFILE_H
-#define MATEMIXER_DEVICE_PROFILE_H
-
-#include <glib.h>
-#include <glib-object.h>
-#include <libmatemixer/matemixer-types.h>
-
-G_BEGIN_DECLS
-
-#define MATE_MIXER_TYPE_DEVICE_PROFILE \
- (mate_mixer_device_profile_get_type ())
-#define MATE_MIXER_DEVICE_PROFILE(o) \
- (G_TYPE_CHECK_INSTANCE_CAST ((o), MATE_MIXER_TYPE_DEVICE_PROFILE, MateMixerDeviceProfile))
-#define MATE_MIXER_IS_DEVICE_PROFILE(o) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((o), MATE_MIXER_TYPE_DEVICE_PROFILE))
-#define MATE_MIXER_DEVICE_PROFILE_CLASS(k) \
- (G_TYPE_CHECK_CLASS_CAST ((k), MATE_MIXER_TYPE_DEVICE_PROFILE, MateMixerDeviceProfileClass))
-#define MATE_MIXER_IS_DEVICE_PROFILE_CLASS(k) \
- (G_TYPE_CHECK_CLASS_TYPE ((k), MATE_MIXER_TYPE_DEVICE_PROFILE))
-#define MATE_MIXER_DEVICE_PROFILE_GET_CLASS(o) \
- (G_TYPE_INSTANCE_GET_CLASS ((o), MATE_MIXER_TYPE_DEVICE_PROFILE, MateMixerDeviceProfileClass))
-
-typedef struct _MateMixerDeviceProfileClass MateMixerDeviceProfileClass;
-typedef struct _MateMixerDeviceProfilePrivate MateMixerDeviceProfilePrivate;
-
-struct _MateMixerDeviceProfile
-{
- GObject parent;
-
- /*< private >*/
- MateMixerDeviceProfilePrivate *priv;
-};
-
-struct _MateMixerDeviceProfileClass
-{
- GObjectClass parent_class;
-};
-
-GType mate_mixer_device_profile_get_type (void) G_GNUC_CONST;
-
-const gchar *mate_mixer_device_profile_get_name (MateMixerDeviceProfile *profile);
-const gchar *mate_mixer_device_profile_get_label (MateMixerDeviceProfile *profile);
-guint mate_mixer_device_profile_get_priority (MateMixerDeviceProfile *profile);
-
-guint mate_mixer_device_profile_get_num_input_streams (MateMixerDeviceProfile *profile);
-guint mate_mixer_device_profile_get_num_output_streams (MateMixerDeviceProfile *profile);
-
-G_END_DECLS
-
-#endif /* MATEMIXER_DEVICE_PROFILE_H */
diff --git a/libmatemixer/matemixer-device.c b/libmatemixer/matemixer-device.c
index 229110f..8144388 100644
--- a/libmatemixer/matemixer-device.c
+++ b/libmatemixer/matemixer-device.c
@@ -20,7 +20,6 @@
#include <glib-object.h>
#include "matemixer-device.h"
-#include "matemixer-device-profile.h"
#include "matemixer-stream.h"
#include "matemixer-switch.h"
@@ -32,13 +31,9 @@
struct _MateMixerDevicePrivate
{
- gchar *name;
- gchar *label;
- gchar *icon;
- GList *streams;
- GList *switches;
- GList *profiles;
- MateMixerDeviceProfile *profile;
+ gchar *name;
+ gchar *label;
+ gchar *icon;
};
enum {
@@ -46,7 +41,6 @@ enum {
PROP_NAME,
PROP_LABEL,
PROP_ICON,
- PROP_ACTIVE_PROFILE,
N_PROPERTIES
};
@@ -74,17 +68,14 @@ static void mate_mixer_device_set_property (GObject *object,
GParamSpec *pspec);
static void mate_mixer_device_init (MateMixerDevice *device);
-static void mate_mixer_device_dispose (GObject *object);
static void mate_mixer_device_finalize (GObject *object);
G_DEFINE_ABSTRACT_TYPE (MateMixerDevice, mate_mixer_device, G_TYPE_OBJECT)
-static MateMixerStream * mate_mixer_device_real_get_stream (MateMixerDevice *device,
- const gchar *name);
-static MateMixerSwitch * mate_mixer_device_real_get_switch (MateMixerDevice *device,
- const gchar *name);
-static MateMixerDeviceProfile *mate_mixer_device_real_get_profile (MateMixerDevice *device,
- const gchar *name);
+static MateMixerStream *mate_mixer_device_real_get_stream (MateMixerDevice *device,
+ const gchar *name);
+static MateMixerSwitch *mate_mixer_device_real_get_switch (MateMixerDevice *device,
+ const gchar *name);
static void
mate_mixer_device_class_init (MateMixerDeviceClass *klass)
@@ -93,10 +84,8 @@ mate_mixer_device_class_init (MateMixerDeviceClass *klass)
klass->get_stream = mate_mixer_device_real_get_stream;
klass->get_switch = mate_mixer_device_real_get_switch;
- klass->get_profile = mate_mixer_device_real_get_profile;
object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = mate_mixer_device_dispose;
object_class->finalize = mate_mixer_device_finalize;
object_class->get_property = mate_mixer_device_get_property;
object_class->set_property = mate_mixer_device_set_property;
@@ -128,14 +117,6 @@ mate_mixer_device_class_init (MateMixerDeviceClass *klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
- properties[PROP_ACTIVE_PROFILE] =
- g_param_spec_object ("active-profile",
- "Active profile",
- "The currently active profile of the device",
- MATE_MIXER_TYPE_DEVICE_PROFILE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS);
-
g_object_class_install_properties (object_class, N_PROPERTIES, properties);
signals[STREAM_ADDED] =
@@ -209,10 +190,6 @@ mate_mixer_device_get_property (GObject *object,
case PROP_ICON:
g_value_set_string (value, device->priv->icon);
break;
- case PROP_ACTIVE_PROFILE:
- g_value_set_object (value, device->priv->profile);
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -258,31 +235,6 @@ mate_mixer_device_init (MateMixerDevice *device)
}
static void
-mate_mixer_device_dispose (GObject *object)
-{
- MateMixerDevice *device;
-
- device = MATE_MIXER_DEVICE (object);
-
- if (device->priv->streams != NULL) {
- g_list_free_full (device->priv->streams, g_object_unref);
- device->priv->streams = NULL;
- }
- if (device->priv->switches != NULL) {
- g_list_free_full (device->priv->switches, g_object_unref);
- device->priv->switches = NULL;
- }
- if (device->priv->profiles != NULL) {
- g_list_free_full (device->priv->profiles, g_object_unref);
- device->priv->profiles = NULL;
- }
-
- g_clear_object (&device->priv->profile);
-
- G_OBJECT_CLASS (mate_mixer_device_parent_class)->dispose (object);
-}
-
-static void
mate_mixer_device_finalize (GObject *object)
{
MateMixerDevice *device;
@@ -309,7 +261,7 @@ mate_mixer_device_get_name (MateMixerDevice *device)
}
/**
- * mate_mixer_device_get_description:
+ * mate_mixer_device_get_label:
* @device: a #MateMixerDevice
*/
const gchar *
@@ -333,20 +285,9 @@ mate_mixer_device_get_icon (MateMixerDevice *device)
}
/**
- * mate_mixer_device_get_profile:
- * @device: a #MateMixerDevice
- * @name: a profile name
- */
-MateMixerDeviceProfile *
-mate_mixer_device_get_profile (MateMixerDevice *device, const gchar *name)
-{
- return MATE_MIXER_DEVICE_GET_CLASS (device)->get_profile (device, name);
-}
-
-/**
* mate_mixer_device_get_stream:
* @device: a #MateMixerDevice
- * @name: a profile name
+ * @name: a stream name
*/
MateMixerStream *
mate_mixer_device_get_stream (MateMixerDevice *device, const gchar *name)
@@ -357,7 +298,7 @@ mate_mixer_device_get_stream (MateMixerDevice *device, const gchar *name)
/**
* mate_mixer_device_get_switch:
* @device: a #MateMixerDevice
- * @name: a profile name
+ * @name: a switch name
*/
MateMixerSwitch *
mate_mixer_device_get_switch (MateMixerDevice *device, const gchar *name)
@@ -372,16 +313,16 @@ mate_mixer_device_get_switch (MateMixerDevice *device, const gchar *name)
const GList *
mate_mixer_device_list_streams (MateMixerDevice *device)
{
+ MateMixerDeviceClass *klass;
+
g_return_val_if_fail (MATE_MIXER_IS_DEVICE (device), NULL);
- if (device->priv->streams == NULL) {
- MateMixerDeviceClass *klass = MATE_MIXER_DEVICE_GET_CLASS (device);
+ klass = MATE_MIXER_DEVICE_GET_CLASS (device);
- if (klass->list_streams != NULL)
- device->priv->streams = klass->list_streams (device);
- }
+ if G_LIKELY (klass->list_streams != NULL)
+ return klass->list_streams (device);
- return (const GList *) device->priv->streams;
+ return NULL;
}
/**
@@ -391,77 +332,16 @@ mate_mixer_device_list_streams (MateMixerDevice *device)
const GList *
mate_mixer_device_list_switches (MateMixerDevice *device)
{
- g_return_val_if_fail (MATE_MIXER_IS_DEVICE (device), NULL);
-
- if (device->priv->switches == NULL) {
- MateMixerDeviceClass *klass = MATE_MIXER_DEVICE_GET_CLASS (device);
-
- if (klass->list_switches != NULL)
- device->priv->switches = klass->list_switches (device);
- }
-
- return (const GList *) device->priv->switches;
-}
-
-/**
- * mate_mixer_device_list_profiles:
- * @device: a #MateMixerDevice
- */
-const GList *
-mate_mixer_device_list_profiles (MateMixerDevice *device)
-{
- g_return_val_if_fail (MATE_MIXER_IS_DEVICE (device), NULL);
-
- if (device->priv->profiles == NULL) {
- MateMixerDeviceClass *klass = MATE_MIXER_DEVICE_GET_CLASS (device);
-
- if (klass->list_profiles != NULL)
- device->priv->profiles = klass->list_profiles (device);
- }
+ MateMixerDeviceClass *klass;
- return (const GList *) device->priv->profiles;
-}
-
-/**
- * mate_mixer_device_get_active_profile:
- * @device: a #MateMixerDevice
- */
-MateMixerDeviceProfile *
-mate_mixer_device_get_active_profile (MateMixerDevice *device)
-{
g_return_val_if_fail (MATE_MIXER_IS_DEVICE (device), NULL);
- return device->priv->profile;
-}
-
-/**
- * mate_mixer_device_set_active_profile:
- * @device: a #MateMixerDevice
- * @profile: a #MateMixerDeviceProfile
- */
-gboolean
-mate_mixer_device_set_active_profile (MateMixerDevice *device,
- MateMixerDeviceProfile *profile)
-{
- g_return_val_if_fail (MATE_MIXER_IS_DEVICE (device), FALSE);
- g_return_val_if_fail (MATE_MIXER_IS_DEVICE_PROFILE (profile), FALSE);
-
- if (profile != device->priv->profile) {
- MateMixerDeviceClass *klass;
-
- klass = MATE_MIXER_DEVICE_GET_CLASS (device);
+ klass = MATE_MIXER_DEVICE_GET_CLASS (device);
- if (klass->set_active_profile == NULL ||
- klass->set_active_profile (device, profile) == FALSE)
- return FALSE;
+ if G_LIKELY (klass->list_switches != NULL)
+ return klass->list_switches (device);
- if (G_LIKELY (device->priv->profile != NULL))
- g_object_unref (device->priv->profile);
-
- device->priv->profile = g_object_ref (profile);
- }
-
- return TRUE;
+ return NULL;
}
static MateMixerStream *
@@ -503,23 +383,3 @@ mate_mixer_device_real_get_switch (MateMixerDevice *device, const gchar *name)
}
return NULL;
}
-
-static MateMixerDeviceProfile *
-mate_mixer_device_real_get_profile (MateMixerDevice *device, const gchar *name)
-{
- const GList *list;
-
- g_return_val_if_fail (MATE_MIXER_IS_DEVICE (device), NULL);
- g_return_val_if_fail (name != NULL, NULL);
-
- list = mate_mixer_device_list_profiles (device);
- while (list != NULL) {
- MateMixerDeviceProfile *profile = MATE_MIXER_DEVICE_PROFILE (list->data);
-
- if (strcmp (name, mate_mixer_device_profile_get_name (profile)) == 0)
- return profile;
-
- list = list->next;
- }
- return NULL;
-}
diff --git a/libmatemixer/matemixer-device.h b/libmatemixer/matemixer-device.h
index 885460c..51d2a14 100644
--- a/libmatemixer/matemixer-device.h
+++ b/libmatemixer/matemixer-device.h
@@ -21,7 +21,7 @@
#include <glib.h>
#include <glib-object.h>
-#include "matemixer-types.h"
+#include <libmatemixer/matemixer-types.h>
G_BEGIN_DECLS
@@ -41,6 +41,12 @@ G_BEGIN_DECLS
typedef struct _MateMixerDeviceClass MateMixerDeviceClass;
typedef struct _MateMixerDevicePrivate MateMixerDevicePrivate;
+/**
+ * MateMixerDevice:
+ *
+ * The #MateMixerDevice structure contains only private data and should only
+ * be accessed using the provided API.
+ */
struct _MateMixerDevice
{
GObject object;
@@ -49,59 +55,49 @@ struct _MateMixerDevice
MateMixerDevicePrivate *priv;
};
+/**
+ * MateMixerDeviceClass:
+ *
+ * The class structure of #MateMixerDevice.
+ */
struct _MateMixerDeviceClass
{
GObjectClass parent_class;
/*< private >*/
+ MateMixerStream *(*get_stream) (MateMixerDevice *device,
+ const gchar *name);
+ MateMixerSwitch *(*get_switch) (MateMixerDevice *device,
+ const gchar *name);
- MateMixerStream *(*get_stream) (MateMixerDevice *device,
- const gchar *name);
- MateMixerSwitch *(*get_switch) (MateMixerDevice *device,
- const gchar *name);
- MateMixerDeviceProfile *(*get_profile) (MateMixerDevice *device,
- const gchar *name);
-
- GList *(*list_streams) (MateMixerDevice *device);
- GList *(*list_switches) (MateMixerDevice *device);
- GList *(*list_profiles) (MateMixerDevice *device);
-
- gboolean (*set_active_profile) (MateMixerDevice *device,
- MateMixerDeviceProfile *profile);
+ const GList *(*list_streams) (MateMixerDevice *device);
+ const GList *(*list_switches) (MateMixerDevice *device);
/* Signals */
- void (*stream_added) (MateMixerDevice *device,
- const gchar *name);
- void (*stream_removed) (MateMixerDevice *device,
- const gchar *name);
- void (*switch_added) (MateMixerDevice *device,
- const gchar *name);
- void (*switch_removed) (MateMixerDevice *device,
- const gchar *name);
+ void (*stream_added) (MateMixerDevice *device,
+ const gchar *name);
+ void (*stream_removed) (MateMixerDevice *device,
+ const gchar *name);
+ void (*switch_added) (MateMixerDevice *device,
+ const gchar *name);
+ void (*switch_removed) (MateMixerDevice *device,
+ const gchar *name);
};
-GType mate_mixer_device_get_type (void) G_GNUC_CONST;
-
-const gchar * mate_mixer_device_get_name (MateMixerDevice *device);
-const gchar * mate_mixer_device_get_label (MateMixerDevice *device);
-const gchar * mate_mixer_device_get_icon (MateMixerDevice *device);
-
-MateMixerStream * mate_mixer_device_get_stream (MateMixerDevice *device,
- const gchar *name);
+GType mate_mixer_device_get_type (void) G_GNUC_CONST;
-MateMixerSwitch * mate_mixer_device_get_switch (MateMixerDevice *device,
- const gchar *name);
+const gchar * mate_mixer_device_get_name (MateMixerDevice *device);
+const gchar * mate_mixer_device_get_label (MateMixerDevice *device);
+const gchar * mate_mixer_device_get_icon (MateMixerDevice *device);
-MateMixerDeviceProfile *mate_mixer_device_get_profile (MateMixerDevice *device,
- const gchar *name);
+MateMixerStream *mate_mixer_device_get_stream (MateMixerDevice *device,
+ const gchar *name);
-const GList * mate_mixer_device_list_streams (MateMixerDevice *device);
-const GList * mate_mixer_device_list_switches (MateMixerDevice *device);
-const GList * mate_mixer_device_list_profiles (MateMixerDevice *device);
+MateMixerSwitch *mate_mixer_device_get_switch (MateMixerDevice *device,
+ const gchar *name);
-MateMixerDeviceProfile *mate_mixer_device_get_active_profile (MateMixerDevice *device);
-gboolean mate_mixer_device_set_active_profile (MateMixerDevice *device,
- MateMixerDeviceProfile *profile);
+const GList * mate_mixer_device_list_streams (MateMixerDevice *device);
+const GList * mate_mixer_device_list_switches (MateMixerDevice *device);
G_END_DECLS
diff --git a/libmatemixer/matemixer-enum-types.c b/libmatemixer/matemixer-enum-types.c
index 035be3d..ea63f50 100644
--- a/libmatemixer/matemixer-enum-types.c
+++ b/libmatemixer/matemixer-enum-types.c
@@ -53,6 +53,8 @@ mate_mixer_backend_type_get_type (void)
static const GEnumValue values[] = {
{ MATE_MIXER_BACKEND_UNKNOWN, "MATE_MIXER_BACKEND_UNKNOWN", "unknown" },
{ MATE_MIXER_BACKEND_PULSEAUDIO, "MATE_MIXER_BACKEND_PULSEAUDIO", "pulseaudio" },
+ { MATE_MIXER_BACKEND_ALSA, "MATE_MIXER_BACKEND_ALSA", "alsa" },
+ { MATE_MIXER_BACKEND_OSS, "MATE_MIXER_BACKEND_OSS", "oss" },
{ MATE_MIXER_BACKEND_NULL, "MATE_MIXER_BACKEND_NULL", "null" },
{ 0, NULL, NULL }
};
@@ -64,62 +66,39 @@ mate_mixer_backend_type_get_type (void)
}
GType
-mate_mixer_port_flags_get_type (void)
+mate_mixer_backend_flags_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
static const GFlagsValue values[] = {
- { MATE_MIXER_PORT_NO_FLAGS, "MATE_MIXER_PORT_NO_FLAGS", "no-flags" },
- { MATE_MIXER_PORT_AVAILABLE, "MATE_MIXER_PORT_AVAILABLE", "available" },
- { MATE_MIXER_PORT_INPUT, "MATE_MIXER_PORT_INPUT", "input" },
- { MATE_MIXER_PORT_OUTPUT, "MATE_MIXER_PORT_OUTPUT", "output" },
+ { MATE_MIXER_BACKEND_NO_FLAGS, "MATE_MIXER_STREAM_NO_FLAGS", "no-flags" },
+ { MATE_MIXER_BACKEND_HAS_APPLICATION_CONTROLS, "MATE_MIXER_BACKEND_HAS_APPLICATION_CONTROLS", "has-application-controls" },
+ { MATE_MIXER_BACKEND_CAN_SET_DEFAULT_INPUT_STREAM, "MATE_MIXER_BACKEND_CAN_SET_DEFAULT_INPUT_STREAM", "can-set-default-input-stream" },
+ { MATE_MIXER_BACKEND_CAN_SET_DEFAULT_OUTPUT_STREAM, "MATE_MIXER_BACKEND_CAN_SET_DEFAULT_OUTPUT_STREAM", "can-set-default-output-stream" },
{ 0, NULL, NULL }
};
etype = g_flags_register_static (
- g_intern_static_string ("MateMixerPortFlags"),
+ g_intern_static_string ("MateMixerBackendFlags"),
values);
}
return etype;
}
GType
-mate_mixer_stream_flags_get_type (void)
-{
- static GType etype = 0;
-
- if (etype == 0) {
- static const GFlagsValue values[] = {
- { MATE_MIXER_STREAM_NO_FLAGS, "MATE_MIXER_STREAM_NO_FLAGS", "no-flags" },
- { MATE_MIXER_STREAM_INPUT, "MATE_MIXER_STREAM_INPUT", "input" },
- { MATE_MIXER_STREAM_OUTPUT, "MATE_MIXER_STREAM_OUTPUT", "output" },
- { MATE_MIXER_STREAM_CLIENT, "MATE_MIXER_STREAM_CLIENT", "client" },
- { MATE_MIXER_STREAM_HAS_MONITOR, "MATE_MIXER_STREAM_HAS_MONITOR", "has-monitor" },
- { MATE_MIXER_STREAM_CAN_SUSPEND, "MATE_MIXER_STREAM_CAN_SUSPEND", "can-suspend" },
- { 0, NULL, NULL }
- };
- etype = g_flags_register_static (
- g_intern_static_string ("MateMixerStreamFlags"),
- values);
- }
- return etype;
-}
-
-GType
-mate_mixer_stream_state_get_type (void)
+mate_mixer_direction_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
static const GEnumValue values[] = {
- { MATE_MIXER_STREAM_STATE_UNKNOWN, "MATE_MIXER_STREAM_STATE_UNKNOWN", "unknown" },
- { MATE_MIXER_STREAM_STATE_RUNNING, "MATE_MIXER_STREAM_STATE_RUNNING", "running" },
- { MATE_MIXER_STREAM_STATE_IDLE, "MATE_MIXER_STREAM_STATE_IDLE", "idle" },
- { MATE_MIXER_STREAM_STATE_SUSPENDED, "MATE_MIXER_STREAM_STATE_SUSPENDED", "suspended" },
+ { MATE_MIXER_DIRECTION_UNKNOWN, "MATE_MIXER_DIRECTION_UNKNOWN", "unknown" },
+ { MATE_MIXER_DIRECTION_INPUT, "MATE_MIXER_DIRECTION_INPUT", "input" },
+ { MATE_MIXER_DIRECTION_OUTPUT, "MATE_MIXER_DIRECTION_OUTPUT", "output" },
{ 0, NULL, NULL }
};
etype = g_enum_register_static (
- g_intern_static_string ("MateMixerStreamState"),
+ g_intern_static_string ("MateMixerDirection"),
values);
}
return etype;
@@ -133,13 +112,16 @@ mate_mixer_stream_control_flags_get_type (void)
if (etype == 0) {
static const GFlagsValue values[] = {
{ MATE_MIXER_STREAM_CONTROL_NO_FLAGS, "MATE_MIXER_STREAM_CONTROL_NO_FLAGS", "no-flags" },
- { MATE_MIXER_STREAM_CONTROL_HAS_MUTE, "MATE_MIXER_STREAM_CONTROL_HAS_MUTE", "has-mute" },
- { MATE_MIXER_STREAM_CONTROL_HAS_VOLUME, "MATE_MIXER_STREAM_CONTROL_HAS_VOLUME", "has-volume" },
- { MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL, "MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL", "has-decibel" },
- { MATE_MIXER_STREAM_CONTROL_HAS_FLAT_VOLUME, "MATE_MIXER_STREAM_CONTROL_HAS_FLAT_VOLUME", "has-flat-volume" },
- { MATE_MIXER_STREAM_CONTROL_CAN_SET_VOLUME, "MATE_MIXER_STREAM_CONTROL_CAN_SET_VOLUME", "can-set-volume" },
+ { MATE_MIXER_STREAM_CONTROL_MUTE_READABLE, "MATE_MIXER_STREAM_CONTROL_MUTE_READABLE", "mute-readable" },
+ { MATE_MIXER_STREAM_CONTROL_MUTE_WRITABLE, "MATE_MIXER_STREAM_CONTROL_MUTE_WRITABLE", "mute-writable" },
+ { MATE_MIXER_STREAM_CONTROL_VOLUME_READABLE, "MATE_MIXER_STREAM_CONTROL_VOLUME_READABLE", "volume-readable" },
+ { MATE_MIXER_STREAM_CONTROL_VOLUME_WRITABLE, "MATE_MIXER_STREAM_CONTROL_VOLUME_WRITABLE", "volume-writable" },
{ MATE_MIXER_STREAM_CONTROL_CAN_BALANCE, "MATE_MIXER_STREAM_CONTROL_CAN_BALANCE", "can-balance" },
{ MATE_MIXER_STREAM_CONTROL_CAN_FADE, "MATE_MIXER_STREAM_CONTROL_CAN_FADE", "can-fade" },
+ { MATE_MIXER_STREAM_CONTROL_MOVABLE, "MATE_MIXER_STREAM_CONTROL_MOVABLE", "movable" },
+ { MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL, "MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL", "has-decibel" },
+ { MATE_MIXER_STREAM_CONTROL_HAS_MONITOR, "MATE_MIXER_STREAM_CONTROL_HAS_MONITOR", "has-monitor" },
+ { MATE_MIXER_STREAM_CONTROL_STORED, "MATE_MIXER_STREAM_CONTROL_STORED", "stored" },
{ 0, NULL, NULL }
};
etype = g_flags_register_static (
@@ -158,12 +140,17 @@ mate_mixer_stream_control_role_get_type (void)
static const GEnumValue values[] = {
{ MATE_MIXER_STREAM_CONTROL_ROLE_UNKNOWN, "MATE_MIXER_STREAM_CONTROL_ROLE_UNKNOWN", "unknown" },
{ MATE_MIXER_STREAM_CONTROL_ROLE_MASTER, "MATE_MIXER_STREAM_CONTROL_ROLE_MASTER", "master" },
- { MATE_MIXER_STREAM_CONTROL_ROLE_PORT, "MATE_MIXER_STREAM_CONTROL_ROLE_PORT", "port" },
+ { MATE_MIXER_STREAM_CONTROL_ROLE_APPLICATION, "MATE_MIXER_STREAM_CONTROL_ROLE_APPLICATION", "application" },
{ MATE_MIXER_STREAM_CONTROL_ROLE_PCM, "MATE_MIXER_STREAM_CONTROL_ROLE_PCM", "pcm" },
+ { MATE_MIXER_STREAM_CONTROL_ROLE_SPEAKER, "MATE_MIXER_STREAM_CONTROL_ROLE_SPEAKER", "speaker" },
+ { MATE_MIXER_STREAM_CONTROL_ROLE_MICROPHONE, "MATE_MIXER_STREAM_CONTROL_ROLE_MICROPHONE", "microphone" },
+ { MATE_MIXER_STREAM_CONTROL_ROLE_PORT, "MATE_MIXER_STREAM_CONTROL_ROLE_PORT", "port" },
+ { MATE_MIXER_STREAM_CONTROL_ROLE_BOOST, "MATE_MIXER_STREAM_CONTROL_ROLE_BOOST", "boost" },
{ MATE_MIXER_STREAM_CONTROL_ROLE_BASS, "MATE_MIXER_STREAM_CONTROL_ROLE_BASS", "bass" },
{ MATE_MIXER_STREAM_CONTROL_ROLE_TREBLE, "MATE_MIXER_STREAM_CONTROL_ROLE_TREBLE", "treble" },
{ MATE_MIXER_STREAM_CONTROL_ROLE_CD, "MATE_MIXER_STREAM_CONTROL_ROLE_CD", "cd" },
- { MATE_MIXER_STREAM_CONTROL_ROLE_SPEAKER, "MATE_MIXER_STREAM_CONTROL_ROLE_SPEAKER", "speaker" },
+ { MATE_MIXER_STREAM_CONTROL_ROLE_VIDEO, "MATE_MIXER_STREAM_CONTROL_ROLE_VIDEO", "video" },
+ { MATE_MIXER_STREAM_CONTROL_ROLE_MUSIC, "MATE_MIXER_STREAM_CONTROL_ROLE_MUSIC", "music" },
{ 0, NULL, NULL }
};
etype = g_enum_register_static (
@@ -174,47 +161,67 @@ mate_mixer_stream_control_role_get_type (void)
}
GType
-mate_mixer_client_stream_flags_get_type (void)
+mate_mixer_stream_control_media_role_get_type (void)
+{
+ static GType etype = 0;
+
+ if (etype == 0) {
+ static const GEnumValue values[] = {
+ { MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_UNKNOWN, "MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_UNKNOWN", "unknown" },
+ { MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_VIDEO, "MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_VIDEO", "video" },
+ { MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_MUSIC, "MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_MUSIC", "music" },
+ { MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_GAME, "MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_GAME", "game" },
+ { MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_EVENT, "MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_EVENT", "event" },
+ { MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_PHONE, "MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_PHONE", "phone" },
+ { MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_ANIMATION, "MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_ANIMATION", "animation" },
+ { MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_PRODUCTION, "MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_PRODUCTION", "production" },
+ { MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_A11Y, "MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_A11Y", "a11y" },
+ { MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_TEST, "MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_TEST", "test" },
+ { MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_ABSTRACT, "MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_ABSTRACT", "abstract" },
+ { MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_FILTER, "MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_FILTER", "filter" },
+ { 0, NULL, NULL }
+ };
+ etype = g_enum_register_static (
+ g_intern_static_string ("MateMixerStreamControlMediaRole"),
+ values);
+ }
+ return etype;
+}
+
+GType
+mate_mixer_switch_flags_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
static const GFlagsValue values[] = {
- { MATE_MIXER_CLIENT_STREAM_NO_FLAGS, "MATE_MIXER_CLIENT_STREAM_NO_FLAGS", "no-flags" },
- { MATE_MIXER_CLIENT_STREAM_APPLICATION, "MATE_MIXER_CLIENT_STREAM_APPLICATION", "application" },
- { MATE_MIXER_CLIENT_STREAM_CACHED, "MATE_MIXER_CLIENT_STREAM_CACHED", "cached" },
+ { MATE_MIXER_SWITCH_NO_FLAGS, "MATE_MIXER_SWITCH_NO_FLAGS", "no-flags" },
+ { MATE_MIXER_SWITCH_TOGGLE, "MATE_MIXER_SWITCH_TOGGLE", "toggle" },
+ { MATE_MIXER_SWITCH_ALLOWS_NO_ACTIVE_OPTION, "MATE_MIXER_SWITCH_ALLOWS_NO_ACTIVE_OPTION", "allows-no-active-option" },
{ 0, NULL, NULL }
};
etype = g_flags_register_static (
- g_intern_static_string ("MateMixerClientStreamFlags"),
+ g_intern_static_string ("MateMixerSwitchFlags"),
values);
}
return etype;
}
GType
-mate_mixer_client_stream_role_get_type (void)
+mate_mixer_switch_role_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
static const GEnumValue values[] = {
- { MATE_MIXER_CLIENT_STREAM_ROLE_NONE, "MATE_MIXER_CLIENT_STREAM_ROLE_NONE", "none" },
- { MATE_MIXER_CLIENT_STREAM_ROLE_VIDEO, "MATE_MIXER_CLIENT_STREAM_ROLE_VIDEO", "video" },
- { MATE_MIXER_CLIENT_STREAM_ROLE_MUSIC, "MATE_MIXER_CLIENT_STREAM_ROLE_MUSIC", "music" },
- { MATE_MIXER_CLIENT_STREAM_ROLE_GAME, "MATE_MIXER_CLIENT_STREAM_ROLE_GAME", "game" },
- { MATE_MIXER_CLIENT_STREAM_ROLE_EVENT, "MATE_MIXER_CLIENT_STREAM_ROLE_EVENT", "event" },
- { MATE_MIXER_CLIENT_STREAM_ROLE_PHONE, "MATE_MIXER_CLIENT_STREAM_ROLE_PHONE", "phone" },
- { MATE_MIXER_CLIENT_STREAM_ROLE_ANIMATION, "MATE_MIXER_CLIENT_STREAM_ROLE_ANIMATION", "animation" },
- { MATE_MIXER_CLIENT_STREAM_ROLE_PRODUCTION, "MATE_MIXER_CLIENT_STREAM_ROLE_PRODUCTION", "production" },
- { MATE_MIXER_CLIENT_STREAM_ROLE_A11Y, "MATE_MIXER_CLIENT_STREAM_ROLE_A11Y", "a11y" },
- { MATE_MIXER_CLIENT_STREAM_ROLE_TEST, "MATE_MIXER_CLIENT_STREAM_ROLE_TEST", "test" },
- { MATE_MIXER_CLIENT_STREAM_ROLE_ABSTRACT, "MATE_MIXER_CLIENT_STREAM_ROLE_ABSTRACT", "abstract" },
- { MATE_MIXER_CLIENT_STREAM_ROLE_FILTER, "MATE_MIXER_CLIENT_STREAM_ROLE_FILTER", "filter" },
+ { MATE_MIXER_SWITCH_ROLE_UNKNOWN, "MATE_MIXER_SWITCH_ROLE_UNKNOWN", "unknown" },
+ { MATE_MIXER_SWITCH_ROLE_DEVICE_PROFILE, "MATE_MIXER_SWITCH_ROLE_DEVICE_PROFILE", "device-profile" },
+ { MATE_MIXER_SWITCH_ROLE_PORT, "MATE_MIXER_SWITCH_ROLE_PORT", "port" },
+ { MATE_MIXER_SWITCH_ROLE_BOOST, "MATE_MIXER_SWITCH_ROLE_BOOST", "boost" },
{ 0, NULL, NULL }
};
etype = g_enum_register_static (
- g_intern_static_string ("MateMixerClientStreamRole"),
+ g_intern_static_string ("MateMixerSwitchRole"),
values);
}
return etype;
diff --git a/libmatemixer/matemixer-enum-types.h b/libmatemixer/matemixer-enum-types.h
index f2193be..f96dc85 100644
--- a/libmatemixer/matemixer-enum-types.h
+++ b/libmatemixer/matemixer-enum-types.h
@@ -34,26 +34,26 @@ GType mate_mixer_state_get_type (void) G_GNUC_CONST;
#define MATE_MIXER_TYPE_BACKEND_TYPE (mate_mixer_backend_type_get_type ())
GType mate_mixer_backend_type_get_type (void) G_GNUC_CONST;
-#define MATE_MIXER_TYPE_PORT_FLAGS (mate_mixer_port_flags_get_type ())
-GType mate_mixer_port_flags_get_type (void) G_GNUC_CONST;
+#define MATE_MIXER_TYPE_BACKEND_FLAGS (mate_mixer_backend_flags_get_type ())
+GType mate_mixer_backend_flags_get_type (void) G_GNUC_CONST;
-#define MATE_MIXER_TYPE_STREAM_FLAGS (mate_mixer_stream_flags_get_type ())
-GType mate_mixer_stream_flags_get_type (void) G_GNUC_CONST;
-
-#define MATE_MIXER_TYPE_STREAM_STATE (mate_mixer_stream_state_get_type ())
-GType mate_mixer_stream_state_get_type (void) G_GNUC_CONST;
+#define MATE_MIXER_TYPE_DIRECTION (mate_mixer_direction_get_type ())
+GType mate_mixer_direction_get_type (void) G_GNUC_CONST;
#define MATE_MIXER_TYPE_STREAM_CONTROL_FLAGS (mate_mixer_stream_control_flags_get_type ())
GType mate_mixer_stream_control_flags_get_type (void) G_GNUC_CONST;
#define MATE_MIXER_TYPE_STREAM_CONTROL_ROLE (mate_mixer_stream_control_role_get_type ())
-GType mate_mixer_stream_control_role_get_type (void);
+GType mate_mixer_stream_control_role_get_type (void) G_GNUC_CONST;
+
+#define MATE_MIXER_TYPE_STREAM_CONTROL_MEDIA_ROLE (mate_mixer_stream_control_media_role_get_type ())
+GType mate_mixer_stream_control_media_role_get_type (void) G_GNUC_CONST;
-#define MATE_MIXER_TYPE_CLIENT_STREAM_FLAGS (mate_mixer_client_stream_flags_get_type ())
-GType mate_mixer_client_stream_flags_get_type (void) G_GNUC_CONST;
+#define MATE_MIXER_TYPE_SWITCH_FLAGS (mate_mixer_switch_flags_get_type ())
+GType mate_mixer_switch_flags_get_type (void) G_GNUC_CONST;
-#define MATE_MIXER_TYPE_CLIENT_STREAM_ROLE (mate_mixer_client_stream_role_get_type ())
-GType mate_mixer_client_stream_role_get_type (void) G_GNUC_CONST;
+#define MATE_MIXER_TYPE_SWITCH_ROLE (mate_mixer_switch_role_get_type ())
+GType mate_mixer_switch_role_get_type (void) G_GNUC_CONST;
#define MATE_MIXER_TYPE_CHANNEL_POSITION (mate_mixer_channel_position_get_type ())
GType mate_mixer_channel_position_get_type (void) G_GNUC_CONST;
diff --git a/libmatemixer/matemixer-enums.h b/libmatemixer/matemixer-enums.h
index 8a88b1c..18bbbcf 100644
--- a/libmatemixer/matemixer-enums.h
+++ b/libmatemixer/matemixer-enums.h
@@ -63,59 +63,25 @@ typedef enum {
MATE_MIXER_BACKEND_NULL
} MateMixerBackendType;
+/**
+ * MateMixerBackendFlags:
+ */
+
typedef enum { /*< flags >*/
MATE_MIXER_BACKEND_NO_FLAGS = 0,
+ MATE_MIXER_BACKEND_HAS_APPLICATION_CONTROLS,
MATE_MIXER_BACKEND_CAN_SET_DEFAULT_INPUT_STREAM,
MATE_MIXER_BACKEND_CAN_SET_DEFAULT_OUTPUT_STREAM
} MateMixerBackendFlags;
/**
- * MateMixerPortFlags:
- * @MATE_MIXER_PORT_NO_FLAGS:
- * @MATE_MIXER_PORT_AVAILABLE:
- * @MATE_MIXER_PORT_INPUT:
- * @MATE_MIXER_PORT_OUTPUT:
- */
-typedef enum { /*< flags >*/
- MATE_MIXER_PORT_NO_FLAGS = 0,
- MATE_MIXER_PORT_AVAILABLE = 1 << 0,
- MATE_MIXER_PORT_INPUT = 1 << 1,
- MATE_MIXER_PORT_OUTPUT = 1 << 2
-} MateMixerPortFlags;
-
-/**
- * MateMixerStreamFlags:
- * @MATE_MIXER_STREAM_NO_FLAGS:
- * @MATE_MIXER_STREAM_INPUT:
- * @MATE_MIXER_STREAM_OUTPUT:
- * @MATE_MIXER_STREAM_CLIENT:
- * @MATE_MIXER_STREAM_HAS_MONITOR:
- * @MATE_MIXER_STREAM_CAN_SUSPEND:
- */
-typedef enum { /*< flags >*/
- MATE_MIXER_STREAM_NO_FLAGS = 0,
- MATE_MIXER_STREAM_INPUT = 1 << 0,
- MATE_MIXER_STREAM_OUTPUT = 1 << 1,
- MATE_MIXER_STREAM_CLIENT = 1 << 2,
- MATE_MIXER_STREAM_HAS_MONITOR = 1 << 3,
- MATE_MIXER_STREAM_CAN_SUSPEND = 1 << 4,
- MATE_MIXER_STREAM_PORTS_FIXED = 1 << 5,
- MATE_MIXER_STREAM_PORTS_EXCLUSIVE = 1 << 6,
-} MateMixerStreamFlags;
-
-/**
- * MateMixerStreamState:
- * @MATE_MIXER_STREAM_STATE_UNKNOWN:
- * @MATE_MIXER_STREAM_STATE_RUNNING:
- * @MATE_MIXER_STREAM_STATE_IDLE:
- * @MATE_MIXER_STREAM_STATE_SUSPENDED:
+ * MateMixerDirection:
*/
typedef enum {
- MATE_MIXER_STREAM_STATE_UNKNOWN,
- MATE_MIXER_STREAM_STATE_RUNNING,
- MATE_MIXER_STREAM_STATE_IDLE,
- MATE_MIXER_STREAM_STATE_SUSPENDED
-} MateMixerStreamState;
+ MATE_MIXER_DIRECTION_UNKNOWN,
+ MATE_MIXER_DIRECTION_INPUT,
+ MATE_MIXER_DIRECTION_OUTPUT,
+} MateMixerDirection;
/**
* MateMixerStreamControlFlags:
@@ -129,69 +95,62 @@ typedef enum {
* @MATE_MIXER_STREAM_CONTROL_CAN_FADE:
*/
typedef enum {
- MATE_MIXER_STREAM_CONTROL_NO_FLAGS = 0,
- MATE_MIXER_STREAM_CONTROL_HAS_MUTE = 1 << 0,
- MATE_MIXER_STREAM_CONTROL_HAS_VOLUME = 1 << 1,
- MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL = 1 << 2,
- MATE_MIXER_STREAM_CONTROL_HAS_FLAT_VOLUME = 1 << 3,
- MATE_MIXER_STREAM_CONTROL_CAN_SET_MUTE = 1 << 4,
- MATE_MIXER_STREAM_CONTROL_CAN_SET_VOLUME = 1 << 5,
- MATE_MIXER_STREAM_CONTROL_CAN_BALANCE = 1 << 6,
- MATE_MIXER_STREAM_CONTROL_CAN_FADE = 1 << 7
+ MATE_MIXER_STREAM_CONTROL_NO_FLAGS = 0,
+ MATE_MIXER_STREAM_CONTROL_MUTE_READABLE = 1 << 0,
+ MATE_MIXER_STREAM_CONTROL_MUTE_WRITABLE = 1 << 1,
+ MATE_MIXER_STREAM_CONTROL_VOLUME_READABLE = 1 << 2,
+ MATE_MIXER_STREAM_CONTROL_VOLUME_WRITABLE = 1 << 3,
+ MATE_MIXER_STREAM_CONTROL_CAN_BALANCE = 1 << 4,
+ MATE_MIXER_STREAM_CONTROL_CAN_FADE = 1 << 5,
+ MATE_MIXER_STREAM_CONTROL_MOVABLE = 1 << 6,
+ MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL = 1 << 7,
+ MATE_MIXER_STREAM_CONTROL_HAS_MONITOR = 1 << 8,
+ MATE_MIXER_STREAM_CONTROL_STORED = 1 << 9
} MateMixerStreamControlFlags;
typedef enum {
MATE_MIXER_STREAM_CONTROL_ROLE_UNKNOWN,
MATE_MIXER_STREAM_CONTROL_ROLE_MASTER,
- MATE_MIXER_STREAM_CONTROL_ROLE_PORT,
+ MATE_MIXER_STREAM_CONTROL_ROLE_APPLICATION,
MATE_MIXER_STREAM_CONTROL_ROLE_PCM,
+ MATE_MIXER_STREAM_CONTROL_ROLE_SPEAKER,
+ MATE_MIXER_STREAM_CONTROL_ROLE_MICROPHONE,
+ MATE_MIXER_STREAM_CONTROL_ROLE_PORT,
+ MATE_MIXER_STREAM_CONTROL_ROLE_BOOST,
MATE_MIXER_STREAM_CONTROL_ROLE_BASS,
MATE_MIXER_STREAM_CONTROL_ROLE_TREBLE,
MATE_MIXER_STREAM_CONTROL_ROLE_CD,
- MATE_MIXER_STREAM_CONTROL_ROLE_SPEAKER,
+ MATE_MIXER_STREAM_CONTROL_ROLE_VIDEO,
+ MATE_MIXER_STREAM_CONTROL_ROLE_MUSIC
} MateMixerStreamControlRole;
-/**
- * MateMixerClientStreamFlags:
- * @MATE_MIXER_CLIENT_STREAM_NO_FLAGS:
- * @MATE_MIXER_CLIENT_STREAM_APPLICATION:
- * @MATE_MIXER_CLIENT_STREAM_CACHED:
- */
+typedef enum {
+ MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_UNKNOWN,
+ MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_VIDEO,
+ MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_MUSIC,
+ MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_GAME,
+ MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_EVENT,
+ MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_PHONE,
+ MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_ANIMATION,
+ MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_PRODUCTION,
+ MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_A11Y,
+ MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_TEST,
+ MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_ABSTRACT,
+ MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_FILTER
+} MateMixerStreamControlMediaRole;
+
typedef enum { /*< flags >*/
- MATE_MIXER_CLIENT_STREAM_NO_FLAGS = 0,
- MATE_MIXER_CLIENT_STREAM_APPLICATION = 1 << 0,
- MATE_MIXER_CLIENT_STREAM_CACHED = 1 << 1,
-} MateMixerClientStreamFlags;
+ MATE_MIXER_SWITCH_NO_FLAGS = 0,
+ MATE_MIXER_SWITCH_TOGGLE = 1 << 0,
+ MATE_MIXER_SWITCH_ALLOWS_NO_ACTIVE_OPTION = 1 << 1
+} MateMixerSwitchFlags;
-/**
- * MateMixerClientStreamRole:
- * @MATE_MIXER_CLIENT_STREAM_ROLE_NONE:
- * @MATE_MIXER_CLIENT_STREAM_ROLE_VIDEO:
- * @MATE_MIXER_CLIENT_STREAM_ROLE_MUSIC:
- * @MATE_MIXER_CLIENT_STREAM_ROLE_GAME:
- * @MATE_MIXER_CLIENT_STREAM_ROLE_EVENT:
- * @MATE_MIXER_CLIENT_STREAM_ROLE_PHONE:
- * @MATE_MIXER_CLIENT_STREAM_ROLE_ANIMATION:
- * @MATE_MIXER_CLIENT_STREAM_ROLE_PRODUCTION:
- * @MATE_MIXER_CLIENT_STREAM_ROLE_A11Y:
- * @MATE_MIXER_CLIENT_STREAM_ROLE_TEST:
- * @MATE_MIXER_CLIENT_STREAM_ROLE_ABSTRACT:
- * @MATE_MIXER_CLIENT_STREAM_ROLE_FILTER:
- */
typedef enum {
- MATE_MIXER_CLIENT_STREAM_ROLE_NONE,
- MATE_MIXER_CLIENT_STREAM_ROLE_VIDEO,
- MATE_MIXER_CLIENT_STREAM_ROLE_MUSIC,
- MATE_MIXER_CLIENT_STREAM_ROLE_GAME,
- MATE_MIXER_CLIENT_STREAM_ROLE_EVENT,
- MATE_MIXER_CLIENT_STREAM_ROLE_PHONE,
- MATE_MIXER_CLIENT_STREAM_ROLE_ANIMATION,
- MATE_MIXER_CLIENT_STREAM_ROLE_PRODUCTION,
- MATE_MIXER_CLIENT_STREAM_ROLE_A11Y,
- MATE_MIXER_CLIENT_STREAM_ROLE_TEST,
- MATE_MIXER_CLIENT_STREAM_ROLE_ABSTRACT,
- MATE_MIXER_CLIENT_STREAM_ROLE_FILTER
-} MateMixerClientStreamRole;
+ MATE_MIXER_SWITCH_ROLE_UNKNOWN,
+ MATE_MIXER_SWITCH_ROLE_DEVICE_PROFILE,
+ MATE_MIXER_SWITCH_ROLE_PORT,
+ MATE_MIXER_SWITCH_ROLE_BOOST
+} MateMixerSwitchRole;
/**
* MateMixerChannelPosition:
diff --git a/libmatemixer/matemixer-private.h b/libmatemixer/matemixer-private.h
index 4229000..41cd2e7 100644
--- a/libmatemixer/matemixer-private.h
+++ b/libmatemixer/matemixer-private.h
@@ -20,12 +20,15 @@
#include <glib.h>
+#include "matemixer-enums.h"
+
+#include "matemixer-app-info-private.h"
+#include "matemixer-backend.h"
#include "matemixer-backend-module.h"
-#include "matemixer-backend-private.h"
-#include "matemixer-device-profile-private.h"
+#include "matemixer-stream-private.h"
#include "matemixer-stream-control-private.h"
-#include "matemixer-switch-option-private.h"
#include "matemixer-switch-private.h"
+#include "matemixer-switch-option-private.h"
G_BEGIN_DECLS
@@ -103,7 +106,9 @@ G_BEGIN_DECLS
#define MATE_MIXER_CHANNEL_MASK_HAS_FRONT(m) ((m) & MATE_MIXER_CHANNEL_MASK_FRONT)
#define MATE_MIXER_CHANNEL_MASK_HAS_BACK(m) ((m) & MATE_MIXER_CHANNEL_MASK_BACK)
-const GList *_mate_mixer_get_modules (void);
+G_GNUC_INTERNAL
+const GList *_mate_mixer_list_modules (void);
+
guint32 _mate_mixer_create_channel_mask (MateMixerChannelPosition *positions, guint n);
G_END_DECLS
diff --git a/libmatemixer/matemixer-stored-control.c b/libmatemixer/matemixer-stored-control.c
new file mode 100644
index 0000000..eb2a448
--- /dev/null
+++ b/libmatemixer/matemixer-stored-control.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "matemixer-enums.h"
+#include "matemixer-enum-types.h"
+#include "matemixer-stream-control.h"
+#include "matemixer-stored-control.h"
+
+G_DEFINE_INTERFACE (MateMixerStoredControl, mate_mixer_stored_control, MATE_MIXER_TYPE_STREAM_CONTROL)
+
+static void
+mate_mixer_stored_control_default_init (MateMixerStoredControlInterface *iface)
+{
+ g_object_interface_install_property (iface,
+ g_param_spec_enum ("direction",
+ "Direction",
+ "Direction of the stored control",
+ MATE_MIXER_TYPE_DIRECTION,
+ MATE_MIXER_DIRECTION_UNKNOWN,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+}
+
+/**
+ * mate_mixer_stored_control_get_direction:
+ * @control: a #MateMixerStoredControl
+ */
+MateMixerDirection
+mate_mixer_stored_control_get_direction (MateMixerStoredControl *control)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_STORED_CONTROL (control), MATE_MIXER_DIRECTION_UNKNOWN);
+
+ return MATE_MIXER_STORED_CONTROL_GET_INTERFACE (control)->get_direction (control);
+}
diff --git a/libmatemixer/matemixer-stored-control.h b/libmatemixer/matemixer-stored-control.h
new file mode 100644
index 0000000..0c9c982
--- /dev/null
+++ b/libmatemixer/matemixer-stored-control.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MATEMIXER_STORED_CONTROL_H
+#define MATEMIXER_STORED_CONTROL_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <libmatemixer/matemixer-enums.h>
+#include <libmatemixer/matemixer-types.h>
+
+G_BEGIN_DECLS
+
+#define MATE_MIXER_TYPE_STORED_CONTROL \
+ (mate_mixer_stored_control_get_type ())
+#define MATE_MIXER_STORED_CONTROL(o) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((o), MATE_MIXER_TYPE_STORED_CONTROL, MateMixerStoredControl))
+#define MATE_MIXER_IS_STORED_CONTROL(o) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((o), MATE_MIXER_TYPE_STORED_CONTROL))
+#define MATE_MIXER_STORED_CONTROL_GET_INTERFACE(o) \
+ (G_TYPE_INSTANCE_GET_INTERFACE ((o), MATE_MIXER_TYPE_STORED_CONTROL, MateMixerStoredControlInterface))
+
+typedef struct _MateMixerStoredControlInterface MateMixerStoredControlInterface;
+
+/**
+ * MateMixerStoredControlInterface:
+ *
+ * The interface structure of #MateMixerStoredControl.
+ */
+struct _MateMixerStoredControlInterface
+{
+ GTypeInterface parent_iface;
+
+ /*< private >*/
+ MateMixerDirection (*get_direction) (MateMixerStoredControl *control);
+};
+
+GType mate_mixer_stored_control_get_type (void) G_GNUC_CONST;
+
+MateMixerDirection mate_mixer_stored_control_get_direction (MateMixerStoredControl *control);
+
+G_END_DECLS
+
+#endif /* MATEMIXER_STORED_CONTROL_H */
diff --git a/libmatemixer/matemixer-stream-control-private.h b/libmatemixer/matemixer-stream-control-private.h
index 49454b3..7802d41 100644
--- a/libmatemixer/matemixer-stream-control-private.h
+++ b/libmatemixer/matemixer-stream-control-private.h
@@ -19,6 +19,7 @@
#define MATEMIXER_STREAM_CONTROL_PRIVATE_H
#include <glib.h>
+
#include "matemixer-enums.h"
#include "matemixer-types.h"
@@ -27,6 +28,9 @@ G_BEGIN_DECLS
void _mate_mixer_stream_control_set_flags (MateMixerStreamControl *control,
MateMixerStreamControlFlags flags);
+void _mate_mixer_stream_control_set_stream (MateMixerStreamControl *control,
+ MateMixerStream *stream);
+
void _mate_mixer_stream_control_set_mute (MateMixerStreamControl *control,
gboolean mute);
diff --git a/libmatemixer/matemixer-stream-control.c b/libmatemixer/matemixer-stream-control.c
index ace584a..b2b2dad 100644
--- a/libmatemixer/matemixer-stream-control.c
+++ b/libmatemixer/matemixer-stream-control.c
@@ -20,6 +20,7 @@
#include "matemixer-enums.h"
#include "matemixer-enum-types.h"
+#include "matemixer-stream.h"
#include "matemixer-stream-control.h"
#include "matemixer-stream-control-private.h"
@@ -30,13 +31,15 @@
struct _MateMixerStreamControlPrivate
{
- gchar *name;
- gchar *label;
- gboolean mute;
- gfloat balance;
- gfloat fade;
- MateMixerStreamControlFlags flags;
- MateMixerStreamControlRole role;
+ gchar *name;
+ gchar *label;
+ gboolean mute;
+ gfloat balance;
+ gfloat fade;
+ MateMixerStream *stream;
+ MateMixerStreamControlFlags flags;
+ MateMixerStreamControlRole role;
+ MateMixerStreamControlMediaRole media_role;
};
enum {
@@ -45,6 +48,8 @@ enum {
PROP_LABEL,
PROP_FLAGS,
PROP_ROLE,
+ PROP_MEDIA_ROLE,
+ PROP_STREAM,
PROP_MUTE,
PROP_VOLUME,
PROP_BALANCE,
@@ -54,6 +59,13 @@ enum {
static GParamSpec *properties[N_PROPERTIES] = { NULL, };
+enum {
+ MONITOR_VALUE,
+ N_SIGNALS
+};
+
+static guint signals[N_SIGNALS] = { 0, };
+
static void mate_mixer_stream_control_class_init (MateMixerStreamControlClass *klass);
static void mate_mixer_stream_control_get_property (GObject *object,
@@ -66,6 +78,7 @@ static void mate_mixer_stream_control_set_property (GObject
GParamSpec *pspec);
static void mate_mixer_stream_control_init (MateMixerStreamControl *control);
+static void mate_mixer_stream_control_dispose (GObject *object);
static void mate_mixer_stream_control_finalize (GObject *object);
G_DEFINE_ABSTRACT_TYPE (MateMixerStreamControl, mate_mixer_stream_control, G_TYPE_OBJECT)
@@ -76,6 +89,7 @@ mate_mixer_stream_control_class_init (MateMixerStreamControlClass *klass)
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass);
+ object_class->dispose = mate_mixer_stream_control_dispose;
object_class->finalize = mate_mixer_stream_control_finalize;
object_class->get_property = mate_mixer_stream_control_get_property;
object_class->set_property = mate_mixer_stream_control_set_property;
@@ -110,13 +124,32 @@ mate_mixer_stream_control_class_init (MateMixerStreamControlClass *klass)
properties[PROP_ROLE] =
g_param_spec_enum ("role",
- "Role",
- "Role of the stream control",
- MATE_MIXER_TYPE_STREAM_CONTROL_ROLE,
- MATE_MIXER_STREAM_CONTROL_ROLE_UNKNOWN,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS);
+ "Role",
+ "Role of the stream control",
+ MATE_MIXER_TYPE_STREAM_CONTROL_ROLE,
+ MATE_MIXER_STREAM_CONTROL_ROLE_UNKNOWN,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
+ properties[PROP_MEDIA_ROLE] =
+ g_param_spec_enum ("media-role",
+ "Media role",
+ "Media role of the stream control",
+ MATE_MIXER_TYPE_STREAM_CONTROL_MEDIA_ROLE,
+ MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_UNKNOWN,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
+ properties[PROP_STREAM] =
+ g_param_spec_object ("stream",
+ "Stream",
+ "Stream which owns the control",
+ MATE_MIXER_TYPE_STREAM,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
properties[PROP_MUTE] =
g_param_spec_boolean ("mute",
@@ -158,6 +191,18 @@ mate_mixer_stream_control_class_init (MateMixerStreamControlClass *klass)
g_object_class_install_properties (object_class, N_PROPERTIES, properties);
+ signals[MONITOR_VALUE] =
+ g_signal_new ("monitor-value",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (MateMixerStreamControlClass, monitor_value),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__DOUBLE,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_DOUBLE);
+
g_type_class_add_private (object_class, sizeof (MateMixerStreamControlPrivate));
}
@@ -184,6 +229,12 @@ mate_mixer_stream_control_get_property (GObject *object,
case PROP_ROLE:
g_value_set_enum (value, control->priv->role);
break;
+ case PROP_MEDIA_ROLE:
+ g_value_set_enum (value, control->priv->media_role);
+ break;
+ case PROP_STREAM:
+ g_value_set_object (value, control->priv->stream);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -216,6 +267,18 @@ mate_mixer_stream_control_set_property (GObject *object,
case PROP_ROLE:
control->priv->role = g_value_get_enum (value);
break;
+ case PROP_MEDIA_ROLE:
+ control->priv->media_role = g_value_get_enum (value);
+ break;
+ case PROP_STREAM:
+ /* Construct-only object */
+ control->priv->stream = g_value_get_object (value);
+
+ if (control->priv->stream != NULL) {
+ g_object_add_weak_pointer (G_OBJECT (control->priv->stream),
+ (gpointer *) &control->priv->stream);
+ }
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -232,6 +295,18 @@ mate_mixer_stream_control_init (MateMixerStreamControl *control)
}
static void
+mate_mixer_stream_control_dispose (GObject *object)
+{
+ MateMixerStreamControl *control;
+
+ control = MATE_MIXER_STREAM_CONTROL (object);
+
+ g_clear_object (&control->priv->stream);
+
+ G_OBJECT_CLASS (mate_mixer_stream_control_parent_class)->dispose (object);
+}
+
+static void
mate_mixer_stream_control_finalize (GObject *object)
{
MateMixerStreamControl *control;
@@ -244,6 +319,10 @@ mate_mixer_stream_control_finalize (GObject *object)
G_OBJECT_CLASS (mate_mixer_stream_control_parent_class)->finalize (object);
}
+/**
+ * mate_mixer_stream_control_get_name:
+ * @control: a #MateMixerStreamControl
+ */
const gchar *
mate_mixer_stream_control_get_name (MateMixerStreamControl *control)
{
@@ -252,6 +331,10 @@ mate_mixer_stream_control_get_name (MateMixerStreamControl *control)
return control->priv->name;
}
+/**
+ * mate_mixer_stream_control_get_label:
+ * @control: a #MateMixerStreamControl
+ */
const gchar *
mate_mixer_stream_control_get_label (MateMixerStreamControl *control)
{
@@ -260,6 +343,10 @@ mate_mixer_stream_control_get_label (MateMixerStreamControl *control)
return control->priv->label;
}
+/**
+ * mate_mixer_stream_control_get_flags:
+ * @control: a #MateMixerStreamControl
+ */
MateMixerStreamControlFlags
mate_mixer_stream_control_get_flags (MateMixerStreamControl *control)
{
@@ -268,6 +355,10 @@ mate_mixer_stream_control_get_flags (MateMixerStreamControl *control)
return control->priv->flags;
}
+/**
+ * mate_mixer_stream_control_get_role:
+ * @control: a #MateMixerStreamControl
+ */
MateMixerStreamControlRole
mate_mixer_stream_control_get_role (MateMixerStreamControl *control)
{
@@ -276,6 +367,79 @@ mate_mixer_stream_control_get_role (MateMixerStreamControl *control)
return control->priv->role;
}
+/**
+ * mate_mixer_stream_control_get_media_role:
+ * @control: a #MateMixerStreamControl
+ */
+MateMixerStreamControlMediaRole
+mate_mixer_stream_control_get_media_role (MateMixerStreamControl *control)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_UNKNOWN);
+
+ return control->priv->media_role;
+}
+
+/**
+ * mate_mixer_stream_control_get_app_info:
+ * @control: a #MateMixerStreamControl
+ */
+MateMixerAppInfo *
+mate_mixer_stream_control_get_app_info (MateMixerStreamControl *control)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), NULL);
+
+ if (control->priv->role == MATE_MIXER_STREAM_CONTROL_ROLE_APPLICATION) {
+ MateMixerStreamControlClass *klass;
+
+ klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
+
+ if G_LIKELY (klass->get_app_info != NULL)
+ return klass->get_app_info (control);
+ }
+ return NULL;
+}
+
+/**
+ * mate_mixer_stream_control_get_stream:
+ * @control: a #MateMixerStreamControl
+ */
+MateMixerStream *
+mate_mixer_stream_control_get_stream (MateMixerStreamControl *control)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), NULL);
+
+ return control->priv->stream;
+}
+
+/**
+ * mate_mixer_stream_control_set_stream:
+ * @control: a #MateMixerStreamControl
+ */
+gboolean
+mate_mixer_stream_control_set_stream (MateMixerStreamControl *control,
+ MateMixerStream *stream)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), 0);
+
+ if (control->priv->stream != stream) {
+ MateMixerStreamControlClass *klass;
+
+ klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
+
+ if (klass->set_stream == NULL ||
+ klass->set_stream (control, stream) == FALSE)
+ return FALSE;
+
+ _mate_mixer_stream_control_set_stream (control, stream);
+ }
+
+ return TRUE;
+}
+
+/**
+ * mate_mixer_stream_control_get_mute:
+ * @control: a #MateMixerStreamControl
+ */
gboolean
mate_mixer_stream_control_get_mute (MateMixerStreamControl *control)
{
@@ -284,6 +448,10 @@ mate_mixer_stream_control_get_mute (MateMixerStreamControl *control)
return control->priv->mute;
}
+/**
+ * mate_mixer_stream_control_set_mute:
+ * @control: a #MateMixerStreamControl
+ */
gboolean
mate_mixer_stream_control_set_mute (MateMixerStreamControl *control, gboolean mute)
{
@@ -292,17 +460,21 @@ mate_mixer_stream_control_set_mute (MateMixerStreamControl *control, gboolean mu
if (control->priv->mute == mute)
return TRUE;
- if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_HAS_MUTE) {
+ if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_MUTE_WRITABLE) {
MateMixerStreamControlClass *klass;
klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- if (G_LIKELY (klass->set_mute != NULL))
+ if G_LIKELY (klass->set_mute != NULL)
return klass->set_mute (control, mute);
}
return FALSE;
}
+/**
+ * mate_mixer_stream_control_get_num_channels:
+ * @control: a #MateMixerStreamControl
+ */
guint
mate_mixer_stream_control_get_num_channels (MateMixerStreamControl *control)
{
@@ -318,38 +490,50 @@ mate_mixer_stream_control_get_num_channels (MateMixerStreamControl *control)
return 0;
}
+/**
+ * mate_mixer_stream_control_get_volume:
+ * @control: a #MateMixerStreamControl
+ */
guint
mate_mixer_stream_control_get_volume (MateMixerStreamControl *control)
{
- g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), 0);
+ MateMixerStreamControlClass *klass;
- if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_HAS_VOLUME) {
- MateMixerStreamControlClass *klass;
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), 0);
- klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
+ klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
+ if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_VOLUME_READABLE) {
if G_LIKELY (klass->get_volume != NULL)
return klass->get_volume (control);
}
- return 0;
+ return klass->get_min_volume (control);
}
+/**
+ * mate_mixer_stream_control_set_volume:
+ * @control: a #MateMixerStreamControl
+ */
gboolean
mate_mixer_stream_control_set_volume (MateMixerStreamControl *control, guint volume)
{
g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), FALSE);
- if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_HAS_VOLUME) {
+ if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_VOLUME_WRITABLE) {
MateMixerStreamControlClass *klass;
klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- if (G_LIKELY (klass->set_volume != NULL))
+ if G_LIKELY (klass->set_volume != NULL)
return klass->set_volume (control, volume);
}
return FALSE;
}
+/**
+ * mate_mixer_stream_control_get_decibel:
+ * @control: a #MateMixerStreamControl
+ */
gdouble
mate_mixer_stream_control_get_decibel (MateMixerStreamControl *control)
{
@@ -360,28 +544,57 @@ mate_mixer_stream_control_get_decibel (MateMixerStreamControl *control)
klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- if (G_LIKELY (klass->get_decibel != NULL))
+ if G_LIKELY (klass->get_decibel != NULL)
return klass->get_decibel (control);
}
return -MATE_MIXER_INFINITY;
}
+/**
+ * mate_mixer_stream_control_set_decibel:
+ * @control: a #MateMixerStreamControl
+ */
gboolean
mate_mixer_stream_control_set_decibel (MateMixerStreamControl *control, gdouble decibel)
{
g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), FALSE);
- if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL) {
+ if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL &&
+ control->priv->flags & MATE_MIXER_STREAM_CONTROL_VOLUME_WRITABLE) {
MateMixerStreamControlClass *klass;
klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- if (G_LIKELY (klass->set_decibel != NULL))
+ if G_LIKELY (klass->set_decibel != NULL)
return klass->set_decibel (control, decibel);
}
return FALSE;
}
+/**
+ * mate_mixer_stream_control_has_channel_position:
+ * @control: a #MateMixerStreamControl
+ */
+gboolean
+mate_mixer_stream_control_has_channel_position (MateMixerStreamControl *control,
+ MateMixerChannelPosition position)
+{
+ MateMixerStreamControlClass *klass;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), FALSE);
+
+ klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
+
+ if (klass->has_channel_position != NULL)
+ return klass->has_channel_position (control, position);
+
+ return FALSE;
+}
+
+/**
+ * mate_mixer_stream_control_get_channel_position:
+ * @control: a #MateMixerStreamControl
+ */
MateMixerChannelPosition
mate_mixer_stream_control_get_channel_position (MateMixerStreamControl *control, guint channel)
{
@@ -397,22 +610,30 @@ mate_mixer_stream_control_get_channel_position (MateMixerStreamControl *control,
return MATE_MIXER_CHANNEL_UNKNOWN;
}
+/**
+ * mate_mixer_stream_control_get_channel_volume:
+ * @control: a #MateMixerStreamControl
+ */
guint
mate_mixer_stream_control_get_channel_volume (MateMixerStreamControl *control, guint channel)
{
g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), 0);
- if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_HAS_VOLUME) {
+ if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_VOLUME_READABLE) {
MateMixerStreamControlClass *klass;
klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- if (G_LIKELY (klass->get_channel_volume != NULL))
+ if G_LIKELY (klass->get_channel_volume != NULL)
return klass->get_channel_volume (control, channel);
}
return 0;
}
+/**
+ * mate_mixer_stream_control_set_channel_volume:
+ * @control: a #MateMixerStreamControl
+ */
gboolean
mate_mixer_stream_control_set_channel_volume (MateMixerStreamControl *control,
guint channel,
@@ -420,17 +641,21 @@ mate_mixer_stream_control_set_channel_volume (MateMixerStreamControl *control,
{
g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), FALSE);
- if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_HAS_VOLUME) {
+ if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_VOLUME_READABLE) {
MateMixerStreamControlClass *klass;
klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- if (G_LIKELY (klass->set_channel_volume != NULL))
+ if G_LIKELY (klass->set_channel_volume != NULL)
return klass->set_channel_volume (control, channel, volume);
}
return FALSE;
}
+/**
+ * mate_mixer_stream_control_get_channel_decibel:
+ * @control: a #MateMixerStreamControl
+ */
gdouble
mate_mixer_stream_control_get_channel_decibel (MateMixerStreamControl *control, guint channel)
{
@@ -441,12 +666,16 @@ mate_mixer_stream_control_get_channel_decibel (MateMixerStreamControl *control,
klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- if (G_LIKELY (klass->get_channel_decibel != NULL))
+ if G_LIKELY (klass->get_channel_decibel != NULL)
return klass->get_channel_decibel (control, channel);
}
return -MATE_MIXER_INFINITY;
}
+/**
+ * mate_mixer_stream_control_set_channel_decibel:
+ * @control: a #MateMixerStreamControl
+ */
gboolean
mate_mixer_stream_control_set_channel_decibel (MateMixerStreamControl *control,
guint channel,
@@ -459,28 +688,16 @@ mate_mixer_stream_control_set_channel_decibel (MateMixerStreamControl *control,
klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- if (G_LIKELY (klass->set_channel_decibel != NULL))
+ if G_LIKELY (klass->set_channel_decibel != NULL)
return klass->set_channel_decibel (control, channel, decibel);
}
return FALSE;
}
-gboolean
-mate_mixer_stream_control_has_channel_position (MateMixerStreamControl *control,
- MateMixerChannelPosition position)
-{
- MateMixerStreamControlClass *klass;
-
- g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), FALSE);
-
- klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
-
- if (klass->has_channel_position != NULL)
- return klass->has_channel_position (control, position);
-
- return FALSE;
-}
-
+/**
+ * mate_mixer_stream_control_get_balance:
+ * @control: a #MateMixerStreamControl
+ */
gfloat
mate_mixer_stream_control_get_balance (MateMixerStreamControl *control)
{
@@ -492,6 +709,10 @@ mate_mixer_stream_control_get_balance (MateMixerStreamControl *control)
return 0.0f;
}
+/**
+ * mate_mixer_stream_control_set_balance:
+ * @control: a #MateMixerStreamControl
+ */
gboolean
mate_mixer_stream_control_set_balance (MateMixerStreamControl *control, gfloat balance)
{
@@ -511,6 +732,10 @@ mate_mixer_stream_control_set_balance (MateMixerStreamControl *control, gfloat b
return FALSE;
}
+/**
+ * mate_mixer_stream_control_get_fade:
+ * @control: a #MateMixerStreamControl
+ */
gfloat
mate_mixer_stream_control_get_fade (MateMixerStreamControl *control)
{
@@ -522,6 +747,10 @@ mate_mixer_stream_control_get_fade (MateMixerStreamControl *control)
return 0.0f;
}
+/**
+ * mate_mixer_stream_control_set_fade:
+ * @control: a #MateMixerStreamControl
+ */
gboolean
mate_mixer_stream_control_set_fade (MateMixerStreamControl *control, gfloat fade)
{
@@ -535,12 +764,59 @@ mate_mixer_stream_control_set_fade (MateMixerStreamControl *control, gfloat fade
klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- if (G_LIKELY (klass->set_fade != NULL))
+ if (klass->set_fade != NULL)
return klass->set_fade (control, fade);
}
return FALSE;
}
+/**
+ * mate_mixer_stream_control_get_monitor_enabled:
+ * @control: a #MateMixerStreamControl
+ */
+gboolean
+mate_mixer_stream_control_get_monitor_enabled (MateMixerStreamControl *control)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), FALSE);
+
+ if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_HAS_MONITOR) {
+ MateMixerStreamControlClass *klass;
+
+ klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
+ if (klass->get_monitor_enabled != NULL)
+ return klass->get_monitor_enabled (control);
+ }
+
+ return FALSE;
+}
+
+/**
+ * mate_mixer_stream_control_set_monitor_enabled:
+ * @control: a #MateMixerStreamControl
+ */
+gboolean
+mate_mixer_stream_control_set_monitor_enabled (MateMixerStreamControl *control, gboolean enabled)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), FALSE);
+
+ if (enabled == mate_mixer_stream_control_get_monitor_enabled (control))
+ return TRUE;
+
+ if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_HAS_MONITOR) {
+ MateMixerStreamControlClass *klass;
+
+ klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
+ if (klass->set_monitor_enabled != NULL)
+ return klass->set_monitor_enabled (control, enabled);
+ }
+
+ return FALSE;
+}
+
+/**
+ * mate_mixer_stream_control_get_min_volume:
+ * @control: a #MateMixerStreamControl
+ */
guint
mate_mixer_stream_control_get_min_volume (MateMixerStreamControl *control)
{
@@ -556,6 +832,10 @@ mate_mixer_stream_control_get_min_volume (MateMixerStreamControl *control)
return 0;
}
+/**
+ * mate_mixer_stream_control_get_max_volume:
+ * @control: a #MateMixerStreamControl
+ */
guint
mate_mixer_stream_control_get_max_volume (MateMixerStreamControl *control)
{
@@ -571,6 +851,10 @@ mate_mixer_stream_control_get_max_volume (MateMixerStreamControl *control)
return 0;
}
+/**
+ * mate_mixer_stream_control_get_normal_volume:
+ * @control: a #MateMixerStreamControl
+ */
guint
mate_mixer_stream_control_get_normal_volume (MateMixerStreamControl *control)
{
@@ -586,6 +870,10 @@ mate_mixer_stream_control_get_normal_volume (MateMixerStreamControl *control)
return 0;
}
+/**
+ * mate_mixer_stream_control_get_base_volume:
+ * @control: a #MateMixerStreamControl
+ */
guint
mate_mixer_stream_control_get_base_volume (MateMixerStreamControl *control)
{
@@ -601,27 +889,77 @@ mate_mixer_stream_control_get_base_volume (MateMixerStreamControl *control)
return 0;
}
+/* Protected functions */
void
_mate_mixer_stream_control_set_flags (MateMixerStreamControl *control,
MateMixerStreamControlFlags flags)
{
+ g_return_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control));
+
+ if (control->priv->flags == flags)
+ return;
+
control->priv->flags = flags;
+
+ g_object_notify_by_pspec (G_OBJECT (control), properties[PROP_FLAGS]);
+}
+
+/* Protected functions */
+void
+_mate_mixer_stream_control_set_stream (MateMixerStreamControl *control,
+ MateMixerStream *stream)
+{
+ g_return_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control));
+
+ if (control->priv->stream == stream)
+ return;
+
+ if (control->priv->stream != NULL)
+ g_object_unref (control->priv->stream);
+
+ if (stream != NULL)
+ control->priv->stream = g_object_ref (stream);
+ else
+ control->priv->stream = NULL;
+
+ g_object_notify_by_pspec (G_OBJECT (control), properties[PROP_STREAM]);
}
void
_mate_mixer_stream_control_set_mute (MateMixerStreamControl *control, gboolean mute)
{
+ g_return_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control));
+
+ if (control->priv->mute == mute)
+ return;
+
control->priv->mute = mute;
+
+ g_object_notify_by_pspec (G_OBJECT (control), properties[PROP_MUTE]);
}
void
_mate_mixer_stream_control_set_balance (MateMixerStreamControl *control, gfloat balance)
{
+ g_return_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control));
+
+ if (control->priv->balance == balance)
+ return;
+
control->priv->balance = balance;
+
+ g_object_notify_by_pspec (G_OBJECT (control), properties[PROP_BALANCE]);
}
void
_mate_mixer_stream_control_set_fade (MateMixerStreamControl *control, gfloat fade)
{
+ g_return_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control));
+
+ if (control->priv->fade == fade)
+ return;
+
control->priv->fade = fade;
+
+ g_object_notify_by_pspec (G_OBJECT (control), properties[PROP_FADE]);
}
diff --git a/libmatemixer/matemixer-stream-control.h b/libmatemixer/matemixer-stream-control.h
index 51d7f95..2adf97f 100644
--- a/libmatemixer/matemixer-stream-control.h
+++ b/libmatemixer/matemixer-stream-control.h
@@ -49,6 +49,12 @@ G_BEGIN_DECLS
typedef struct _MateMixerStreamControlClass MateMixerStreamControlClass;
typedef struct _MateMixerStreamControlPrivate MateMixerStreamControlPrivate;
+/**
+ * MateMixerStreamControl:
+ *
+ * The #MateMixerStreamControl structure contains only private data and should only
+ * be accessed using the provided API.
+ */
struct _MateMixerStreamControl
{
GObject object;
@@ -57,103 +63,132 @@ struct _MateMixerStreamControl
MateMixerStreamControlPrivate *priv;
};
+/**
+ * MateMixerStreamControlClass:
+ *
+ * The class structure of #MateMixerStreamControl.
+ */
struct _MateMixerStreamControlClass
{
GObjectClass parent_class;
/*< private >*/
- gboolean (*set_mute) (MateMixerStreamControl *control,
- gboolean mute);
-
- guint (*get_num_channels) (MateMixerStreamControl *control);
-
- guint (*get_volume) (MateMixerStreamControl *control);
- gboolean (*set_volume) (MateMixerStreamControl *control,
- guint volume);
-
- gdouble (*get_decibel) (MateMixerStreamControl *control);
- gboolean (*set_decibel) (MateMixerStreamControl *control,
- gdouble decibel);
-
- gboolean (*has_channel_position) (MateMixerStreamControl *control,
- MateMixerChannelPosition position);
- MateMixerChannelPosition (*get_channel_position) (MateMixerStreamControl *control,
- guint channel);
-
- guint (*get_channel_volume) (MateMixerStreamControl *control,
- guint channel);
- gboolean (*set_channel_volume) (MateMixerStreamControl *control,
- guint channel,
- guint volume);
-
- gdouble (*get_channel_decibel) (MateMixerStreamControl *control,
- guint channel);
- gboolean (*set_channel_decibel) (MateMixerStreamControl *control,
- guint channel,
- gdouble decibel);
-
- gboolean (*set_balance) (MateMixerStreamControl *control,
- gfloat balance);
-
- gboolean (*set_fade) (MateMixerStreamControl *control,
- gfloat fade);
-
- guint (*get_min_volume) (MateMixerStreamControl *control);
- guint (*get_max_volume) (MateMixerStreamControl *control);
- guint (*get_normal_volume) (MateMixerStreamControl *control);
- guint (*get_base_volume) (MateMixerStreamControl *control);
+ MateMixerAppInfo * (*get_app_info) (MateMixerStreamControl *control);
+
+ gboolean (*set_stream) (MateMixerStreamControl *control,
+ MateMixerStream *stream);
+
+ gboolean (*set_mute) (MateMixerStreamControl *control,
+ gboolean mute);
+
+ guint (*get_num_channels) (MateMixerStreamControl *control);
+
+ guint (*get_volume) (MateMixerStreamControl *control);
+ gboolean (*set_volume) (MateMixerStreamControl *control,
+ guint volume);
+
+ gdouble (*get_decibel) (MateMixerStreamControl *control);
+ gboolean (*set_decibel) (MateMixerStreamControl *control,
+ gdouble decibel);
+
+ gboolean (*has_channel_position) (MateMixerStreamControl *control,
+ MateMixerChannelPosition position);
+ MateMixerChannelPosition (*get_channel_position) (MateMixerStreamControl *control,
+ guint channel);
+
+ guint (*get_channel_volume) (MateMixerStreamControl *control,
+ guint channel);
+ gboolean (*set_channel_volume) (MateMixerStreamControl *control,
+ guint channel,
+ guint volume);
+
+ gdouble (*get_channel_decibel) (MateMixerStreamControl *control,
+ guint channel);
+ gboolean (*set_channel_decibel) (MateMixerStreamControl *control,
+ guint channel,
+ gdouble decibel);
+
+ gboolean (*set_balance) (MateMixerStreamControl *control,
+ gfloat balance);
+
+ gboolean (*set_fade) (MateMixerStreamControl *control,
+ gfloat fade);
+
+ gboolean (*get_monitor_enabled) (MateMixerStreamControl *control);
+ gboolean (*set_monitor_enabled) (MateMixerStreamControl *control,
+ gboolean enabled);
+
+ guint (*get_min_volume) (MateMixerStreamControl *control);
+ guint (*get_max_volume) (MateMixerStreamControl *control);
+ guint (*get_normal_volume) (MateMixerStreamControl *control);
+ guint (*get_base_volume) (MateMixerStreamControl *control);
+
+ /* Signals */
+ void (*monitor_value) (MateMixerStreamControl *control,
+ gdouble value);
};
-GType mate_mixer_stream_control_get_type (void) G_GNUC_CONST;
+GType mate_mixer_stream_control_get_type (void) G_GNUC_CONST;
+
+const gchar * mate_mixer_stream_control_get_name (MateMixerStreamControl *control);
+const gchar * mate_mixer_stream_control_get_label (MateMixerStreamControl *control);
+MateMixerStreamControlFlags mate_mixer_stream_control_get_flags (MateMixerStreamControl *control);
+MateMixerStreamControlRole mate_mixer_stream_control_get_role (MateMixerStreamControl *control);
+MateMixerStreamControlMediaRole mate_mixer_stream_control_get_media_role (MateMixerStreamControl *control);
+
+MateMixerAppInfo * mate_mixer_stream_control_get_app_info (MateMixerStreamControl *control);
+
+MateMixerStream * mate_mixer_stream_control_get_stream (MateMixerStreamControl *control);
+gboolean mate_mixer_stream_control_set_stream (MateMixerStreamControl *control,
+ MateMixerStream *stream);
-const gchar * mate_mixer_stream_control_get_name (MateMixerStreamControl *control);
-const gchar * mate_mixer_stream_control_get_label (MateMixerStreamControl *control);
-MateMixerStreamControlFlags mate_mixer_stream_control_get_flags (MateMixerStreamControl *control);
-MateMixerStreamControlRole mate_mixer_stream_control_get_role (MateMixerStreamControl *control);
+gboolean mate_mixer_stream_control_get_mute (MateMixerStreamControl *control);
+gboolean mate_mixer_stream_control_set_mute (MateMixerStreamControl *control,
+ gboolean mute);
-gboolean mate_mixer_stream_control_get_mute (MateMixerStreamControl *control);
-gboolean mate_mixer_stream_control_set_mute (MateMixerStreamControl *control,
- gboolean mute);
+guint mate_mixer_stream_control_get_num_channels (MateMixerStreamControl *control);
-guint mate_mixer_stream_control_get_num_channels (MateMixerStreamControl *control);
+guint mate_mixer_stream_control_get_volume (MateMixerStreamControl *control);
+gboolean mate_mixer_stream_control_set_volume (MateMixerStreamControl *control,
+ guint volume);
-guint mate_mixer_stream_control_get_volume (MateMixerStreamControl *control);
-gboolean mate_mixer_stream_control_set_volume (MateMixerStreamControl *control,
- guint volume);
+gdouble mate_mixer_stream_control_get_decibel (MateMixerStreamControl *control);
+gboolean mate_mixer_stream_control_set_decibel (MateMixerStreamControl *control,
+ gdouble decibel);
-gdouble mate_mixer_stream_control_get_decibel (MateMixerStreamControl *control);
-gboolean mate_mixer_stream_control_set_decibel (MateMixerStreamControl *control,
- gdouble decibel);
+gboolean mate_mixer_stream_control_has_channel_position (MateMixerStreamControl *control,
+ MateMixerChannelPosition position);
+MateMixerChannelPosition mate_mixer_stream_control_get_channel_position (MateMixerStreamControl *control,
+ guint channel);
-gboolean mate_mixer_stream_control_has_channel_position (MateMixerStreamControl *control,
- MateMixerChannelPosition position);
-MateMixerChannelPosition mate_mixer_stream_control_get_channel_position (MateMixerStreamControl *control,
- guint channel);
+guint mate_mixer_stream_control_get_channel_volume (MateMixerStreamControl *control,
+ guint channel);
+gboolean mate_mixer_stream_control_set_channel_volume (MateMixerStreamControl *control,
+ guint channel,
+ guint volume);
-guint mate_mixer_stream_control_get_channel_volume (MateMixerStreamControl *control,
- guint channel);
-gboolean mate_mixer_stream_control_set_channel_volume (MateMixerStreamControl *control,
- guint channel,
- guint volume);
+gdouble mate_mixer_stream_control_get_channel_decibel (MateMixerStreamControl *control,
+ guint channel);
+gboolean mate_mixer_stream_control_set_channel_decibel (MateMixerStreamControl *control,
+ guint channel,
+ gdouble decibel);
-gdouble mate_mixer_stream_control_get_channel_decibel (MateMixerStreamControl *control,
- guint channel);
-gboolean mate_mixer_stream_control_set_channel_decibel (MateMixerStreamControl *control,
- guint channel,
- gdouble decibel);
+gfloat mate_mixer_stream_control_get_balance (MateMixerStreamControl *control);
+gboolean mate_mixer_stream_control_set_balance (MateMixerStreamControl *control,
+ gfloat balance);
-gfloat mate_mixer_stream_control_get_balance (MateMixerStreamControl *control);
-gboolean mate_mixer_stream_control_set_balance (MateMixerStreamControl *control,
- gfloat balance);
+gfloat mate_mixer_stream_control_get_fade (MateMixerStreamControl *control);
+gboolean mate_mixer_stream_control_set_fade (MateMixerStreamControl *control,
+ gfloat fade);
-gfloat mate_mixer_stream_control_get_fade (MateMixerStreamControl *control);
-gboolean mate_mixer_stream_control_set_fade (MateMixerStreamControl *control,
- gfloat fade);
+gboolean mate_mixer_stream_control_get_monitor_enabled (MateMixerStreamControl *control);
+gboolean mate_mixer_stream_control_set_monitor_enabled (MateMixerStreamControl *control,
+ gboolean enabled);
-guint mate_mixer_stream_control_get_min_volume (MateMixerStreamControl *control);
-guint mate_mixer_stream_control_get_max_volume (MateMixerStreamControl *control);
-guint mate_mixer_stream_control_get_normal_volume (MateMixerStreamControl *control);
-guint mate_mixer_stream_control_get_base_volume (MateMixerStreamControl *control);
+guint mate_mixer_stream_control_get_min_volume (MateMixerStreamControl *control);
+guint mate_mixer_stream_control_get_max_volume (MateMixerStreamControl *control);
+guint mate_mixer_stream_control_get_normal_volume (MateMixerStreamControl *control);
+guint mate_mixer_stream_control_get_base_volume (MateMixerStreamControl *control);
G_END_DECLS
diff --git a/libmatemixer/matemixer-stream-private.h b/libmatemixer/matemixer-stream-private.h
new file mode 100644
index 0000000..84243ae
--- /dev/null
+++ b/libmatemixer/matemixer-stream-private.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MATEMIXER_STREAM_PRIVATE_H
+#define MATEMIXER_STREAM_PRIVATE_H
+
+#include <glib.h>
+
+#include "matemixer-types.h"
+
+G_BEGIN_DECLS
+
+void _mate_mixer_stream_set_default_control (MateMixerStream *stream,
+ MateMixerStreamControl *control);
+
+G_END_DECLS
+
+#endif /* MATEMIXER_STREAM_PRIVATE_H */
diff --git a/libmatemixer/matemixer-stream.c b/libmatemixer/matemixer-stream.c
index 1902de3..03902bd 100644
--- a/libmatemixer/matemixer-stream.c
+++ b/libmatemixer/matemixer-stream.c
@@ -24,6 +24,7 @@
#include "matemixer-enum-types.h"
#include "matemixer-stream.h"
#include "matemixer-stream-control.h"
+#include "matemixer-stream-private.h"
#include "matemixer-switch.h"
/**
@@ -34,27 +35,29 @@
struct _MateMixerStreamPrivate
{
gchar *name;
- GList *controls;
- GList *switches;
- gboolean monitor_enabled;
+ gchar *label;
+ MateMixerDirection direction;
MateMixerDevice *device;
- MateMixerStreamFlags flags;
- MateMixerStreamState state;
+ MateMixerStreamControl *control;
};
enum {
PROP_0,
PROP_NAME,
+ PROP_LABEL,
+ PROP_DIRECTION,
PROP_DEVICE,
- PROP_FLAGS,
- PROP_STATE,
+ PROP_DEFAULT_CONTROL,
N_PROPERTIES
};
static GParamSpec *properties[N_PROPERTIES] = { NULL, };
enum {
- MONITOR_VALUE,
+ CONTROL_ADDED,
+ CONTROL_REMOVED,
+ SWITCH_ADDED,
+ SWITCH_REMOVED,
N_SIGNALS
};
@@ -105,6 +108,25 @@ mate_mixer_stream_class_init (MateMixerStreamClass *klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
+ properties[PROP_LABEL] =
+ g_param_spec_string ("label",
+ "Label",
+ "Label of the stream",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
+ properties[PROP_DIRECTION] =
+ g_param_spec_enum ("direction",
+ "Direction",
+ "Direction of the stream",
+ MATE_MIXER_TYPE_DIRECTION,
+ MATE_MIXER_DIRECTION_UNKNOWN,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
properties[PROP_DEVICE] =
g_param_spec_object ("device",
"Device",
@@ -114,39 +136,64 @@ mate_mixer_stream_class_init (MateMixerStreamClass *klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
- properties[PROP_FLAGS] =
- g_param_spec_flags ("flags",
- "Flags",
- "Capability flags of the stream",
- MATE_MIXER_TYPE_STREAM_FLAGS,
- MATE_MIXER_STREAM_NO_FLAGS,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS);
-
- properties[PROP_STATE] =
- g_param_spec_enum ("state",
- "State",
- "Current state of the stream",
- MATE_MIXER_TYPE_STREAM_STATE,
- MATE_MIXER_STREAM_STATE_UNKNOWN,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS);
+ properties[PROP_DEFAULT_CONTROL] =
+ g_param_spec_object ("default-control",
+ "Default control",
+ "Default control of the stream",
+ MATE_MIXER_TYPE_STREAM_CONTROL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPERTIES, properties);
- signals[MONITOR_VALUE] =
- g_signal_new ("monitor-value",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (MateMixerStreamClass, monitor_value),
+ signals[CONTROL_ADDED] =
+ g_signal_new ("control-added",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (MateMixerStreamClass, control_added),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING);
+
+ signals[CONTROL_REMOVED] =
+ g_signal_new ("control-removed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (MateMixerStreamClass, control_removed),
NULL,
NULL,
- g_cclosure_marshal_VOID__DOUBLE,
+ g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE,
1,
- G_TYPE_DOUBLE);
+ G_TYPE_STRING);
+
+ signals[SWITCH_ADDED] =
+ g_signal_new ("switch-added",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (MateMixerStreamClass, switch_added),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING);
+
+ signals[SWITCH_REMOVED] =
+ g_signal_new ("switch-removed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (MateMixerStreamClass, switch_removed),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING);
g_type_class_add_private (object_class, sizeof (MateMixerStreamPrivate));
}
@@ -165,14 +212,17 @@ mate_mixer_stream_get_property (GObject *object,
case PROP_NAME:
g_value_set_string (value, stream->priv->name);
break;
+ case PROP_LABEL:
+ g_value_set_string (value, stream->priv->label);
+ break;
+ case PROP_DIRECTION:
+ g_value_set_enum (value, stream->priv->direction);
+ break;
case PROP_DEVICE:
g_value_set_object (value, stream->priv->device);
break;
- case PROP_FLAGS:
- g_value_set_flags (value, stream->priv->flags);
- break;
- case PROP_STATE:
- g_value_set_enum (value, stream->priv->state);
+ case PROP_DEFAULT_CONTROL:
+ g_value_set_object (value, stream->priv->control);
break;
default:
@@ -196,15 +246,25 @@ mate_mixer_stream_set_property (GObject *object,
/* Construct-only string */
stream->priv->name = g_value_dup_string (value);
break;
+ case PROP_LABEL:
+ /* Construct-only string */
+ stream->priv->label = g_value_dup_string (value);
+ break;
+ case PROP_DIRECTION:
+ stream->priv->direction = g_value_get_enum (value);
+ break;
case PROP_DEVICE:
/* Construct-only object */
- stream->priv->device = g_value_dup_object (value);
- break;
- case PROP_FLAGS:
- stream->priv->flags = g_value_get_flags (value);
+ stream->priv->device = g_value_get_object (value);
+
+ if (stream->priv->device != NULL) {
+ g_object_add_weak_pointer (G_OBJECT (stream->priv->device),
+ (gpointer *) &stream->priv->device);
+ }
break;
- case PROP_STATE:
- stream->priv->state = g_value_get_enum (value);
+ case PROP_DEFAULT_CONTROL:
+ /* Construct-only object */
+ stream->priv->control = g_value_dup_object (value);
break;
default:
@@ -228,7 +288,7 @@ mate_mixer_stream_dispose (GObject *object)
stream = MATE_MIXER_STREAM (object);
- g_clear_object (&stream->priv->device);
+ g_clear_object (&stream->priv->control);
G_OBJECT_CLASS (mate_mixer_stream_parent_class)->dispose (object);
}
@@ -245,6 +305,10 @@ mate_mixer_stream_finalize (GObject *object)
G_OBJECT_CLASS (mate_mixer_stream_parent_class)->finalize (object);
}
+/**
+ * mate_mixer_stream_get_name:
+ * @stream: a #MateMixerStream
+ */
const gchar *
mate_mixer_stream_get_name (MateMixerStream *stream)
{
@@ -253,30 +317,46 @@ mate_mixer_stream_get_name (MateMixerStream *stream)
return stream->priv->name;
}
-MateMixerDevice *
-mate_mixer_stream_get_device (MateMixerStream *stream)
+/**
+ * mate_mixer_stream_get_label:
+ * @stream: a #MateMixerStream
+ */
+const gchar *
+mate_mixer_stream_get_label (MateMixerStream *stream)
{
g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), NULL);
- return stream->priv->device;
+ return stream->priv->label;
}
-MateMixerStreamFlags
-mate_mixer_stream_get_flags (MateMixerStream *stream)
+/**
+ * mate_mixer_stream_get_direction:
+ * @stream: a #MateMixerStream
+ */
+MateMixerDirection
+mate_mixer_stream_get_direction (MateMixerStream *stream)
{
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), MATE_MIXER_STREAM_NO_FLAGS);
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), MATE_MIXER_DIRECTION_UNKNOWN);
- return stream->priv->flags;
+ return stream->priv->direction;
}
-MateMixerStreamState
-mate_mixer_stream_get_state (MateMixerStream *stream)
+/**
+ * mate_mixer_stream_get_device:
+ * @stream: a #MateMixerStream
+ */
+MateMixerDevice *
+mate_mixer_stream_get_device (MateMixerStream *stream)
{
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), MATE_MIXER_STREAM_STATE_UNKNOWN);
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), NULL);
- return stream->priv->state;
+ return stream->priv->device;
}
+/**
+ * mate_mixer_stream_get_control:
+ * @stream: a #MateMixerStream
+ */
MateMixerStreamControl *
mate_mixer_stream_get_control (MateMixerStream *stream, const gchar *name)
{
@@ -286,6 +366,10 @@ mate_mixer_stream_get_control (MateMixerStream *stream, const gchar *name)
return MATE_MIXER_STREAM_GET_CLASS (stream)->get_control (stream, name);
}
+/**
+ * mate_mixer_stream_get_switch:
+ * @stream: a #MateMixerStream
+ */
MateMixerSwitch *
mate_mixer_stream_get_switch (MateMixerStream *stream, const gchar *name)
{
@@ -295,92 +379,40 @@ mate_mixer_stream_get_switch (MateMixerStream *stream, const gchar *name)
return MATE_MIXER_STREAM_GET_CLASS (stream)->get_switch (stream, name);
}
+/**
+ * mate_mixer_stream_get_default_control:
+ * @stream: a #MateMixerStream
+ */
MateMixerStreamControl *
mate_mixer_stream_get_default_control (MateMixerStream *stream)
{
g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), NULL);
- return MATE_MIXER_STREAM_GET_CLASS (stream)->get_default_control (stream);
+ return stream->priv->control;
}
+/**
+ * mate_mixer_stream_list_controls:
+ * @stream: a #MateMixerStream
+ */
const GList *
mate_mixer_stream_list_controls (MateMixerStream *stream)
{
g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), NULL);
- if (stream->priv->controls == NULL)
- stream->priv->controls = MATE_MIXER_STREAM_GET_CLASS (stream)->list_controls (stream);
-
- return (const GList *) stream->priv->controls;
+ return MATE_MIXER_STREAM_GET_CLASS (stream)->list_controls (stream);
}
+/**
+ * mate_mixer_stream_list_switches:
+ * @stream: a #MateMixerStream
+ */
const GList *
mate_mixer_stream_list_switches (MateMixerStream *stream)
{
g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), NULL);
- if (stream->priv->switches == NULL) {
- MateMixerStreamClass *klass = MATE_MIXER_STREAM_GET_CLASS (stream);
-
- if (klass->list_switches != NULL)
- stream->priv->switches = klass->list_switches (stream);
- }
-
- return (const GList *) stream->priv->switches;
-}
-
-gboolean
-mate_mixer_stream_suspend (MateMixerStream *stream)
-{
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), FALSE);
-
- if (stream->priv->state == MATE_MIXER_STREAM_STATE_SUSPENDED)
- return TRUE;
-
- if (stream->priv->flags & MATE_MIXER_STREAM_CAN_SUSPEND)
- return MATE_MIXER_STREAM_GET_CLASS (stream)->suspend (stream);
-
- return FALSE;
-}
-
-gboolean
-mate_mixer_stream_resume (MateMixerStream *stream)
-{
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), FALSE);
-
- if (stream->priv->state != MATE_MIXER_STREAM_STATE_SUSPENDED)
- return TRUE;
-
- if (stream->priv->flags & MATE_MIXER_STREAM_CAN_SUSPEND)
- return MATE_MIXER_STREAM_GET_CLASS (stream)->resume (stream);
-
- return FALSE;
-}
-
-gboolean
-mate_mixer_stream_monitor_get_enabled (MateMixerStream *stream)
-{
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), FALSE);
-
- return stream->priv->monitor_enabled;
-}
-
-gboolean
-mate_mixer_stream_monitor_set_enabled (MateMixerStream *stream, gboolean enabled)
-{
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), FALSE);
-
- if (stream->priv->monitor_enabled == enabled)
- return TRUE;
-
- if (stream->priv->flags & MATE_MIXER_STREAM_HAS_MONITOR) {
- if (enabled)
- return MATE_MIXER_STREAM_GET_CLASS (stream)->monitor_start (stream);
- else
- return MATE_MIXER_STREAM_GET_CLASS (stream)->monitor_stop (stream);
- }
-
- return FALSE;
+ return MATE_MIXER_STREAM_GET_CLASS (stream)->list_switches (stream);
}
static MateMixerStreamControl *
@@ -422,3 +454,34 @@ mate_mixer_stream_real_get_switch (MateMixerStream *stream, const gchar *name)
}
return NULL;
}
+
+void
+_mate_mixer_stream_set_default_control (MateMixerStream *stream,
+ MateMixerStreamControl *control)
+{
+ g_return_if_fail (MATE_MIXER_IS_STREAM (stream));
+ g_return_if_fail (control == NULL || MATE_MIXER_IS_STREAM_CONTROL (control));
+
+ if (stream->priv->control == control)
+ return;
+
+ if (stream->priv->control != NULL)
+ g_object_unref (stream->priv->control);
+
+ /* The default control is allowed to be NULL */
+ if (control != NULL) {
+ stream->priv->control = g_object_ref (control);
+
+ g_debug ("Stream %s default control changed to %s",
+ mate_mixer_stream_get_name (stream),
+ mate_mixer_stream_control_get_name (control));
+ } else {
+ stream->priv->control = NULL;
+
+ g_debug ("Stream %s default control unset",
+ mate_mixer_stream_get_name (stream));
+ }
+
+ g_object_notify_by_pspec (G_OBJECT (stream),
+ properties[PROP_DEFAULT_CONTROL]);
+}
diff --git a/libmatemixer/matemixer-stream.h b/libmatemixer/matemixer-stream.h
index e73579e..c030196 100644
--- a/libmatemixer/matemixer-stream.h
+++ b/libmatemixer/matemixer-stream.h
@@ -42,6 +42,12 @@ G_BEGIN_DECLS
typedef struct _MateMixerStreamClass MateMixerStreamClass;
typedef struct _MateMixerStreamPrivate MateMixerStreamPrivate;
+/**
+ * MateMixerStream:
+ *
+ * The #MateMixerStream structure contains only private data and should only
+ * be accessed using the provided API.
+ */
struct _MateMixerStream
{
GObject object;
@@ -50,39 +56,43 @@ struct _MateMixerStream
MateMixerStreamPrivate *priv;
};
+/**
+ * MateMixerStreamClass:
+ *
+ * The class structure of #MateMixerStream.
+ */
struct _MateMixerStreamClass
{
GObjectClass parent_class;
/*< private >*/
- MateMixerStreamControl *(*get_control) (MateMixerStream *stream,
- const gchar *name);
-
- MateMixerStreamControl *(*get_default_control) (MateMixerStream *stream);
-
- MateMixerSwitch *(*get_switch) (MateMixerStream *stream,
- const gchar *name);
+ MateMixerStreamControl *(*get_control) (MateMixerStream *stream,
+ const gchar *name);
+ MateMixerSwitch *(*get_switch) (MateMixerStream *stream,
+ const gchar *name);
- GList *(*list_controls) (MateMixerStream *stream);
- GList *(*list_switches) (MateMixerStream *stream);
-
- gboolean (*suspend) (MateMixerStream *stream);
- gboolean (*resume) (MateMixerStream *stream);
-
- gboolean (*monitor_start) (MateMixerStream *stream);
- gboolean (*monitor_stop) (MateMixerStream *stream);
+ const GList *(*list_controls) (MateMixerStream *stream);
+ const GList *(*list_switches) (MateMixerStream *stream);
/* Signals */
- void (*monitor_value) (MateMixerStream *stream, gdouble value);
+ void (*control_added) (MateMixerStream *stream,
+ const gchar *name);
+ void (*control_removed) (MateMixerStream *stream,
+ const gchar *name);
+
+ void (*switch_added) (MateMixerStream *stream,
+ const gchar *name);
+ void (*switch_removed) (MateMixerStream *stream,
+ const gchar *name);
};
GType mate_mixer_stream_get_type (void) G_GNUC_CONST;
const gchar * mate_mixer_stream_get_name (MateMixerStream *stream);
-MateMixerDevice * mate_mixer_stream_get_device (MateMixerStream *stream);
-MateMixerStreamFlags mate_mixer_stream_get_flags (MateMixerStream *stream);
-MateMixerStreamState mate_mixer_stream_get_state (MateMixerStream *stream);
+const gchar * mate_mixer_stream_get_label (MateMixerStream *stream);
+MateMixerDirection mate_mixer_stream_get_direction (MateMixerStream *stream);
+MateMixerDevice * mate_mixer_stream_get_device (MateMixerStream *stream);
MateMixerStreamControl *mate_mixer_stream_get_control (MateMixerStream *stream,
const gchar *name);
MateMixerSwitch * mate_mixer_stream_get_switch (MateMixerStream *stream,
@@ -93,13 +103,6 @@ MateMixerStreamControl *mate_mixer_stream_get_default_control (MateMixerStream *
const GList * mate_mixer_stream_list_controls (MateMixerStream *stream);
const GList * mate_mixer_stream_list_switches (MateMixerStream *stream);
-gboolean mate_mixer_stream_suspend (MateMixerStream *stream);
-gboolean mate_mixer_stream_resume (MateMixerStream *stream);
-
-gboolean mate_mixer_stream_monitor_get_enabled (MateMixerStream *stream);
-gboolean mate_mixer_stream_monitor_set_enabled (MateMixerStream *stream,
- gboolean enabled);
-
G_END_DECLS
#endif /* MATEMIXER_STREAM_H */
diff --git a/libmatemixer/matemixer-switch-option-private.h b/libmatemixer/matemixer-switch-option-private.h
index dea7583..d084dd5 100644
--- a/libmatemixer/matemixer-switch-option-private.h
+++ b/libmatemixer/matemixer-switch-option-private.h
@@ -20,7 +20,7 @@
#include <glib.h>
-#include "matemixer-switch-option.h"
+#include "matemixer-types.h"
G_BEGIN_DECLS
diff --git a/libmatemixer/matemixer-switch-option.c b/libmatemixer/matemixer-switch-option.c
index e924b46..fc0c5b6 100644
--- a/libmatemixer/matemixer-switch-option.c
+++ b/libmatemixer/matemixer-switch-option.c
@@ -121,6 +121,7 @@ mate_mixer_switch_option_get_property (GObject *object,
case PROP_ICON:
g_value_set_string (value, option->priv->icon);
break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -150,6 +151,7 @@ mate_mixer_switch_option_set_property (GObject *object,
/* Construct-only string */
option->priv->icon = g_value_dup_string (value);
break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
diff --git a/libmatemixer/matemixer-switch-option.h b/libmatemixer/matemixer-switch-option.h
index b02c42c..ae87718 100644
--- a/libmatemixer/matemixer-switch-option.h
+++ b/libmatemixer/matemixer-switch-option.h
@@ -20,6 +20,7 @@
#include <glib.h>
#include <glib-object.h>
+
#include <libmatemixer/matemixer-types.h>
G_BEGIN_DECLS
@@ -40,6 +41,12 @@ G_BEGIN_DECLS
typedef struct _MateMixerSwitchOptionClass MateMixerSwitchOptionClass;
typedef struct _MateMixerSwitchOptionPrivate MateMixerSwitchOptionPrivate;
+/**
+ * MateMixerSwitchOption:
+ *
+ * The #MateMixerSwitchOption structure contains only private data and should only
+ * be accessed using the provided API.
+ */
struct _MateMixerSwitchOption
{
GObject parent;
@@ -48,6 +55,11 @@ struct _MateMixerSwitchOption
MateMixerSwitchOptionPrivate *priv;
};
+/**
+ * MateMixerSwitchOptionClass:
+ *
+ * The class structure of #MateMixerSwitchOption.
+ */
struct _MateMixerSwitchOptionClass
{
GObjectClass parent_class;
diff --git a/libmatemixer/matemixer-switch-private.h b/libmatemixer/matemixer-switch-private.h
index 42390a9..bd4761e 100644
--- a/libmatemixer/matemixer-switch-private.h
+++ b/libmatemixer/matemixer-switch-private.h
@@ -19,6 +19,7 @@
#define MATEMIXER_SWITCH_PRIVATE_H
#include <glib.h>
+
#include "matemixer-types.h"
G_BEGIN_DECLS
diff --git a/libmatemixer/matemixer-switch.c b/libmatemixer/matemixer-switch.c
index b30e405..461b49e 100644
--- a/libmatemixer/matemixer-switch.c
+++ b/libmatemixer/matemixer-switch.c
@@ -34,7 +34,8 @@ struct _MateMixerSwitchPrivate
{
gchar *name;
gchar *label;
- GList *options;
+ MateMixerSwitchFlags flags;
+ MateMixerSwitchRole role;
MateMixerSwitchOption *active;
};
@@ -42,6 +43,8 @@ enum {
PROP_0,
PROP_NAME,
PROP_LABEL,
+ PROP_FLAGS,
+ PROP_ROLE,
PROP_ACTIVE_OPTION,
N_PROPERTIES
};
@@ -60,6 +63,7 @@ static void mate_mixer_switch_set_property (GObject *object,
GParamSpec *pspec);
static void mate_mixer_switch_init (MateMixerSwitch *swtch);
+static void mate_mixer_switch_dispose (GObject *object);
static void mate_mixer_switch_finalize (GObject *object);
G_DEFINE_ABSTRACT_TYPE (MateMixerSwitch, mate_mixer_switch, G_TYPE_OBJECT)
@@ -75,6 +79,7 @@ mate_mixer_switch_class_init (MateMixerSwitchClass *klass)
klass->get_option = mate_mixer_switch_real_get_option;
object_class = G_OBJECT_CLASS (klass);
+ object_class->dispose = mate_mixer_switch_dispose;
object_class->finalize = mate_mixer_switch_finalize;
object_class->get_property = mate_mixer_switch_get_property;
object_class->set_property = mate_mixer_switch_set_property;
@@ -97,12 +102,33 @@ mate_mixer_switch_class_init (MateMixerSwitchClass *klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
+ properties[PROP_ROLE] =
+ g_param_spec_enum ("role",
+ "Role",
+ "Role of the switch",
+ MATE_MIXER_TYPE_SWITCH_ROLE,
+ MATE_MIXER_SWITCH_ROLE_UNKNOWN,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
+ properties[PROP_FLAGS] =
+ g_param_spec_flags ("flags",
+ "Flags",
+ "Flags of the switch",
+ MATE_MIXER_TYPE_SWITCH_FLAGS,
+ MATE_MIXER_SWITCH_NO_FLAGS,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+
properties[PROP_ACTIVE_OPTION] =
g_param_spec_object ("active-option",
"Active option",
"Active option of the switch",
MATE_MIXER_TYPE_SWITCH_OPTION,
- G_PARAM_READABLE |
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPERTIES, properties);
@@ -127,6 +153,16 @@ mate_mixer_switch_get_property (GObject *object,
case PROP_LABEL:
g_value_set_string (value, swtch->priv->label);
break;
+ case PROP_FLAGS:
+ g_value_set_flags (value, swtch->priv->flags);
+ break;
+ case PROP_ROLE:
+ g_value_set_enum (value, swtch->priv->role);
+ break;
+ case PROP_ACTIVE_OPTION:
+ g_value_set_object (value, swtch->priv->active);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -152,6 +188,17 @@ mate_mixer_switch_set_property (GObject *object,
/* Construct-only string */
swtch->priv->label = g_value_dup_string (value);
break;
+ case PROP_FLAGS:
+ swtch->priv->flags = g_value_get_flags (value);
+ break;
+ case PROP_ROLE:
+ swtch->priv->role = g_value_get_enum (value);
+ break;
+ case PROP_ACTIVE_OPTION:
+ /* Construct-only object */
+ swtch->priv->active = g_value_dup_object (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -167,6 +214,18 @@ mate_mixer_switch_init (MateMixerSwitch *swtch)
}
static void
+mate_mixer_switch_dispose (GObject *object)
+{
+ MateMixerSwitch *swtch;
+
+ swtch = MATE_MIXER_SWITCH (object);
+
+ g_clear_object (&swtch->priv->active);
+
+ G_OBJECT_CLASS (mate_mixer_switch_parent_class)->dispose (object);
+}
+
+static void
mate_mixer_switch_finalize (GObject *object)
{
MateMixerSwitch *swtch;
@@ -179,6 +238,10 @@ mate_mixer_switch_finalize (GObject *object)
G_OBJECT_CLASS (mate_mixer_switch_parent_class)->finalize (object);
}
+/**
+ * mate_mixer_switch_get_name:
+ * @swtch: a #MateMixerSwitch
+ */
const gchar *
mate_mixer_switch_get_name (MateMixerSwitch *swtch)
{
@@ -187,6 +250,10 @@ mate_mixer_switch_get_name (MateMixerSwitch *swtch)
return swtch->priv->name;
}
+/**
+ * mate_mixer_switch_get_label:
+ * @swtch: a #MateMixerSwitch
+ */
const gchar *
mate_mixer_switch_get_label (MateMixerSwitch *swtch)
{
@@ -195,6 +262,34 @@ mate_mixer_switch_get_label (MateMixerSwitch *swtch)
return swtch->priv->label;
}
+/**
+ * mate_mixer_switch_get_flags:
+ * @swtch: a #MateMixerSwitch
+ */
+MateMixerSwitchFlags
+mate_mixer_switch_get_flags (MateMixerSwitch *swtch)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_SWITCH (swtch), MATE_MIXER_SWITCH_NO_FLAGS);
+
+ return swtch->priv->flags;
+}
+
+/**
+ * mate_mixer_switch_get_role:
+ * @swtch: a #MateMixerSwitch
+ */
+MateMixerSwitchRole
+mate_mixer_switch_get_role (MateMixerSwitch *swtch)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_SWITCH (swtch), MATE_MIXER_SWITCH_ROLE_UNKNOWN);
+
+ return swtch->priv->role;
+}
+
+/**
+ * mate_mixer_switch_get_option:
+ * @swtch: a #MateMixerSwitch
+ */
MateMixerSwitchOption *
mate_mixer_switch_get_option (MateMixerSwitch *swtch, const gchar *name)
{
@@ -203,6 +298,10 @@ mate_mixer_switch_get_option (MateMixerSwitch *swtch, const gchar *name)
return MATE_MIXER_SWITCH_GET_CLASS (swtch)->get_option (swtch, name);
}
+/**
+ * mate_mixer_switch_get_active_option:
+ * @swtch: a #MateMixerSwitch
+ */
MateMixerSwitchOption *
mate_mixer_switch_get_active_option (MateMixerSwitch *swtch)
{
@@ -211,45 +310,48 @@ mate_mixer_switch_get_active_option (MateMixerSwitch *swtch)
return swtch->priv->active;
}
+/**
+ * mate_mixer_switch_set_active_option:
+ * @swtch: a #MateMixerSwitch
+ */
gboolean
mate_mixer_switch_set_active_option (MateMixerSwitch *swtch,
MateMixerSwitchOption *option)
{
- MateMixerSwitchClass *klass;
-
g_return_val_if_fail (MATE_MIXER_IS_SWITCH (swtch), FALSE);
- klass = MATE_MIXER_SWITCH_GET_CLASS (swtch);
- if (klass->set_active_option != NULL) {
- if (klass->set_active_option (swtch, option) == FALSE)
+ if (swtch->priv->active != option) {
+ MateMixerSwitchClass *klass;
+
+ klass = MATE_MIXER_SWITCH_GET_CLASS (swtch);
+ if (klass->set_active_option == NULL ||
+ klass->set_active_option (swtch, option) == FALSE)
return FALSE;
_mate_mixer_switch_set_active_option (swtch, option);
- return TRUE;
}
- return FALSE;
+ return TRUE;
}
+/**
+ * mate_mixer_switch_get_name:
+ * @swtch: a #MateMixerSwitch
+ */
const GList *
mate_mixer_switch_list_options (MateMixerSwitch *swtch)
{
g_return_val_if_fail (MATE_MIXER_IS_SWITCH (swtch), NULL);
- if (swtch->priv->options == NULL) {
- MateMixerSwitchClass *klass = MATE_MIXER_SWITCH_GET_CLASS (swtch);
-
- if (klass->list_options != NULL)
- swtch->priv->options = klass->list_options (swtch);
- }
- return (const GList *) swtch->priv->options;
+ return MATE_MIXER_SWITCH_GET_CLASS (swtch)->list_options (swtch);
}
+/* Protected functions */
void
_mate_mixer_switch_set_active_option (MateMixerSwitch *swtch,
MateMixerSwitchOption *option)
{
g_return_if_fail (MATE_MIXER_IS_SWITCH (swtch));
- g_return_if_fail (MATE_MIXER_IS_SWITCH_OPTION (option));
+ g_return_if_fail (option == NULL || MATE_MIXER_IS_SWITCH_OPTION (option));
if (swtch->priv->active == option)
return;
@@ -257,9 +359,13 @@ _mate_mixer_switch_set_active_option (MateMixerSwitch *swtch,
if (swtch->priv->active != NULL)
g_object_unref (swtch->priv->active);
- swtch->priv->active = g_object_ref (option);
+ if (option != NULL)
+ swtch->priv->active = g_object_ref (option);
+ else
+ swtch->priv->active = NULL;
- g_object_notify_by_pspec (G_OBJECT (swtch), properties[PROP_ACTIVE_OPTION]);
+ g_object_notify_by_pspec (G_OBJECT (swtch),
+ properties[PROP_ACTIVE_OPTION]);
}
static MateMixerSwitchOption *
diff --git a/libmatemixer/matemixer-switch.h b/libmatemixer/matemixer-switch.h
index 3035607..7f0109f 100644
--- a/libmatemixer/matemixer-switch.h
+++ b/libmatemixer/matemixer-switch.h
@@ -21,6 +21,7 @@
#include <glib.h>
#include <glib-object.h>
+#include <libmatemixer/matemixer-enums.h>
#include <libmatemixer/matemixer-types.h>
G_BEGIN_DECLS
@@ -41,6 +42,12 @@ G_BEGIN_DECLS
typedef struct _MateMixerSwitchClass MateMixerSwitchClass;
typedef struct _MateMixerSwitchPrivate MateMixerSwitchPrivate;
+/**
+ * MateMixerSwitch:
+ *
+ * The #MateMixerSwitch structure contains only private data and should only
+ * be accessed using the provided API.
+ */
struct _MateMixerSwitch
{
GObject object;
@@ -49,6 +56,11 @@ struct _MateMixerSwitch
MateMixerSwitchPrivate *priv;
};
+/**
+ * MateMixerSwitchClass:
+ *
+ * The class structure of #MateMixerSwitch.
+ */
struct _MateMixerSwitchClass
{
GObjectClass parent_class;
@@ -57,26 +69,28 @@ struct _MateMixerSwitchClass
MateMixerSwitchOption *(*get_option) (MateMixerSwitch *swtch,
const gchar *name);
+ const GList *(*list_options) (MateMixerSwitch *swtch);
+
gboolean (*set_active_option) (MateMixerSwitch *swtch,
MateMixerSwitchOption *option);
-
- GList *(*list_options) (MateMixerSwitch *swtch);
};
GType mate_mixer_switch_get_type (void) G_GNUC_CONST;
const gchar * mate_mixer_switch_get_name (MateMixerSwitch *swtch);
const gchar * mate_mixer_switch_get_label (MateMixerSwitch *swtch);
+MateMixerSwitchFlags mate_mixer_switch_get_flags (MateMixerSwitch *swtch);
+MateMixerSwitchRole mate_mixer_switch_get_role (MateMixerSwitch *swtch);
MateMixerSwitchOption *mate_mixer_switch_get_option (MateMixerSwitch *swtch,
const gchar *name);
+const GList * mate_mixer_switch_list_options (MateMixerSwitch *swtch);
+
MateMixerSwitchOption *mate_mixer_switch_get_active_option (MateMixerSwitch *swtch);
gboolean mate_mixer_switch_set_active_option (MateMixerSwitch *swtch,
MateMixerSwitchOption *option);
-const GList * mate_mixer_switch_list_options (MateMixerSwitch *swtch);
-
G_END_DECLS
#endif /* MATEMIXER_SWITCH_H */
diff --git a/libmatemixer/matemixer-toggle.c b/libmatemixer/matemixer-toggle.c
index 2eea599..0db6e3b 100644
--- a/libmatemixer/matemixer-toggle.c
+++ b/libmatemixer/matemixer-toggle.c
@@ -30,6 +30,7 @@
struct _MateMixerTogglePrivate
{
+ GList *options;
MateMixerSwitchOption *on;
MateMixerSwitchOption *off;
};
@@ -63,7 +64,7 @@ G_DEFINE_ABSTRACT_TYPE (MateMixerToggle, mate_mixer_toggle, MATE_MIXER_TYPE_SWIT
static MateMixerSwitchOption *mate_mixer_toggle_get_option (MateMixerSwitch *swtch,
const gchar *name);
-static GList * mate_mixer_toggle_list_options (MateMixerSwitch *swtch);
+static const GList * mate_mixer_toggle_list_options (MateMixerSwitch *swtch);
static void
mate_mixer_toggle_class_init (MateMixerToggleClass *klass)
@@ -83,7 +84,7 @@ mate_mixer_toggle_class_init (MateMixerToggleClass *klass)
properties[PROP_STATE] =
g_param_spec_boolean ("state",
"State",
- "Current state",
+ "Current state of the toggle",
FALSE,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS);
@@ -131,6 +132,7 @@ mate_mixer_toggle_get_property (GObject *object,
case PROP_STATE_OPTION_OFF:
g_value_set_object (value, toggle->priv->off);
break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -156,6 +158,7 @@ mate_mixer_toggle_set_property (GObject *object,
/* Construct-only object */
toggle->priv->off = g_value_dup_object (value);
break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -177,12 +180,22 @@ mate_mixer_toggle_dispose (GObject *object)
toggle = MATE_MIXER_TOGGLE (object);
+ if (toggle->priv->options != NULL) {
+ g_list_free_full (toggle->priv->options, g_object_unref);
+ toggle->priv->options = NULL;
+ }
+
+ /* FIXME: crashes on ALSA without the polling thread */
g_clear_object (&toggle->priv->on);
g_clear_object (&toggle->priv->off);
G_OBJECT_CLASS (mate_mixer_toggle_parent_class)->dispose (object);
}
+/**
+ * mate_mixer_toggle_get_state:
+ * @toggle: a #MateMixerToggle
+ */
gboolean
mate_mixer_toggle_get_state (MateMixerToggle *toggle)
{
@@ -197,6 +210,10 @@ mate_mixer_toggle_get_state (MateMixerToggle *toggle)
return FALSE;
}
+/**
+ * mate_mixer_toggle_get_state_option:
+ * @toggle: a #MateMixerToggle
+ */
MateMixerSwitchOption *
mate_mixer_toggle_get_state_option (MateMixerToggle *toggle, gboolean state)
{
@@ -208,6 +225,10 @@ mate_mixer_toggle_get_state_option (MateMixerToggle *toggle, gboolean state)
return toggle->priv->off;
}
+/**
+ * mate_mixer_toggle_set_state:
+ * @toggle: a #MateMixerToggle
+ */
gboolean
mate_mixer_toggle_set_state (MateMixerToggle *toggle, gboolean state)
{
@@ -240,15 +261,20 @@ mate_mixer_toggle_get_option (MateMixerSwitch *swtch, const gchar *name)
return NULL;
}
-static GList *
+static const GList *
mate_mixer_toggle_list_options (MateMixerSwitch *swtch)
{
- GList *list = NULL;
+ MateMixerToggle *toggle;
g_return_val_if_fail (MATE_MIXER_IS_TOGGLE (swtch), NULL);
- list = g_list_prepend (list, MATE_MIXER_TOGGLE (swtch)->priv->off);
- list = g_list_prepend (list, MATE_MIXER_TOGGLE (swtch)->priv->on);
+ toggle = MATE_MIXER_TOGGLE (swtch);
- return list;
+ if (toggle->priv->options == NULL) {
+ toggle->priv->options = g_list_prepend (toggle->priv->options,
+ toggle->priv->off);
+ toggle->priv->options = g_list_prepend (toggle->priv->options,
+ toggle->priv->on);
+ }
+ return toggle->priv->options;
}
diff --git a/libmatemixer/matemixer-toggle.h b/libmatemixer/matemixer-toggle.h
index 1cedfc5..44946f7 100644
--- a/libmatemixer/matemixer-toggle.h
+++ b/libmatemixer/matemixer-toggle.h
@@ -25,22 +25,28 @@
G_BEGIN_DECLS
-#define MATE_MIXER_TYPE_TOGGLE \
+#define MATE_MIXER_TYPE_TOGGLE \
(mate_mixer_toggle_get_type ())
-#define MATE_MIXER_TOGGLE(o) \
+#define MATE_MIXER_TOGGLE(o) \
(G_TYPE_CHECK_INSTANCE_CAST ((o), MATE_MIXER_TYPE_TOGGLE, MateMixerToggle))
-#define MATE_MIXER_IS_TOGGLE(o) \
+#define MATE_MIXER_IS_TOGGLE(o) \
(G_TYPE_CHECK_INSTANCE_TYPE ((o), MATE_MIXER_TYPE_TOGGLE))
-#define MATE_MIXER_TOGGLE_CLASS(k) \
+#define MATE_MIXER_TOGGLE_CLASS(k) \
(G_TYPE_CHECK_CLASS_CAST ((k), MATE_MIXER_TYPE_TOGGLE, MateMixerToggleClass))
-#define MATE_MIXER_IS_TOGGLE_CLASS(k) \
+#define MATE_MIXER_IS_TOGGLE_CLASS(k) \
(G_TYPE_CHECK_CLASS_TYPE ((k), MATE_MIXER_TYPE_TOGGLE))
-#define MATE_MIXER_TOGGLE_GET_CLASS(o) \
+#define MATE_MIXER_TOGGLE_GET_CLASS(o) \
(G_TYPE_INSTANCE_GET_CLASS ((o), MATE_MIXER_TYPE_TOGGLE, MateMixerToggleClass))
typedef struct _MateMixerToggleClass MateMixerToggleClass;
typedef struct _MateMixerTogglePrivate MateMixerTogglePrivate;
+/**
+ * MateMixerToggle:
+ *
+ * The #MateMixerToggle structure contains only private data and should only
+ * be accessed using the provided API.
+ */
struct _MateMixerToggle
{
MateMixerSwitch object;
@@ -49,6 +55,11 @@ struct _MateMixerToggle
MateMixerTogglePrivate *priv;
};
+/**
+ * MateMixerToggleClass:
+ *
+ * The class structure of #MateMixerToggle.
+ */
struct _MateMixerToggleClass
{
MateMixerSwitchClass parent_class;
diff --git a/libmatemixer/matemixer-types.h b/libmatemixer/matemixer-types.h
index 6601a95..57a64a1 100644
--- a/libmatemixer/matemixer-types.h
+++ b/libmatemixer/matemixer-types.h
@@ -20,10 +20,11 @@
G_BEGIN_DECLS
+typedef struct _MateMixerAppInfo MateMixerAppInfo;
typedef struct _MateMixerDevice MateMixerDevice;
-typedef struct _MateMixerClientStream MateMixerClientStream;
typedef struct _MateMixerContext MateMixerContext;
typedef struct _MateMixerDeviceProfile MateMixerDeviceProfile;
+typedef struct _MateMixerStoredControl MateMixerStoredControl;
typedef struct _MateMixerStream MateMixerStream;
typedef struct _MateMixerStreamControl MateMixerStreamControl;
typedef struct _MateMixerSwitch MateMixerSwitch;
diff --git a/libmatemixer/matemixer.c b/libmatemixer/matemixer.c
index fa83e3f..a5bca6f 100644
--- a/libmatemixer/matemixer.c
+++ b/libmatemixer/matemixer.c
@@ -100,13 +100,14 @@ mate_mixer_is_initialized (void)
return initialized;
}
-/* Return a list of loaded backend modules */
+/* Internal: return a list of loaded backend modules */
const GList *
-_mate_mixer_get_modules (void)
+_mate_mixer_list_modules (void)
{
return (const GList *) modules;
}
+/* Internal: create a channel mask using the given list of channel positions */
guint32
_mate_mixer_create_channel_mask (MateMixerChannelPosition *positions, guint n)
{
diff --git a/libmatemixer/matemixer.h b/libmatemixer/matemixer.h
index a6eac79..589bf0d 100644
--- a/libmatemixer/matemixer.h
+++ b/libmatemixer/matemixer.h
@@ -21,11 +21,14 @@
#include <glib.h>
#include <glib-object.h>
-#include <libmatemixer/matemixer-client-stream.h>
+#include <libmatemixer/matemixer-types.h>
+
+#include <libmatemixer/matemixer-app-info.h>
#include <libmatemixer/matemixer-context.h>
#include <libmatemixer/matemixer-device.h>
-#include <libmatemixer/matemixer-device-profile.h>
#include <libmatemixer/matemixer-enums.h>
+#include <libmatemixer/matemixer-enum-types.h>
+#include <libmatemixer/matemixer-stored-control.h>
#include <libmatemixer/matemixer-stream.h>
#include <libmatemixer/matemixer-stream-control.h>
#include <libmatemixer/matemixer-switch.h>