summaryrefslogtreecommitdiff
path: root/libmatemixer
diff options
context:
space:
mode:
authorMichal Ratajsky <[email protected]>2014-07-18 15:41:59 +0200
committerMichal Ratajsky <[email protected]>2014-07-18 15:41:59 +0200
commit56c76128b0144a5c61e77d2a7aec07a337cfb66d (patch)
treef67ce44025881578cf6de3332064c214da176a23 /libmatemixer
parent85070f3b97a3213d75a7bebf86ad973aaa21c55b (diff)
downloadlibmatemixer-56c76128b0144a5c61e77d2a7aec07a337cfb66d.tar.bz2
libmatemixer-56c76128b0144a5c61e77d2a7aec07a337cfb66d.tar.xz
PulseAudio fixes and API updates
Diffstat (limited to 'libmatemixer')
-rw-r--r--libmatemixer/Makefile.am2
-rw-r--r--libmatemixer/matemixer-backend-module.c48
-rw-r--r--libmatemixer/matemixer-backend-module.h3
-rw-r--r--libmatemixer/matemixer-backend.c51
-rw-r--r--libmatemixer/matemixer-backend.h11
-rw-r--r--libmatemixer/matemixer-client-stream.c64
-rw-r--r--libmatemixer/matemixer-client-stream.h46
-rw-r--r--libmatemixer/matemixer-control.c517
-rw-r--r--libmatemixer/matemixer-control.h36
-rw-r--r--libmatemixer/matemixer-device-profile-private.h44
-rw-r--r--libmatemixer/matemixer-device-profile.c142
-rw-r--r--libmatemixer/matemixer-device-profile.h18
-rw-r--r--libmatemixer/matemixer-device.c99
-rw-r--r--libmatemixer/matemixer-device.h48
-rw-r--r--libmatemixer/matemixer-enum-types.c67
-rw-r--r--libmatemixer/matemixer-enum-types.h6
-rw-r--r--libmatemixer/matemixer-enums.h139
-rw-r--r--libmatemixer/matemixer-port-private.h45
-rw-r--r--libmatemixer/matemixer-port.c143
-rw-r--r--libmatemixer/matemixer-port.h16
-rw-r--r--libmatemixer/matemixer-stream.c103
-rw-r--r--libmatemixer/matemixer-stream.h129
-rw-r--r--libmatemixer/matemixer.c111
23 files changed, 1234 insertions, 654 deletions
diff --git a/libmatemixer/Makefile.am b/libmatemixer/Makefile.am
index 538592f..8c219d4 100644
--- a/libmatemixer/Makefile.am
+++ b/libmatemixer/Makefile.am
@@ -32,9 +32,11 @@ libmatemixer_la_SOURCES = \
matemixer-control.c \
matemixer-device.c \
matemixer-device-profile.c \
+ matemixer-device-profile-private.h \
matemixer-enum-types.c \
matemixer-enum-types.h \
matemixer-port.c \
+ matemixer-port-private.h \
matemixer-stream.c
libmatemixer_la_LIBADD = $(GLIB_LIBS)
diff --git a/libmatemixer/matemixer-backend-module.c b/libmatemixer/matemixer-backend-module.c
index e0707c1..a3146d2 100644
--- a/libmatemixer/matemixer-backend-module.c
+++ b/libmatemixer/matemixer-backend-module.c
@@ -36,24 +36,23 @@ struct _MateMixerBackendModulePrivate
enum {
PROP_0,
- PROP_PATH,
- N_PROPERTIES
+ PROP_PATH
};
-static void mate_mixer_backend_module_class_init (MateMixerBackendModuleClass *klass);
+static void mate_mixer_backend_module_class_init (MateMixerBackendModuleClass *klass);
-static void mate_mixer_backend_module_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec);
-static void mate_mixer_backend_module_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec);
+static void mate_mixer_backend_module_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void mate_mixer_backend_module_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec);
-static void mate_mixer_backend_module_init (MateMixerBackendModule *module);
-static void mate_mixer_backend_module_dispose (GObject *object);
-static void mate_mixer_backend_module_finalize (GObject *object);
+static void mate_mixer_backend_module_init (MateMixerBackendModule *module);
+static void mate_mixer_backend_module_dispose (GObject *object);
+static void mate_mixer_backend_module_finalize (GObject *object);
G_DEFINE_TYPE (MateMixerBackendModule, mate_mixer_backend_module, G_TYPE_TYPE_MODULE);
@@ -77,7 +76,7 @@ mate_mixer_backend_module_class_init (MateMixerBackendModuleClass *klass)
g_param_spec_string ("path",
"Path",
"File path to the module",
- 0,
+ NULL,
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
@@ -145,12 +144,13 @@ mate_mixer_backend_module_dispose (GObject *object)
module = MATE_MIXER_BACKEND_MODULE (object);
- if (module->priv->loaded) {
+ if (module->priv->loaded == TRUE) {
/* Keep the module alive and avoid calling the parent dispose, which
* would do the same thing and also produce a warning */
g_object_ref (object);
return;
}
+
G_OBJECT_CLASS (mate_mixer_backend_module_parent_class)->dispose (object);
}
@@ -199,6 +199,7 @@ const MateMixerBackendInfo *
mate_mixer_backend_module_get_info (MateMixerBackendModule *module)
{
g_return_val_if_fail (MATE_MIXER_IS_BACKEND_MODULE (module), NULL);
+ g_return_val_if_fail (module->priv->loaded == TRUE, NULL);
return module->priv->get_info ();
}
@@ -226,7 +227,7 @@ backend_module_load (GTypeModule *type_module)
module = MATE_MIXER_BACKEND_MODULE (type_module);
- if (!module->priv->loaded) {
+ if (module->priv->loaded == FALSE) {
module->priv->gmodule = g_module_open (module->priv->path,
G_MODULE_BIND_LAZY |
G_MODULE_BIND_LOCAL);
@@ -239,12 +240,12 @@ backend_module_load (GTypeModule *type_module)
}
/* Validate library symbols that each backend module must provide */
- if (!g_module_symbol (module->priv->gmodule,
- "backend_module_init",
- (gpointer *) &module->priv->init) ||
- !g_module_symbol (module->priv->gmodule,
- "backend_module_get_info",
- (gpointer *) &module->priv->get_info)) {
+ if (g_module_symbol (module->priv->gmodule,
+ "backend_module_init",
+ (gpointer *) &module->priv->init) == FALSE ||
+ g_module_symbol (module->priv->gmodule,
+ "backend_module_get_info",
+ (gpointer *) &module->priv->get_info) == FALSE) {
g_warning ("Failed to load backend module %s: %s",
module->priv->path,
g_module_error ());
@@ -283,6 +284,7 @@ backend_module_load (GTypeModule *type_module)
/* This function was called before, so avoid loading and initialize only */
module->priv->init (type_module);
}
+
return TRUE;
}
diff --git a/libmatemixer/matemixer-backend-module.h b/libmatemixer/matemixer-backend-module.h
index e654413..62b0a43 100644
--- a/libmatemixer/matemixer-backend-module.h
+++ b/libmatemixer/matemixer-backend-module.h
@@ -21,6 +21,8 @@
#include <glib.h>
#include <glib-object.h>
+#include "matemixer-enums.h"
+
G_BEGIN_DECLS
typedef struct {
@@ -63,6 +65,7 @@ struct _MateMixerBackendModuleClass
GType mate_mixer_backend_module_get_type (void) G_GNUC_CONST;
MateMixerBackendModule * mate_mixer_backend_module_new (const gchar *path);
+
const MateMixerBackendInfo *mate_mixer_backend_module_get_info (MateMixerBackendModule *module);
const gchar * mate_mixer_backend_module_get_path (MateMixerBackendModule *module);
diff --git a/libmatemixer/matemixer-backend.c b/libmatemixer/matemixer-backend.c
index 32f7f1b..be5c704 100644
--- a/libmatemixer/matemixer-backend.c
+++ b/libmatemixer/matemixer-backend.c
@@ -25,11 +25,11 @@
enum {
DEVICE_ADDED,
- DEVICE_CHANGED,
DEVICE_REMOVED,
STREAM_ADDED,
- STREAM_CHANGED,
STREAM_REMOVED,
+ CACHED_STREAM_ADDED,
+ CACHED_STREAM_REMOVED,
N_SIGNALS
};
@@ -77,11 +77,11 @@ mate_mixer_backend_default_init (MateMixerBackendInterface *iface)
1,
G_TYPE_STRING);
- signals[DEVICE_CHANGED] =
- g_signal_new ("device-changed",
+ signals[DEVICE_REMOVED] =
+ g_signal_new ("device-removed",
G_TYPE_FROM_INTERFACE (iface),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (MateMixerBackendInterface, device_changed),
+ G_STRUCT_OFFSET (MateMixerBackendInterface, device_removed),
NULL,
NULL,
g_cclosure_marshal_VOID__STRING,
@@ -89,11 +89,11 @@ mate_mixer_backend_default_init (MateMixerBackendInterface *iface)
1,
G_TYPE_STRING);
- signals[DEVICE_REMOVED] =
- g_signal_new ("device-removed",
+ signals[STREAM_ADDED] =
+ g_signal_new ("stream-added",
G_TYPE_FROM_INTERFACE (iface),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (MateMixerBackendInterface, device_removed),
+ G_STRUCT_OFFSET (MateMixerBackendInterface, stream_added),
NULL,
NULL,
g_cclosure_marshal_VOID__STRING,
@@ -101,11 +101,11 @@ mate_mixer_backend_default_init (MateMixerBackendInterface *iface)
1,
G_TYPE_STRING);
- signals[STREAM_ADDED] =
- g_signal_new ("stream-added",
+ signals[STREAM_REMOVED] =
+ g_signal_new ("stream-removed",
G_TYPE_FROM_INTERFACE (iface),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (MateMixerBackendInterface, stream_added),
+ G_STRUCT_OFFSET (MateMixerBackendInterface, stream_removed),
NULL,
NULL,
g_cclosure_marshal_VOID__STRING,
@@ -113,11 +113,11 @@ mate_mixer_backend_default_init (MateMixerBackendInterface *iface)
1,
G_TYPE_STRING);
- signals[STREAM_CHANGED] =
- g_signal_new ("stream-changed",
+ signals[CACHED_STREAM_ADDED] =
+ g_signal_new ("cached-stream-added",
G_TYPE_FROM_INTERFACE (iface),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (MateMixerBackendInterface, stream_changed),
+ G_STRUCT_OFFSET (MateMixerBackendInterface, cached_stream_added),
NULL,
NULL,
g_cclosure_marshal_VOID__STRING,
@@ -125,11 +125,11 @@ mate_mixer_backend_default_init (MateMixerBackendInterface *iface)
1,
G_TYPE_STRING);
- signals[STREAM_REMOVED] =
- g_signal_new ("stream-removed",
+ signals[CACHED_STREAM_REMOVED] =
+ g_signal_new ("cached-stream-removed",
G_TYPE_FROM_INTERFACE (iface),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (MateMixerBackendInterface, stream_removed),
+ G_STRUCT_OFFSET (MateMixerBackendInterface, cached_stream_removed),
NULL,
NULL,
g_cclosure_marshal_VOID__STRING,
@@ -156,6 +156,7 @@ mate_mixer_backend_open (MateMixerBackend *backend)
{
g_return_val_if_fail (MATE_MIXER_IS_BACKEND (backend), FALSE);
+ /* Implementation required */
return MATE_MIXER_BACKEND_GET_INTERFACE (backend)->open (backend);
}
@@ -177,6 +178,7 @@ mate_mixer_backend_get_state (MateMixerBackend *backend)
{
g_return_val_if_fail (MATE_MIXER_IS_BACKEND (backend), MATE_MIXER_STATE_UNKNOWN);
+ /* Implementation required */
return MATE_MIXER_BACKEND_GET_INTERFACE (backend)->get_state (backend);
}
@@ -210,6 +212,21 @@ mate_mixer_backend_list_streams (MateMixerBackend *backend)
return NULL;
}
+GList *
+mate_mixer_backend_list_cached_streams (MateMixerBackend *backend)
+{
+ MateMixerBackendInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_BACKEND (backend), NULL);
+
+ iface = MATE_MIXER_BACKEND_GET_INTERFACE (backend);
+
+ if (iface->list_cached_streams)
+ return iface->list_cached_streams (backend);
+
+ return NULL;
+}
+
MateMixerStream *
mate_mixer_backend_get_default_input_stream (MateMixerBackend *backend)
{
diff --git a/libmatemixer/matemixer-backend.h b/libmatemixer/matemixer-backend.h
index 559f256..8bedfe0 100644
--- a/libmatemixer/matemixer-backend.h
+++ b/libmatemixer/matemixer-backend.h
@@ -52,6 +52,7 @@ struct _MateMixerBackendInterface
GTypeInterface parent_iface;
/*< private >*/
+ /* Virtual table */
void (*set_data) (MateMixerBackend *backend,
const MateMixerBackendData *data);
@@ -62,6 +63,7 @@ struct _MateMixerBackendInterface
GList *(*list_devices) (MateMixerBackend *backend);
GList *(*list_streams) (MateMixerBackend *backend);
+ GList *(*list_cached_streams) (MateMixerBackend *backend);
MateMixerStream *(*get_default_input_stream) (MateMixerBackend *backend);
gboolean (*set_default_input_stream) (MateMixerBackend *backend,
@@ -74,16 +76,16 @@ struct _MateMixerBackendInterface
/* Signals */
void (*device_added) (MateMixerBackend *backend,
const gchar *name);
- void (*device_changed) (MateMixerBackend *backend,
- const gchar *name);
void (*device_removed) (MateMixerBackend *backend,
const gchar *name);
void (*stream_added) (MateMixerBackend *backend,
const gchar *name);
- void (*stream_changed) (MateMixerBackend *backend,
- const gchar *name);
void (*stream_removed) (MateMixerBackend *backend,
const gchar *name);
+ void (*cached_stream_added) (MateMixerBackend *backend,
+ const gchar *name);
+ void (*cached_stream_removed) (MateMixerBackend *backend,
+ const gchar *name);
};
GType mate_mixer_backend_get_type (void) G_GNUC_CONST;
@@ -98,6 +100,7 @@ MateMixerState mate_mixer_backend_get_state (MateMixerBackend
GList * mate_mixer_backend_list_devices (MateMixerBackend *backend);
GList * mate_mixer_backend_list_streams (MateMixerBackend *backend);
+GList * mate_mixer_backend_list_cached_streams (MateMixerBackend *backend);
MateMixerStream *mate_mixer_backend_get_default_input_stream (MateMixerBackend *backend);
gboolean mate_mixer_backend_set_default_input_stream (MateMixerBackend *backend,
diff --git a/libmatemixer/matemixer-client-stream.c b/libmatemixer/matemixer-client-stream.c
index 74b3e15..3ff3c54 100644
--- a/libmatemixer/matemixer-client-stream.c
+++ b/libmatemixer/matemixer-client-stream.c
@@ -19,11 +19,13 @@
#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: An interface providing extra functionality for client streams
+ * @short_description: Interface providing extra functionality for client streams
* @see_also: #MateMixerStream
* @include: libmatemixer/matemixer.h
*
@@ -39,6 +41,24 @@ static void
mate_mixer_client_stream_default_init (MateMixerClientStreamInterface *iface)
{
g_object_interface_install_property (iface,
+ 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));
+
+ g_object_interface_install_property (iface,
+ 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));
+
+ g_object_interface_install_property (iface,
g_param_spec_object ("parent",
"Parent",
"Parent stream of the client stream",
@@ -80,12 +100,52 @@ mate_mixer_client_stream_default_init (MateMixerClientStreamInterface *iface)
}
/**
+ * mate_mixer_client_stream_get_flags:
+ * @client: a #MateMixerClientStream
+ *
+ */
+MateMixerClientStreamFlags
+mate_mixer_client_stream_get_flags (MateMixerClientStream *client)
+{
+ MateMixerClientStreamInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), MATE_MIXER_CLIENT_STREAM_NO_FLAGS);
+
+ iface = MATE_MIXER_CLIENT_STREAM_GET_INTERFACE (client);
+
+ if (iface->get_flags)
+ return iface->get_flags (client);
+
+ return MATE_MIXER_CLIENT_STREAM_NO_FLAGS;
+}
+
+/**
+ * mate_mixer_client_stream_get_role:
+ * @client: a #MateMixerClientStream
+ *
+ */
+MateMixerClientStreamRole
+mate_mixer_client_stream_get_role (MateMixerClientStream *client)
+{
+ MateMixerClientStreamInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), MATE_MIXER_CLIENT_STREAM_ROLE_NONE);
+
+ iface = MATE_MIXER_CLIENT_STREAM_GET_INTERFACE (client);
+
+ if (iface->get_role)
+ return iface->get_role (client);
+
+ return MATE_MIXER_CLIENT_STREAM_ROLE_NONE;
+}
+
+/**
* mate_mixer_client_stream_get_parent:
* @client: a #MateMixerClientStream
*
* Gets the parent stream of the client stream.
*
- * Returns: a #MateMixerStream or %NULL on failure.
+ * Returns: a #MateMixerStream or %NULL if the parent stream is not known.
*/
MateMixerStream *
mate_mixer_client_stream_get_parent (MateMixerClientStream *client)
diff --git a/libmatemixer/matemixer-client-stream.h b/libmatemixer/matemixer-client-stream.h
index 1375cb3..fae5934 100644
--- a/libmatemixer/matemixer-client-stream.h
+++ b/libmatemixer/matemixer-client-stream.h
@@ -21,6 +21,7 @@
#include <glib.h>
#include <glib-object.h>
+#include <libmatemixer/matemixer-enums.h>
#include <libmatemixer/matemixer-stream.h>
G_BEGIN_DECLS
@@ -42,26 +43,37 @@ struct _MateMixerClientStreamInterface
GTypeInterface parent_iface;
/*< private >*/
- 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);
+ /* Virtual table */
+ 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;
-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);
+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);
+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
diff --git a/libmatemixer/matemixer-control.c b/libmatemixer/matemixer-control.c
index 6aac624..b501f1e 100644
--- a/libmatemixer/matemixer-control.c
+++ b/libmatemixer/matemixer-control.c
@@ -31,6 +31,7 @@
/**
* SECTION:matemixer-control
+ * @short_description:The main class for interfacing with the library
* @include: libmatemixer/matemixer.h
*/
@@ -38,6 +39,7 @@ struct _MateMixerControlPrivate
{
GList *devices;
GList *streams;
+ GList *cached_streams;
gboolean backend_chosen;
MateMixerState state;
MateMixerBackend *backend;
@@ -63,74 +65,76 @@ static GParamSpec *properties[N_PROPERTIES] = { NULL, };
enum {
DEVICE_ADDED,
- DEVICE_CHANGED,
DEVICE_REMOVED,
STREAM_ADDED,
- STREAM_CHANGED,
STREAM_REMOVED,
+ CACHED_STREAM_ADDED,
+ CACHED_STREAM_REMOVED,
N_SIGNALS
};
static guint signals[N_SIGNALS] = { 0, };
-static void mate_mixer_control_class_init (MateMixerControlClass *klass);
+static void mate_mixer_control_class_init (MateMixerControlClass *klass);
-static void mate_mixer_control_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec);
-static void mate_mixer_control_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec);
+static void mate_mixer_control_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void mate_mixer_control_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec);
-static void mate_mixer_control_init (MateMixerControl *control);
-static void mate_mixer_control_dispose (GObject *object);
-static void mate_mixer_control_finalize (GObject *object);
+static void mate_mixer_control_init (MateMixerControl *control);
+static void mate_mixer_control_dispose (GObject *object);
+static void mate_mixer_control_finalize (GObject *object);
G_DEFINE_TYPE (MateMixerControl, mate_mixer_control, G_TYPE_OBJECT);
-static void control_backend_state_cb (MateMixerBackend *backend,
- GParamSpec *pspec,
- MateMixerControl *control);
-
-static void control_backend_device_added_cb (MateMixerBackend *backend,
- const gchar *name,
- MateMixerControl *control);
-static void control_backend_device_changed_cb (MateMixerBackend *backend,
- const gchar *name,
- MateMixerControl *control);
-static void control_backend_device_removed_cb (MateMixerBackend *backend,
- const gchar *name,
- MateMixerControl *control);
-
-static void control_backend_stream_added_cb (MateMixerBackend *backend,
- const gchar *name,
- MateMixerControl *control);
-static void control_backend_stream_changed_cb (MateMixerBackend *backend,
- const gchar *name,
- MateMixerControl *control);
-static void control_backend_stream_removed_cb (MateMixerBackend *backend,
- const gchar *name,
- MateMixerControl *control);
-
-static void control_backend_default_input_cb (MateMixerBackend *backend,
- GParamSpec *pspec,
- MateMixerControl *control);
-static void control_backend_default_output_cb (MateMixerBackend *backend,
- GParamSpec *pspec,
- MateMixerControl *control);
-
-static gboolean control_try_next_backend (MateMixerControl *control);
-
-static void control_change_state (MateMixerControl *control,
- MateMixerState state);
-
-static void control_close (MateMixerControl *control);
-
-static void control_free_backend (MateMixerControl *control);
-static void control_free_devices (MateMixerControl *control);
-static void control_free_streams (MateMixerControl *control);
+static void on_backend_state_notify (MateMixerBackend *backend,
+ GParamSpec *pspec,
+ MateMixerControl *control);
+
+static void on_backend_device_added (MateMixerBackend *backend,
+ const gchar *name,
+ MateMixerControl *control);
+static void on_backend_device_removed (MateMixerBackend *backend,
+ const gchar *name,
+ MateMixerControl *control);
+
+static void on_backend_stream_added (MateMixerBackend *backend,
+ const gchar *name,
+ MateMixerControl *control);
+static void on_backend_stream_removed (MateMixerBackend *backend,
+ const gchar *name,
+ MateMixerControl *control);
+
+static void on_backend_cached_stream_added (MateMixerBackend *backend,
+ const gchar *name,
+ MateMixerControl *control);
+static void on_backend_cached_stream_removed (MateMixerBackend *backend,
+ const gchar *name,
+ MateMixerControl *control);
+
+static void on_backend_default_input_notify (MateMixerBackend *backend,
+ GParamSpec *pspec,
+ MateMixerControl *control);
+static void on_backend_default_output_notify (MateMixerBackend *backend,
+ GParamSpec *pspec,
+ MateMixerControl *control);
+
+static gboolean try_next_backend (MateMixerControl *control);
+
+static void change_state (MateMixerControl *control,
+ MateMixerState state);
+
+static void close_control (MateMixerControl *control);
+
+static void free_backend (MateMixerControl *control);
+static void free_devices (MateMixerControl *control);
+static void free_streams (MateMixerControl *control);
+static void free_cached_streams (MateMixerControl *control);
static void
mate_mixer_control_class_init (MateMixerControlClass *klass)
@@ -219,14 +223,14 @@ mate_mixer_control_class_init (MateMixerControlClass *klass)
"Default input",
"Default input stream",
MATE_MIXER_TYPE_STREAM,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
properties[PROP_DEFAULT_OUTPUT] =
g_param_spec_object ("default-output",
"Default output",
"Default output stream",
MATE_MIXER_TYPE_STREAM,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPERTIES, properties);
@@ -250,18 +254,17 @@ mate_mixer_control_class_init (MateMixerControlClass *klass)
G_TYPE_STRING);
/**
- * MateMixerControl::device-changed:
+ * MateMixerControl::device-removed:
* @control: a #MateMixerControl
- * @name: name of the changed device
+ * @name: name of the removed device
*
- * The signal is emitted each time a change occurs on one of the known
- * devices.
+ * The signal is emitted each time a device is removed from the system.
*/
- signals[DEVICE_CHANGED] =
- g_signal_new ("device-changed",
+ signals[DEVICE_REMOVED] =
+ g_signal_new ("device-removed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (MateMixerControlClass, device_changed),
+ G_STRUCT_OFFSET (MateMixerControlClass, device_removed),
NULL,
NULL,
g_cclosure_marshal_VOID__STRING,
@@ -270,17 +273,17 @@ mate_mixer_control_class_init (MateMixerControlClass *klass)
G_TYPE_STRING);
/**
- * MateMixerControl::device-removed:
+ * MateMixerControl::stream-added:
* @control: a #MateMixerControl
- * @name: name of the removed device
+ * @name: name of the added stream
*
- * The signal is emitted each time a device is removed from the system.
+ * The signal is emitted each time a stream is created.
*/
- signals[DEVICE_REMOVED] =
- g_signal_new ("device-removed",
+ signals[STREAM_ADDED] =
+ g_signal_new ("stream-added",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (MateMixerControlClass, device_removed),
+ G_STRUCT_OFFSET (MateMixerControlClass, stream_added),
NULL,
NULL,
g_cclosure_marshal_VOID__STRING,
@@ -289,17 +292,17 @@ mate_mixer_control_class_init (MateMixerControlClass *klass)
G_TYPE_STRING);
/**
- * MateMixerControl::stream-added:
+ * MateMixerControl::stream-removed:
* @control: a #MateMixerControl
- * @name: name of the added stream
+ * @name: name of the removed stream
*
- * The signal is emitted each time a stream is added to the system.
+ * The signal is emitted each time a stream is removed.
*/
- signals[STREAM_ADDED] =
- g_signal_new ("stream-added",
+ signals[STREAM_REMOVED] =
+ g_signal_new ("stream-removed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (MateMixerControlClass, stream_added),
+ G_STRUCT_OFFSET (MateMixerControlClass, stream_removed),
NULL,
NULL,
g_cclosure_marshal_VOID__STRING,
@@ -308,18 +311,17 @@ mate_mixer_control_class_init (MateMixerControlClass *klass)
G_TYPE_STRING);
/**
- * MateMixerControl::stream-changed:
+ * MateMixerControl::cached-stream-added:
* @control: a #MateMixerControl
- * @name: name of the changed stream
+ * @name: name of the added cached stream
*
- * The signal is emitted each time a change occurs on one of the known
- * streams.
+ * The signal is emitted each time a cached stream is created.
*/
- signals[STREAM_CHANGED] =
- g_signal_new ("stream-changed",
+ signals[CACHED_STREAM_ADDED] =
+ g_signal_new ("cached-stream-added",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (MateMixerControlClass, stream_changed),
+ G_STRUCT_OFFSET (MateMixerControlClass, cached_stream_added),
NULL,
NULL,
g_cclosure_marshal_VOID__STRING,
@@ -332,13 +334,13 @@ mate_mixer_control_class_init (MateMixerControlClass *klass)
* @control: a #MateMixerControl
* @name: name of the removed stream
*
- * The signal is emitted each time a stream is removed from the system.
+ * The signal is emitted each time a stream is removed.
*/
- signals[STREAM_REMOVED] =
- g_signal_new ("stream-removed",
+ signals[CACHED_STREAM_REMOVED] =
+ g_signal_new ("cached-stream-removed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (MateMixerControlClass, stream_removed),
+ G_STRUCT_OFFSET (MateMixerControlClass, cached_stream_removed),
NULL,
NULL,
g_cclosure_marshal_VOID__STRING,
@@ -416,6 +418,12 @@ mate_mixer_control_set_property (GObject *object,
case PROP_SERVER_ADDRESS:
mate_mixer_control_set_server_address (control, g_value_get_string (value));
break;
+ case PROP_DEFAULT_INPUT:
+ mate_mixer_control_set_default_input_stream (control, g_value_get_object (value));
+ break;
+ case PROP_DEFAULT_OUTPUT:
+ mate_mixer_control_set_default_output_stream (control, g_value_get_object (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -433,7 +441,7 @@ mate_mixer_control_init (MateMixerControl *control)
static void
mate_mixer_control_dispose (GObject *object)
{
- control_close (MATE_MIXER_CONTROL (object));
+ close_control (MATE_MIXER_CONTROL (object));
G_OBJECT_CLASS (mate_mixer_control_parent_class)->dispose (object);
}
@@ -465,10 +473,11 @@ mate_mixer_control_finalize (GObject *object)
MateMixerControl *
mate_mixer_control_new (void)
{
- if (!mate_mixer_is_initialized ()) {
+ if (mate_mixer_is_initialized () == FALSE) {
g_critical ("The library has not been initialized");
return NULL;
}
+
return g_object_new (MATE_MIXER_TYPE_CONTROL, NULL);
}
@@ -504,7 +513,8 @@ mate_mixer_control_set_backend_type (MateMixerControl *control,
return FALSE;
modules = mate_mixer_get_modules ();
- while (modules) {
+
+ while (modules != NULL) {
module = MATE_MIXER_BACKEND_MODULE (modules->data);
info = mate_mixer_backend_module_get_info (module);
@@ -540,11 +550,13 @@ mate_mixer_control_set_app_name (MateMixerControl *control, const gchar *app_nam
control->priv->state == MATE_MIXER_STATE_READY)
return FALSE;
- g_free (control->priv->backend_data.app_name);
+ if (g_strcmp0 (control->priv->backend_data.app_name, app_name) != 0) {
+ g_free (control->priv->backend_data.app_name);
- control->priv->backend_data.app_name = g_strdup (app_name);
+ control->priv->backend_data.app_name = g_strdup (app_name);
- g_object_notify_by_pspec (G_OBJECT (control), properties[PROP_APP_NAME]);
+ g_object_notify_by_pspec (G_OBJECT (control), properties[PROP_APP_NAME]);
+ }
return TRUE;
}
@@ -571,11 +583,13 @@ mate_mixer_control_set_app_id (MateMixerControl *control, const gchar *app_id)
control->priv->state == MATE_MIXER_STATE_READY)
return FALSE;
- g_free (control->priv->backend_data.app_id);
+ if (g_strcmp0 (control->priv->backend_data.app_id, app_id) != 0) {
+ g_free (control->priv->backend_data.app_id);
- control->priv->backend_data.app_id = g_strdup (app_id);
+ control->priv->backend_data.app_id = g_strdup (app_id);
- g_object_notify_by_pspec (G_OBJECT (control), properties[PROP_APP_ID]);
+ g_object_notify_by_pspec (G_OBJECT (control), properties[PROP_APP_ID]);
+ }
return TRUE;
}
@@ -602,11 +616,13 @@ mate_mixer_control_set_app_version (MateMixerControl *control, const gchar *app_
control->priv->state == MATE_MIXER_STATE_READY)
return FALSE;
- g_free (control->priv->backend_data.app_version);
+ if (g_strcmp0 (control->priv->backend_data.app_version, app_version) != 0) {
+ g_free (control->priv->backend_data.app_version);
- control->priv->backend_data.app_version = g_strdup (app_version);
+ control->priv->backend_data.app_version = g_strdup (app_version);
- g_object_notify_by_pspec (G_OBJECT (control), properties[PROP_APP_VERSION]);
+ g_object_notify_by_pspec (G_OBJECT (control), properties[PROP_APP_VERSION]);
+ }
return TRUE;
}
@@ -633,11 +649,13 @@ mate_mixer_control_set_app_icon (MateMixerControl *control, const gchar *app_ico
control->priv->state == MATE_MIXER_STATE_READY)
return FALSE;
- g_free (control->priv->backend_data.app_icon);
+ if (g_strcmp0 (control->priv->backend_data.app_icon, app_icon) != 0) {
+ g_free (control->priv->backend_data.app_icon);
- control->priv->backend_data.app_icon = g_strdup (app_icon);
+ control->priv->backend_data.app_icon = g_strdup (app_icon);
- g_object_notify_by_pspec (G_OBJECT (control), properties[PROP_APP_ICON]);
+ g_object_notify_by_pspec (G_OBJECT (control), properties[PROP_APP_ICON]);
+ }
return TRUE;
}
@@ -665,11 +683,13 @@ mate_mixer_control_set_server_address (MateMixerControl *control, const gchar *a
control->priv->state == MATE_MIXER_STATE_READY)
return FALSE;
- g_free (control->priv->backend_data.server_address);
+ if (g_strcmp0 (control->priv->backend_data.server_address, address) != 0) {
+ g_free (control->priv->backend_data.server_address);
- control->priv->backend_data.server_address = g_strdup (address);
+ control->priv->backend_data.server_address = g_strdup (address);
- g_object_notify_by_pspec (G_OBJECT (control), properties[PROP_SERVER_ADDRESS]);
+ g_object_notify_by_pspec (G_OBJECT (control), properties[PROP_SERVER_ADDRESS]);
+ }
return TRUE;
}
@@ -718,7 +738,7 @@ mate_mixer_control_open (MateMixerControl *control)
modules = mate_mixer_get_modules ();
if (control->priv->backend_type != MATE_MIXER_BACKEND_UNKNOWN) {
- while (modules) {
+ while (modules != NULL) {
const MateMixerBackendInfo *info;
module = MATE_MIXER_BACKEND_MODULE (modules->data);
@@ -736,7 +756,7 @@ mate_mixer_control_open (MateMixerControl *control)
}
if (module == NULL) {
/* Most likely the selected backend is not installed */
- control_change_state (control, MATE_MIXER_STATE_FAILED);
+ change_state (control, MATE_MIXER_STATE_FAILED);
return FALSE;
}
@@ -750,19 +770,19 @@ mate_mixer_control_open (MateMixerControl *control)
/* This transitional state is always present, it will change to MATE_MIXER_STATE_READY
* or MATE_MIXER_STATE_FAILED either instantly or asynchronously */
- control_change_state (control, MATE_MIXER_STATE_CONNECTING);
+ change_state (control, MATE_MIXER_STATE_CONNECTING);
/* The backend initialization might fail in case it is known right now that
* the backend is unusable */
- if (!mate_mixer_backend_open (control->priv->backend)) {
+ if (mate_mixer_backend_open (control->priv->backend) == FALSE) {
if (control->priv->backend_type == MATE_MIXER_BACKEND_UNKNOWN) {
/* User didn't request a specific backend, so try another one */
- return control_try_next_backend (control);
+ return try_next_backend (control);
}
/* User requested a specific backend and it failed */
- control_close (control);
- control_change_state (control, MATE_MIXER_STATE_FAILED);
+ close_control (control);
+ change_state (control, MATE_MIXER_STATE_FAILED);
return FALSE;
}
@@ -773,17 +793,20 @@ mate_mixer_control_open (MateMixerControl *control)
/* This would be a backend bug */
g_warn_if_reached ();
- control_close (control);
- control_change_state (control, MATE_MIXER_STATE_FAILED);
+ if (control->priv->backend_type == MATE_MIXER_BACKEND_UNKNOWN)
+ return try_next_backend (control);
+
+ close_control (control);
+ change_state (control, MATE_MIXER_STATE_FAILED);
return FALSE;
}
- g_signal_connect (control->priv->backend,
+ g_signal_connect (G_OBJECT (control->priv->backend),
"notify::state",
- G_CALLBACK (control_backend_state_cb),
+ G_CALLBACK (on_backend_state_notify),
control);
- control_change_state (control, state);
+ change_state (control, state);
return TRUE;
}
@@ -799,8 +822,8 @@ mate_mixer_control_close (MateMixerControl *control)
{
g_return_if_fail (MATE_MIXER_IS_CONTROL (control));
- control_close (control);
- control_change_state (control, MATE_MIXER_STATE_IDLE);
+ close_control (control);
+ change_state (control, MATE_MIXER_STATE_IDLE);
}
/**
@@ -837,10 +860,10 @@ mate_mixer_control_get_device (MateMixerControl *control, const gchar *name)
g_return_val_if_fail (name != NULL, NULL);
list = mate_mixer_control_list_devices (control);
- while (list) {
+ while (list != NULL) {
MateMixerDevice *device = MATE_MIXER_DEVICE (list->data);
- if (!strcmp (name, mate_mixer_device_get_name (device)))
+ if (strcmp (name, mate_mixer_device_get_name (device)) == 0)
return device;
list = list->next;
@@ -866,10 +889,36 @@ mate_mixer_control_get_stream (MateMixerControl *control, const gchar *name)
g_return_val_if_fail (name != NULL, NULL);
list = mate_mixer_control_list_streams (control);
+ while (list != NULL) {
+ MateMixerStream *stream = MATE_MIXER_STREAM (list->data);
+
+ if (strcmp (name, mate_mixer_stream_get_name (stream)) == 0)
+ return stream;
+
+ list = list->next;
+ }
+ return NULL;
+}
+
+/**
+ * mate_mixer_control_get_cached_stream:
+ * @control: a #MateMixerControl
+ * @name: a stream name
+ *
+ */
+MateMixerStream *
+mate_mixer_control_get_cached_stream (MateMixerControl *control, const gchar *name)
+{
+ const GList *list;
+
+ g_return_val_if_fail (MATE_MIXER_IS_CONTROL (control), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+
+ list = mate_mixer_control_list_cached_streams (control);
while (list) {
MateMixerStream *stream = MATE_MIXER_STREAM (list->data);
- if (!strcmp (name, mate_mixer_stream_get_name (stream)))
+ if (strcmp (name, mate_mixer_stream_get_name (stream)) == 0)
return stream;
list = list->next;
@@ -938,6 +987,28 @@ mate_mixer_control_list_streams (MateMixerControl *control)
}
/**
+ * mate_mixer_control_list_cached_streams:
+ * @control: a #MateMixerControl
+ *
+ */
+const GList *
+mate_mixer_control_list_cached_streams (MateMixerControl *control)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_CONTROL (control), NULL);
+
+ if (control->priv->state != MATE_MIXER_STATE_READY)
+ return NULL;
+
+ /* This list is cached here and invalidated when the backend notifies us
+ * about a change */
+ if (control->priv->cached_streams == NULL)
+ control->priv->cached_streams =
+ mate_mixer_backend_list_cached_streams (MATE_MIXER_BACKEND (control->priv->backend));
+
+ return (const GList *) control->priv->cached_streams;
+}
+
+/**
* mate_mixer_control_get_default_input_stream:
* @control: a #MateMixerControl
*
@@ -1057,7 +1128,7 @@ mate_mixer_control_get_backend_name (MateMixerControl *control)
{
g_return_val_if_fail (MATE_MIXER_IS_CONTROL (control), NULL);
- if (!control->priv->backend_chosen)
+ if (control->priv->backend_chosen == FALSE)
return NULL;
return mate_mixer_backend_module_get_info (control->priv->module)->name;
@@ -1077,16 +1148,16 @@ mate_mixer_control_get_backend_type (MateMixerControl *control)
{
g_return_val_if_fail (MATE_MIXER_IS_CONTROL (control), MATE_MIXER_BACKEND_UNKNOWN);
- if (!control->priv->backend_chosen)
+ if (control->priv->backend_chosen == FALSE)
return MATE_MIXER_BACKEND_UNKNOWN;
return mate_mixer_backend_module_get_info (control->priv->module)->backend_type;
}
static void
-control_backend_state_cb (MateMixerBackend *backend,
- GParamSpec *pspec,
- MateMixerControl *control)
+on_backend_state_notify (MateMixerBackend *backend,
+ GParamSpec *pspec,
+ MateMixerControl *control)
{
MateMixerState state = mate_mixer_backend_get_state (backend);
@@ -1095,19 +1166,20 @@ control_backend_state_cb (MateMixerBackend *backend,
g_debug ("Backend %s changed state to CONNECTING",
mate_mixer_backend_module_get_info (control->priv->module)->name);
- if (control->priv->backend_chosen) {
+ if (control->priv->backend_chosen == TRUE) {
/* Invalidate cached data when reconnecting */
- control_free_devices (control);
- control_free_devices (control);
+ free_devices (control);
+ free_streams (control);
+ free_cached_streams (control);
}
- control_change_state (control, state);
+ change_state (control, state);
break;
case MATE_MIXER_STATE_READY:
g_debug ("Backend %s changed state to READY",
mate_mixer_backend_module_get_info (control->priv->module)->name);
- control_change_state (control, state);
+ change_state (control, state);
break;
case MATE_MIXER_STATE_FAILED:
@@ -1116,11 +1188,11 @@ control_backend_state_cb (MateMixerBackend *backend,
if (control->priv->backend_type == MATE_MIXER_BACKEND_UNKNOWN) {
/* User didn't request a specific backend, so try another one */
- control_try_next_backend (control);
+ try_next_backend (control);
} else {
/* User requested a specific backend and it failed */
- control_close (control);
- control_change_state (control, state);
+ close_control (control);
+ change_state (control, state);
}
break;
@@ -1130,11 +1202,11 @@ control_backend_state_cb (MateMixerBackend *backend,
}
static void
-control_backend_device_added_cb (MateMixerBackend *backend,
- const gchar *name,
- MateMixerControl *control)
+on_backend_device_added (MateMixerBackend *backend,
+ const gchar *name,
+ MateMixerControl *control)
{
- control_free_devices (control);
+ free_devices (control);
g_signal_emit (G_OBJECT (control),
signals[DEVICE_ADDED],
@@ -1143,107 +1215,110 @@ control_backend_device_added_cb (MateMixerBackend *backend,
}
static void
-control_backend_device_changed_cb (MateMixerBackend *backend,
- const gchar *name,
- MateMixerControl *control)
+on_backend_device_removed (MateMixerBackend *backend,
+ const gchar *name,
+ MateMixerControl *control)
{
+ free_devices (control);
+
g_signal_emit (G_OBJECT (control),
- signals[DEVICE_CHANGED],
+ signals[DEVICE_REMOVED],
0,
name);
}
static void
-control_backend_device_removed_cb (MateMixerBackend *backend,
- const gchar *name,
- MateMixerControl *control)
+on_backend_stream_added (MateMixerBackend *backend,
+ const gchar *name,
+ MateMixerControl *control)
{
- control_free_devices (control);
+ free_streams (control);
g_signal_emit (G_OBJECT (control),
- signals[DEVICE_REMOVED],
+ signals[STREAM_ADDED],
0,
name);
}
static void
-control_backend_stream_added_cb (MateMixerBackend *backend,
- const gchar *name,
- MateMixerControl *control)
+on_backend_stream_removed (MateMixerBackend *backend,
+ const gchar *name,
+ MateMixerControl *control)
{
- control_free_streams (control);
+ free_streams (control);
g_signal_emit (G_OBJECT (control),
- signals[STREAM_ADDED],
+ signals[STREAM_REMOVED],
0,
name);
}
static void
-control_backend_stream_changed_cb (MateMixerBackend *backend,
- const gchar *name,
- MateMixerControl *control)
+on_backend_cached_stream_added (MateMixerBackend *backend,
+ const gchar *name,
+ MateMixerControl *control)
{
+ free_cached_streams (control);
+
g_signal_emit (G_OBJECT (control),
- signals[STREAM_CHANGED],
+ signals[CACHED_STREAM_ADDED],
0,
name);
}
static void
-control_backend_stream_removed_cb (MateMixerBackend *backend,
- const gchar *name,
- MateMixerControl *control)
+on_backend_cached_stream_removed (MateMixerBackend *backend,
+ const gchar *name,
+ MateMixerControl *control)
{
- control_free_streams (control);
+ free_cached_streams (control);
g_signal_emit (G_OBJECT (control),
- signals[STREAM_REMOVED],
+ signals[CACHED_STREAM_REMOVED],
0,
name);
}
static void
-control_backend_default_input_cb (MateMixerBackend *backend,
- GParamSpec *pspec,
- MateMixerControl *control)
+on_backend_default_input_notify (MateMixerBackend *backend,
+ GParamSpec *pspec,
+ MateMixerControl *control)
{
g_object_notify_by_pspec (G_OBJECT (control), properties[PROP_DEFAULT_INPUT]);
}
static void
-control_backend_default_output_cb (MateMixerBackend *backend,
- GParamSpec *pspec,
- MateMixerControl *control)
+on_backend_default_output_notify (MateMixerBackend *backend,
+ GParamSpec *pspec,
+ MateMixerControl *control)
{
g_object_notify_by_pspec (G_OBJECT (control), properties[PROP_DEFAULT_OUTPUT]);
}
static gboolean
-control_try_next_backend (MateMixerControl *control)
+try_next_backend (MateMixerControl *control)
{
const GList *modules;
MateMixerBackendModule *module = NULL;
MateMixerState state;
modules = mate_mixer_get_modules ();
- while (modules) {
+
+ while (modules != NULL) {
if (control->priv->module == modules->data) {
/* Found the last tested backend, try to use the next one with a lower
* priority unless we have reached the end of the list */
- if (modules->next)
+ if (modules->next != NULL)
module = MATE_MIXER_BACKEND_MODULE (modules->next->data);
break;
}
modules = modules->next;
}
- control_close (control);
+ close_control (control);
if (module == NULL) {
- /* This shouldn't happen under normal circumstances as the lowest
- * priority module is the "Null" module which never fails to initialize,
- * but in a broken installation this module could be missing */
- control_change_state (control, MATE_MIXER_STATE_FAILED);
+ /* We have tried all the modules and all of them failed */
+ change_state (control, MATE_MIXER_STATE_FAILED);
return FALSE;
}
@@ -1253,8 +1328,10 @@ control_try_next_backend (MateMixerControl *control)
mate_mixer_backend_set_data (control->priv->backend, &control->priv->backend_data);
- if (!mate_mixer_backend_open (control->priv->backend))
- return control_try_next_backend (control);
+ /* Try to open this backend and in case of failure keep trying until we find
+ * one that works or reach the end of the list */
+ if (mate_mixer_backend_open (control->priv->backend) == FALSE)
+ return try_next_backend (control);
state = mate_mixer_backend_get_state (control->priv->backend);
@@ -1263,64 +1340,63 @@ control_try_next_backend (MateMixerControl *control)
/* This would be a backend bug */
g_warn_if_reached ();
- control_close (control);
- return control_try_next_backend (control);
+ return try_next_backend (control);
}
- g_signal_connect (control->priv->backend,
+ g_signal_connect (G_OBJECT (control->priv->backend),
"notify::state",
- G_CALLBACK (control_backend_state_cb),
+ G_CALLBACK (on_backend_state_notify),
control);
- control_change_state (control, state);
+ change_state (control, state);
return TRUE;
}
static void
-control_change_state (MateMixerControl *control, MateMixerState state)
+change_state (MateMixerControl *control, MateMixerState state)
{
if (control->priv->state == state)
return;
control->priv->state = state;
- if (state == MATE_MIXER_STATE_READY && !control->priv->backend_chosen) {
+ if (state == MATE_MIXER_STATE_READY && control->priv->backend_chosen == FALSE) {
/* It is safe to connect to the backend signals after reaching the READY
* state, because the app is not allowed to query any data before that state;
* therefore we won't end up in an inconsistent state by caching a list and
* then missing a notification about a change in the list */
- g_signal_connect (control->priv->backend,
+ g_signal_connect (G_OBJECT (control->priv->backend),
"device-added",
- G_CALLBACK (control_backend_device_added_cb),
- control);
- g_signal_connect (control->priv->backend,
- "device-changed",
- G_CALLBACK (control_backend_device_changed_cb),
+ G_CALLBACK (on_backend_device_added),
control);
- g_signal_connect (control->priv->backend,
+ g_signal_connect (G_OBJECT (control->priv->backend),
"device-removed",
- G_CALLBACK (control_backend_device_removed_cb),
+ G_CALLBACK (on_backend_device_removed),
control);
- g_signal_connect (control->priv->backend,
+ g_signal_connect (G_OBJECT (control->priv->backend),
"stream-added",
- G_CALLBACK (control_backend_stream_added_cb),
+ G_CALLBACK (on_backend_stream_added),
control);
- g_signal_connect (control->priv->backend,
- "stream-changed",
- G_CALLBACK (control_backend_stream_changed_cb),
- control);
- g_signal_connect (control->priv->backend,
+ g_signal_connect (G_OBJECT (control->priv->backend),
"stream-removed",
- G_CALLBACK (control_backend_stream_removed_cb),
+ G_CALLBACK (on_backend_stream_removed),
+ control);
+ g_signal_connect (G_OBJECT (control->priv->backend),
+ "cached-stream-added",
+ G_CALLBACK (on_backend_cached_stream_added),
+ control);
+ g_signal_connect (G_OBJECT (control->priv->backend),
+ "cached-stream-removed",
+ G_CALLBACK (on_backend_cached_stream_removed),
control);
- g_signal_connect (control->priv->backend,
+ g_signal_connect (G_OBJECT (control->priv->backend),
"notify::default-input",
- G_CALLBACK (control_backend_default_input_cb),
+ G_CALLBACK (on_backend_default_input_notify),
control);
- g_signal_connect (control->priv->backend,
+ g_signal_connect (G_OBJECT (control->priv->backend),
"notify::default-output",
- G_CALLBACK (control_backend_default_output_cb),
+ G_CALLBACK (on_backend_default_output_notify),
control);
control->priv->backend_chosen = TRUE;
@@ -1330,28 +1406,34 @@ control_change_state (MateMixerControl *control, MateMixerState state)
}
static void
-control_close (MateMixerControl *control)
+close_control (MateMixerControl *control)
{
- control_free_backend (control);
- control_free_devices (control);
- control_free_streams (control);
+ free_backend (control);
+ free_devices (control);
+ free_streams (control);
+ free_cached_streams (control);
g_clear_object (&control->priv->module);
+
+ control->priv->backend_chosen = FALSE;
}
static void
-control_free_backend (MateMixerControl *control)
+free_backend (MateMixerControl *control)
{
if (control->priv->backend == NULL)
return;
+ g_signal_handlers_disconnect_by_data (G_OBJECT (control->priv->backend),
+ control);
+
mate_mixer_backend_close (control->priv->backend);
g_clear_object (&control->priv->backend);
}
static void
-control_free_devices (MateMixerControl *control)
+free_devices (MateMixerControl *control)
{
if (control->priv->devices == NULL)
return;
@@ -1362,7 +1444,7 @@ control_free_devices (MateMixerControl *control)
}
static void
-control_free_streams (MateMixerControl *control)
+free_streams (MateMixerControl *control)
{
if (control->priv->streams == NULL)
return;
@@ -1371,3 +1453,14 @@ control_free_streams (MateMixerControl *control)
control->priv->streams = NULL;
}
+
+static void
+free_cached_streams (MateMixerControl *control)
+{
+ if (control->priv->cached_streams == NULL)
+ return;
+
+ g_list_free_full (control->priv->cached_streams, g_object_unref);
+
+ control->priv->cached_streams = NULL;
+}
diff --git a/libmatemixer/matemixer-control.h b/libmatemixer/matemixer-control.h
index 5598ade..e6d3afa 100644
--- a/libmatemixer/matemixer-control.h
+++ b/libmatemixer/matemixer-control.h
@@ -68,21 +68,29 @@ struct _MateMixerControlClass
GObjectClass parent_class;
/*< private >*/
- void (*device_added) (MateMixerControl *control,
- const gchar *name);
- void (*device_changed) (MateMixerControl *control,
- const gchar *name);
- void (*device_removed) (MateMixerControl *control,
- const gchar *name);
- void (*stream_added) (MateMixerControl *control,
- const gchar *name);
- void (*stream_changed) (MateMixerControl *control,
- const gchar *name);
- void (*stream_removed) (MateMixerControl *control,
- const gchar *name);
+ /* Signals */
+ void (*device_added) (MateMixerControl *control,
+ const gchar *name);
+ void (*device_changed) (MateMixerControl *control,
+ const gchar *name);
+ void (*device_removed) (MateMixerControl *control,
+ const gchar *name);
+ void (*stream_added) (MateMixerControl *control,
+ const gchar *name);
+ void (*stream_changed) (MateMixerControl *control,
+ const gchar *name);
+ void (*stream_removed) (MateMixerControl *control,
+ const gchar *name);
+ void (*cached_stream_added) (MateMixerControl *control,
+ const gchar *name);
+ void (*cached_stream_changed) (MateMixerControl *control,
+ const gchar *name);
+ void (*cached_stream_removed) (MateMixerControl *control,
+ const gchar *name);
};
GType mate_mixer_control_get_type (void) G_GNUC_CONST;
+
MateMixerControl * mate_mixer_control_new (void);
gboolean mate_mixer_control_set_backend_type (MateMixerControl *control,
@@ -97,6 +105,7 @@ gboolean mate_mixer_control_set_app_icon (MateMixerCon
const gchar *app_icon);
gboolean mate_mixer_control_set_server_address (MateMixerControl *control,
const gchar *address);
+
gboolean mate_mixer_control_open (MateMixerControl *control);
void mate_mixer_control_close (MateMixerControl *control);
@@ -106,9 +115,12 @@ MateMixerDevice * mate_mixer_control_get_device (MateMixerCon
const gchar *name);
MateMixerStream * mate_mixer_control_get_stream (MateMixerControl *control,
const gchar *name);
+MateMixerStream * mate_mixer_control_get_cached_stream (MateMixerControl *control,
+ const gchar *name);
const GList * mate_mixer_control_list_devices (MateMixerControl *control);
const GList * mate_mixer_control_list_streams (MateMixerControl *control);
+const GList * mate_mixer_control_list_cached_streams (MateMixerControl *control);
MateMixerStream * mate_mixer_control_get_default_input_stream (MateMixerControl *control);
gboolean mate_mixer_control_set_default_input_stream (MateMixerControl *control,
diff --git a/libmatemixer/matemixer-device-profile-private.h b/libmatemixer/matemixer-device-profile-private.h
new file mode 100644
index 0000000..403c7d7
--- /dev/null
+++ b/libmatemixer/matemixer-device-profile-private.h
@@ -0,0 +1,44 @@
+/*
+ * 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_update_description (MateMixerDeviceProfile *profile,
+ const gchar *description);
+gboolean _mate_mixer_device_profile_update_priority (MateMixerDeviceProfile *profile,
+ guint priority);
+gboolean _mate_mixer_device_profile_update_num_input_streams (MateMixerDeviceProfile *profile,
+ guint num);
+gboolean _mate_mixer_device_profile_update_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
index e229b6a..0485740 100644
--- a/libmatemixer/matemixer-device-profile.c
+++ b/libmatemixer/matemixer-device-profile.c
@@ -19,9 +19,11 @@
#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
*/
@@ -46,19 +48,19 @@ enum {
static GParamSpec *properties[N_PROPERTIES] = { NULL, };
-static void mate_mixer_device_profile_class_init (MateMixerDeviceProfileClass *klass);
+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_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);
+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);
@@ -215,22 +217,10 @@ mate_mixer_device_profile_finalize (GObject *object)
G_OBJECT_CLASS (mate_mixer_device_profile_parent_class)->finalize (object);
}
-MateMixerDeviceProfile *
-mate_mixer_device_profile_new (const gchar *name,
- const gchar *description,
- guint priority,
- guint input_streams,
- guint output_streams)
-{
- return g_object_new (MATE_MIXER_TYPE_DEVICE_PROFILE,
- "name", name,
- "description", description,
- "priority", priority,
- "num-input-streams", input_streams,
- "num-output-streams", output_streams,
- NULL);
-}
-
+/**
+ * mate_mixer_device_profile_get_name:
+ * @profile: a #MateMixerDeviceProfile
+ */
const gchar *
mate_mixer_device_profile_get_name (MateMixerDeviceProfile *profile)
{
@@ -239,6 +229,10 @@ mate_mixer_device_profile_get_name (MateMixerDeviceProfile *profile)
return profile->priv->name;
}
+/**
+ * mate_mixer_device_profile_get_description:
+ * @profile: a #MateMixerDeviceProfile
+ */
const gchar *
mate_mixer_device_profile_get_description (MateMixerDeviceProfile *profile)
{
@@ -247,6 +241,10 @@ mate_mixer_device_profile_get_description (MateMixerDeviceProfile *profile)
return profile->priv->description;
}
+/**
+ * mate_mixer_device_profile_get_priority:
+ * @profile: a #MateMixerDeviceProfile
+ */
guint
mate_mixer_device_profile_get_priority (MateMixerDeviceProfile *profile)
{
@@ -255,6 +253,10 @@ mate_mixer_device_profile_get_priority (MateMixerDeviceProfile *profile)
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)
{
@@ -263,6 +265,10 @@ mate_mixer_device_profile_get_num_input_streams (MateMixerDeviceProfile *profile
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)
{
@@ -270,3 +276,85 @@ mate_mixer_device_profile_get_num_output_streams (MateMixerDeviceProfile *profil
return profile->priv->num_output_streams;
}
+
+MateMixerDeviceProfile *
+_mate_mixer_device_profile_new (const gchar *name,
+ const gchar *description,
+ guint priority,
+ guint input_streams,
+ guint output_streams)
+{
+ return g_object_new (MATE_MIXER_TYPE_DEVICE_PROFILE,
+ "name", name,
+ "description", description,
+ "priority", priority,
+ "num-input-streams", input_streams,
+ "num-output-streams", output_streams,
+ NULL);
+}
+
+gboolean
+_mate_mixer_device_profile_update_description (MateMixerDeviceProfile *profile,
+ const gchar *description)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_DEVICE_PROFILE (profile), FALSE);
+
+ if (g_strcmp0 (profile->priv->description, description) != 0) {
+ g_free (profile->priv->description);
+
+ profile->priv->description = g_strdup (description);
+
+ g_object_notify_by_pspec (G_OBJECT (profile), properties[PROP_DESCRIPTION]);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+gboolean
+_mate_mixer_device_profile_update_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_update_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_update_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
index 6a4368b..e8fae19 100644
--- a/libmatemixer/matemixer-device-profile.h
+++ b/libmatemixer/matemixer-device-profile.h
@@ -53,19 +53,13 @@ struct _MateMixerDeviceProfileClass
GObjectClass parent_class;
};
-GType mate_mixer_device_profile_get_type (void) G_GNUC_CONST;
+GType mate_mixer_device_profile_get_type (void) G_GNUC_CONST;
-MateMixerDeviceProfile *mate_mixer_device_profile_new (const gchar *name,
- const gchar *description,
- guint priority,
- guint input_streams,
- guint output_streams);
-
-const gchar * mate_mixer_device_profile_get_name (MateMixerDeviceProfile *profile);
-const gchar * mate_mixer_device_profile_get_description (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);
+const gchar *mate_mixer_device_profile_get_name (MateMixerDeviceProfile *profile);
+const gchar *mate_mixer_device_profile_get_description (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
diff --git a/libmatemixer/matemixer-device.c b/libmatemixer/matemixer-device.c
index 00a848a..0406709 100644
--- a/libmatemixer/matemixer-device.c
+++ b/libmatemixer/matemixer-device.c
@@ -20,9 +20,11 @@
#include "matemixer-device.h"
#include "matemixer-device-profile.h"
+#include "matemixer-port.h"
/**
* SECTION:matemixer-device
+ * @short_description: Hardware or software device in the sound system
* @include: libmatemixer/matemixer.h
*/
@@ -34,7 +36,7 @@ mate_mixer_device_default_init (MateMixerDeviceInterface *iface)
g_object_interface_install_property (iface,
g_param_spec_string ("name",
"Name",
- "Name of the sound device",
+ "Name of the device",
NULL,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
@@ -42,7 +44,7 @@ mate_mixer_device_default_init (MateMixerDeviceInterface *iface)
g_object_interface_install_property (iface,
g_param_spec_string ("description",
"Description",
- "Description of the sound device",
+ "Description of the device",
NULL,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
@@ -56,36 +58,31 @@ mate_mixer_device_default_init (MateMixerDeviceInterface *iface)
G_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface,
- g_param_spec_pointer ("ports",
- "Ports",
- "GList of the sound device ports",
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- g_object_interface_install_property (iface,
- g_param_spec_pointer ("profiles",
- "Profiles",
- "GList of the sound device profiles",
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- g_object_interface_install_property (iface,
g_param_spec_object ("active-profile",
"Active profile",
- "The currently active profile of the sound device",
+ "The currently active profile of the device",
MATE_MIXER_TYPE_DEVICE_PROFILE,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
}
+/**
+ * mate_mixer_device_get_name:
+ * @device: a #MateMixerDevice
+ */
const gchar *
mate_mixer_device_get_name (MateMixerDevice *device)
{
g_return_val_if_fail (MATE_MIXER_IS_DEVICE (device), NULL);
+ /* Implementation required */
return MATE_MIXER_DEVICE_GET_INTERFACE (device)->get_name (device);
}
+/**
+ * mate_mixer_device_get_description:
+ * @device: a #MateMixerDevice
+ */
const gchar *
mate_mixer_device_get_description (MateMixerDevice *device)
{
@@ -101,6 +98,10 @@ mate_mixer_device_get_description (MateMixerDevice *device)
return NULL;
}
+/**
+ * mate_mixer_device_get_icon:
+ * @device: a #MateMixerDevice
+ */
const gchar *
mate_mixer_device_get_icon (MateMixerDevice *device)
{
@@ -116,6 +117,52 @@ mate_mixer_device_get_icon (MateMixerDevice *device)
return NULL;
}
+/**
+ * mate_mixer_device_get_port:
+ * @device: a #MateMixerDevice
+ * @name: a port name
+ */
+MateMixerPort *
+mate_mixer_device_get_port (MateMixerDevice *device, const gchar *name)
+{
+ MateMixerDeviceInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_DEVICE (device), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+
+ iface = MATE_MIXER_DEVICE_GET_INTERFACE (device);
+
+ if (iface->get_port)
+ return iface->get_port (device, name);
+
+ return NULL;
+}
+
+/**
+ * mate_mixer_device_get_profile:
+ * @device: a #MateMixerDevice
+ * @name: a profile name
+ */
+MateMixerDeviceProfile *
+mate_mixer_device_get_profile (MateMixerDevice *device, const gchar *name)
+{
+ MateMixerDeviceInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_DEVICE (device), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+
+ iface = MATE_MIXER_DEVICE_GET_INTERFACE (device);
+
+ if (iface->get_profile)
+ return iface->get_profile (device, name);
+
+ return NULL;
+}
+
+/**
+ * mate_mixer_device_list_ports:
+ * @device: a #MateMixerDevice
+ */
const GList *
mate_mixer_device_list_ports (MateMixerDevice *device)
{
@@ -131,6 +178,10 @@ mate_mixer_device_list_ports (MateMixerDevice *device)
return NULL;
}
+/**
+ * mate_mixer_device_list_profiles:
+ * @device: a #MateMixerDevice
+ */
const GList *
mate_mixer_device_list_profiles (MateMixerDevice *device)
{
@@ -146,6 +197,10 @@ mate_mixer_device_list_profiles (MateMixerDevice *device)
return NULL;
}
+/**
+ * mate_mixer_device_get_active_profile:
+ * @device: a #MateMixerDevice
+ */
MateMixerDeviceProfile *
mate_mixer_device_get_active_profile (MateMixerDevice *device)
{
@@ -161,13 +216,19 @@ mate_mixer_device_get_active_profile (MateMixerDevice *device)
return NULL;
}
+/**
+ * mate_mixer_device_set_active_profile:
+ * @device: a #MateMixerDevice
+ * @profile: a #MateMixerDeviceProfile
+ */
gboolean
-mate_mixer_device_set_active_profile (MateMixerDevice *device, const gchar *profile)
+mate_mixer_device_set_active_profile (MateMixerDevice *device,
+ MateMixerDeviceProfile *profile)
{
MateMixerDeviceInterface *iface;
g_return_val_if_fail (MATE_MIXER_IS_DEVICE (device), FALSE);
- g_return_val_if_fail (profile != NULL, FALSE);
+ g_return_val_if_fail (MATE_MIXER_IS_DEVICE_PROFILE (profile), FALSE);
iface = MATE_MIXER_DEVICE_GET_INTERFACE (device);
diff --git a/libmatemixer/matemixer-device.h b/libmatemixer/matemixer-device.h
index ef283f1..340496b 100644
--- a/libmatemixer/matemixer-device.h
+++ b/libmatemixer/matemixer-device.h
@@ -22,6 +22,7 @@
#include <glib-object.h>
#include <libmatemixer/matemixer-device-profile.h>
+#include <libmatemixer/matemixer-port.h>
G_BEGIN_DECLS
@@ -42,29 +43,42 @@ struct _MateMixerDeviceInterface
GTypeInterface parent_iface;
/*< private >*/
- const gchar *(*get_name) (MateMixerDevice *device);
- const gchar *(*get_description) (MateMixerDevice *device);
- const gchar *(*get_icon) (MateMixerDevice *device);
- const GList *(*list_streams) (MateMixerDevice *device);
- const GList *(*list_ports) (MateMixerDevice *device);
- const GList *(*list_profiles) (MateMixerDevice *device);
- MateMixerDeviceProfile *(*get_active_profile) (MateMixerDevice *device);
- gboolean (*set_active_profile) (MateMixerDevice *device,
- const gchar *profile);
+ /* Virtual table */
+ const gchar *(*get_name) (MateMixerDevice *device);
+ const gchar *(*get_description) (MateMixerDevice *device);
+ const gchar *(*get_icon) (MateMixerDevice *device);
+
+ MateMixerPort *(*get_port) (MateMixerDevice *device,
+ const gchar *name);
+ MateMixerDeviceProfile *(*get_profile) (MateMixerDevice *device,
+ const gchar *name);
+
+ const GList *(*list_streams) (MateMixerDevice *device);
+ const GList *(*list_ports) (MateMixerDevice *device);
+ const GList *(*list_profiles) (MateMixerDevice *device);
+
+ MateMixerDeviceProfile *(*get_active_profile) (MateMixerDevice *device);
+ gboolean (*set_active_profile) (MateMixerDevice *device,
+ MateMixerDeviceProfile *profile);
};
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_description (MateMixerDevice *device);
-const gchar * mate_mixer_device_get_icon (MateMixerDevice *device);
+const gchar * mate_mixer_device_get_name (MateMixerDevice *device);
+const gchar * mate_mixer_device_get_description (MateMixerDevice *device);
+const gchar * mate_mixer_device_get_icon (MateMixerDevice *device);
+
+MateMixerPort * mate_mixer_device_get_port (MateMixerDevice *device,
+ const gchar *name);
+MateMixerDeviceProfile *mate_mixer_device_get_profile (MateMixerDevice *device,
+ const gchar *name);
-const GList * mate_mixer_device_list_ports (MateMixerDevice *device);
-const GList * mate_mixer_device_list_profiles (MateMixerDevice *device);
+const GList * mate_mixer_device_list_ports (MateMixerDevice *device);
+const GList * mate_mixer_device_list_profiles (MateMixerDevice *device);
-MateMixerDeviceProfile *mate_mixer_device_get_active_profile (MateMixerDevice *device);
-gboolean mate_mixer_device_set_active_profile (MateMixerDevice *device,
- const gchar *profile);
+MateMixerDeviceProfile *mate_mixer_device_get_active_profile (MateMixerDevice *device);
+gboolean mate_mixer_device_set_active_profile (MateMixerDevice *device,
+ MateMixerDeviceProfile *profile);
G_END_DECLS
diff --git a/libmatemixer/matemixer-enum-types.c b/libmatemixer/matemixer-enum-types.c
index 0f60a6a..339b673 100644
--- a/libmatemixer/matemixer-enum-types.c
+++ b/libmatemixer/matemixer-enum-types.c
@@ -94,16 +94,14 @@ mate_mixer_stream_flags_get_type (void)
{ 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_APPLICATION, "MATE_MIXER_STREAM_APPLICATION", "application" },
- { MATE_MIXER_STREAM_EVENT, "MATE_MIXER_STREAM_EVENT", "event" },
{ MATE_MIXER_STREAM_HAS_MUTE, "MATE_MIXER_STREAM_HAS_MUTE", "has-mute" },
{ MATE_MIXER_STREAM_HAS_VOLUME, "MATE_MIXER_STREAM_HAS_VOLUME", "has-volume" },
{ MATE_MIXER_STREAM_HAS_DECIBEL_VOLUME, "MATE_MIXER_STREAM_HAS_DECIBEL_VOLUME", "has-decibel-volume" },
{ MATE_MIXER_STREAM_HAS_FLAT_VOLUME, "MATE_MIXER_STREAM_HAS_FLAT_VOLUME", "has-flat-volume" },
{ MATE_MIXER_STREAM_HAS_MONITOR, "MATE_MIXER_STREAM_HAS_MONITOR", "has-monitor" },
+ { MATE_MIXER_STREAM_CAN_SET_VOLUME, "MATE_MIXER_STREAM_CAN_SET_VOLUME", "can-set-volume" },
{ MATE_MIXER_STREAM_CAN_BALANCE, "MATE_MIXER_STREAM_CAN_BALANCE", "can-balance" },
{ MATE_MIXER_STREAM_CAN_FADE, "MATE_MIXER_STREAM_CAN_FADE", "can-fade" },
- { MATE_MIXER_STREAM_CAN_SET_VOLUME, "MATE_MIXER_STREAM_CAN_SET_VOLUME", "can-set-volume" },
{ MATE_MIXER_STREAM_CAN_SUSPEND, "MATE_MIXER_STREAM_CAN_SUSPEND", "can-suspend" },
{ 0, NULL, NULL }
};
@@ -121,10 +119,10 @@ mate_mixer_stream_state_get_type (void)
if (etype == 0) {
static const GEnumValue values[] = {
- { MATE_MIXER_STREAM_UNKNOWN_STATE, "MATE_MIXER_STREAM_UNKNOWN_STATE", "unknown-state" },
- { MATE_MIXER_STREAM_RUNNING, "MATE_MIXER_STREAM_RUNNING", "running" },
- { MATE_MIXER_STREAM_IDLE, "MATE_MIXER_STREAM_IDLE", "idle" },
- { MATE_MIXER_STREAM_SUSPENDED, "MATE_MIXER_STREAM_SUSPENDED", "suspended" },
+ { 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" },
{ 0, NULL, NULL }
};
etype = g_enum_register_static (
@@ -135,13 +133,60 @@ mate_mixer_stream_state_get_type (void)
}
GType
+mate_mixer_client_stream_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" },
+ { 0, NULL, NULL }
+ };
+ etype = g_flags_register_static (
+ g_intern_static_string ("MateMixerClientStreamFlags"),
+ values);
+ }
+ return etype;
+}
+
+GType
+mate_mixer_client_stream_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" },
+ { 0, NULL, NULL }
+ };
+ etype = g_enum_register_static (
+ g_intern_static_string ("MateMixerClientStreamRole"),
+ values);
+ }
+ return etype;
+}
+
+GType
mate_mixer_channel_position_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
static const GEnumValue values[] = {
- { MATE_MIXER_CHANNEL_UNKNOWN_POSITION, "MATE_MIXER_CHANNEL_UNKNOWN_POSITION", "unknown-position" },
+ { MATE_MIXER_CHANNEL_UNKNOWN, "MATE_MIXER_CHANNEL_UNKNOWN", "unknown" },
{ MATE_MIXER_CHANNEL_MONO, "MATE_MIXER_CHANNEL_MONO", "mono" },
{ MATE_MIXER_CHANNEL_FRONT_LEFT, "MATE_MIXER_CHANNEL_FRONT_LEFT", "front-left" },
{ MATE_MIXER_CHANNEL_FRONT_RIGHT, "MATE_MIXER_CHANNEL_FRONT_RIGHT", "front-right" },
@@ -149,9 +194,9 @@ mate_mixer_channel_position_get_type (void)
{ MATE_MIXER_CHANNEL_LFE, "MATE_MIXER_CHANNEL_LFE", "lfe" },
{ MATE_MIXER_CHANNEL_BACK_LEFT, "MATE_MIXER_CHANNEL_BACK_LEFT", "back-left" },
{ MATE_MIXER_CHANNEL_BACK_RIGHT, "MATE_MIXER_CHANNEL_BACK_RIGHT", "back-right" },
- { MATE_MIXER_CHANNEL_FRONT_LEFT_CENTER, "MATE_MIXER_CHANNEL_FRONT_LEFT_CENTER", "front-left-center" },
- { MATE_MIXER_CHANNEL_FRONT_RIGHT_CENTER, "MATE_MIXER_CHANNEL_FRONT_RIGHT_CENTER", "front-right-center" },
- { MATE_MIXER_CHANNEL_BACK_CENTER, "MATE_MIXER_CHANNEL_BACK_CENTER", "back-center" },
+ { MATE_MIXER_CHANNEL_BACK_CENTER, "MATE_MIXER_STREAM_BACK_CENTER", "back-center" },
+ { MATE_MIXER_CHANNEL_FRONT_LEFT_CENTER, "MATE_MIXER_STREAM_FRONT_LEFT_CENTER", "front-left-center" },
+ { MATE_MIXER_CHANNEL_FRONT_RIGHT_CENTER, "MATE_MIXER_STREAM_FRONT_RIGHT_CENTER", "front-right-center" },
{ MATE_MIXER_CHANNEL_SIDE_LEFT, "MATE_MIXER_CHANNEL_SIDE_LEFT", "side-left" },
{ MATE_MIXER_CHANNEL_SIDE_RIGHT, "MATE_MIXER_CHANNEL_SIDE_RIGHT", "side-right" },
{ MATE_MIXER_CHANNEL_TOP_FRONT_LEFT, "MATE_MIXER_CHANNEL_TOP_FRONT_LEFT", "top-front-left" },
diff --git a/libmatemixer/matemixer-enum-types.h b/libmatemixer/matemixer-enum-types.h
index 7b6fcf0..03c1297 100644
--- a/libmatemixer/matemixer-enum-types.h
+++ b/libmatemixer/matemixer-enum-types.h
@@ -43,6 +43,12 @@ 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_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_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_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 4753aaf..a6326ce 100644
--- a/libmatemixer/matemixer-enums.h
+++ b/libmatemixer/matemixer-enums.h
@@ -23,8 +23,16 @@
* https://bugzilla.gnome.org/show_bug.cgi?id=621942
*/
+/**
+ * MateMixerState:
+ * @MATE_MIXER_STATE_IDLE:
+ * @MATE_MIXER_STATE_CONNECTING:
+ * @MATE_MIXER_STATE_READY:
+ * @MATE_MIXER_STATE_FAILED:
+ * @MATE_MIXER_STATE_UNKNOWN:
+ */
typedef enum {
- MATE_MIXER_STATE_IDLE = 0,
+ MATE_MIXER_STATE_IDLE,
MATE_MIXER_STATE_CONNECTING,
MATE_MIXER_STATE_READY,
MATE_MIXER_STATE_FAILED,
@@ -46,11 +54,18 @@ typedef enum {
* "real" backends fail to initialize.
*/
typedef enum {
- MATE_MIXER_BACKEND_UNKNOWN = 0,
+ MATE_MIXER_BACKEND_UNKNOWN,
MATE_MIXER_BACKEND_PULSEAUDIO,
MATE_MIXER_BACKEND_NULL
} MateMixerBackendType;
+/**
+ * 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,
@@ -58,33 +73,119 @@ typedef enum { /*< flags >*/
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_MUTE:
+ * @MATE_MIXER_STREAM_HAS_VOLUME:
+ * @MATE_MIXER_STREAM_HAS_DECIBEL_VOLUME:
+ * @MATE_MIXER_STREAM_HAS_FLAT_VOLUME:
+ * @MATE_MIXER_STREAM_HAS_MONITOR:
+ * @MATE_MIXER_STREAM_CAN_SET_VOLUME:
+ * @MATE_MIXER_STREAM_CAN_BALANCE:
+ * @MATE_MIXER_STREAM_CAN_FADE:
+ * @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_APPLICATION = 1 << 3,
- MATE_MIXER_STREAM_EVENT = 1 << 4,
- MATE_MIXER_STREAM_HAS_MUTE = 1 << 5,
- MATE_MIXER_STREAM_HAS_VOLUME = 1 << 6,
- MATE_MIXER_STREAM_HAS_DECIBEL_VOLUME = 1 << 7,
- MATE_MIXER_STREAM_HAS_FLAT_VOLUME = 1 << 8,
- MATE_MIXER_STREAM_HAS_MONITOR = 1 << 9,
- MATE_MIXER_STREAM_CAN_BALANCE = 1 << 10,
- MATE_MIXER_STREAM_CAN_FADE = 1 << 11,
- MATE_MIXER_STREAM_CAN_SET_VOLUME = 1 << 12,
- MATE_MIXER_STREAM_CAN_SUSPEND = 1 << 13
+ MATE_MIXER_STREAM_HAS_MUTE = 1 << 3,
+ MATE_MIXER_STREAM_HAS_VOLUME = 1 << 4,
+ MATE_MIXER_STREAM_HAS_DECIBEL_VOLUME = 1 << 5,
+ MATE_MIXER_STREAM_HAS_FLAT_VOLUME = 1 << 6,
+ MATE_MIXER_STREAM_HAS_MONITOR = 1 << 7,
+ MATE_MIXER_STREAM_CAN_SET_VOLUME = 1 << 8,
+ MATE_MIXER_STREAM_CAN_BALANCE = 1 << 9,
+ MATE_MIXER_STREAM_CAN_FADE = 1 << 10,
+ MATE_MIXER_STREAM_CAN_SUSPEND = 1 << 11
} MateMixerStreamFlags;
+/**
+ * MateMixerStreamState:
+ * @MATE_MIXER_STREAM_STATE_UNKNOWN:
+ * @MATE_MIXER_STREAM_STATE_RUNNING:
+ * @MATE_MIXER_STREAM_STATE_IDLE:
+ * @MATE_MIXER_STREAM_STATE_SUSPENDED:
+ */
typedef enum {
- MATE_MIXER_STREAM_UNKNOWN_STATE,
- MATE_MIXER_STREAM_RUNNING,
- MATE_MIXER_STREAM_IDLE,
- MATE_MIXER_STREAM_SUSPENDED
+ MATE_MIXER_STREAM_STATE_UNKNOWN,
+ MATE_MIXER_STREAM_STATE_RUNNING,
+ MATE_MIXER_STREAM_STATE_IDLE,
+ MATE_MIXER_STREAM_STATE_SUSPENDED
} MateMixerStreamState;
+/**
+ * MateMixerClientStreamFlags:
+ * @MATE_MIXER_CLIENT_STREAM_NO_FLAGS:
+ * @MATE_MIXER_CLIENT_STREAM_APPLICATION:
+ * @MATE_MIXER_CLIENT_STREAM_CACHED:
+ */
+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;
+
+/**
+ * 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;
+
+/**
+ * MateMixerChannelPosition:
+ * @MATE_MIXER_CHANNEL_UNKNOWN:
+ * @MATE_MIXER_CHANNEL_MONO:
+ * @MATE_MIXER_CHANNEL_FRONT_LEFT:
+ * @MATE_MIXER_CHANNEL_FRONT_RIGHT:
+ * @MATE_MIXER_CHANNEL_FRONT_CENTER:
+ * @MATE_MIXER_CHANNEL_LFE:
+ * @MATE_MIXER_CHANNEL_BACK_LEFT:
+ * @MATE_MIXER_CHANNEL_BACK_RIGHT:
+ * @MATE_MIXER_CHANNEL_BACK_CENTER:
+ * @MATE_MIXER_CHANNEL_FRONT_LEFT_CENTER:
+ * @MATE_MIXER_CHANNEL_FRONT_RIGHT_CENTER:
+ * @MATE_MIXER_CHANNEL_SIDE_LEFT:
+ * @MATE_MIXER_CHANNEL_SIDE_RIGHT:
+ * @MATE_MIXER_CHANNEL_TOP_FRONT_LEFT:
+ * @MATE_MIXER_CHANNEL_TOP_FRONT_RIGHT:
+ * @MATE_MIXER_CHANNEL_TOP_FRONT_CENTER:
+ * @MATE_MIXER_CHANNEL_TOP_CENTER:
+ * @MATE_MIXER_CHANNEL_TOP_BACK_LEFT:
+ * @MATE_MIXER_CHANNEL_TOP_BACK_RIGHT:
+ * @MATE_MIXER_CHANNEL_TOP_BACK_CENTER:
+ */
typedef enum {
- MATE_MIXER_CHANNEL_UNKNOWN_POSITION,
+ MATE_MIXER_CHANNEL_UNKNOWN,
MATE_MIXER_CHANNEL_MONO,
MATE_MIXER_CHANNEL_FRONT_LEFT,
MATE_MIXER_CHANNEL_FRONT_RIGHT,
@@ -92,9 +193,9 @@ typedef enum {
MATE_MIXER_CHANNEL_LFE,
MATE_MIXER_CHANNEL_BACK_LEFT,
MATE_MIXER_CHANNEL_BACK_RIGHT,
+ MATE_MIXER_CHANNEL_BACK_CENTER,
MATE_MIXER_CHANNEL_FRONT_LEFT_CENTER,
MATE_MIXER_CHANNEL_FRONT_RIGHT_CENTER,
- MATE_MIXER_CHANNEL_BACK_CENTER,
MATE_MIXER_CHANNEL_SIDE_LEFT,
MATE_MIXER_CHANNEL_SIDE_RIGHT,
MATE_MIXER_CHANNEL_TOP_FRONT_LEFT,
diff --git a/libmatemixer/matemixer-port-private.h b/libmatemixer/matemixer-port-private.h
new file mode 100644
index 0000000..a696d27
--- /dev/null
+++ b/libmatemixer/matemixer-port-private.h
@@ -0,0 +1,45 @@
+/*
+ * 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_PORT_PRIVATE_H
+#define MATEMIXER_PORT_PRIVATE_H
+
+#include <glib.h>
+
+#include "matemixer-enums.h"
+#include "matemixer-port.h"
+
+G_BEGIN_DECLS
+
+MateMixerPort *_mate_mixer_port_new (const gchar *name,
+ const gchar *description,
+ const gchar *icon,
+ guint priority,
+ MateMixerPortFlags flags);
+
+gboolean _mate_mixer_port_update_description (MateMixerPort *port,
+ const gchar *description);
+gboolean _mate_mixer_port_update_icon (MateMixerPort *port,
+ const gchar *icon);
+gboolean _mate_mixer_port_update_priority (MateMixerPort *port,
+ guint priority);
+gboolean _mate_mixer_port_update_flags (MateMixerPort *port,
+ MateMixerPortFlags flags);
+
+G_END_DECLS
+
+#endif /* MATEMIXER_PORT_PRIVATE_H */
diff --git a/libmatemixer/matemixer-port.c b/libmatemixer/matemixer-port.c
index 3a7670d..f89a8bb 100644
--- a/libmatemixer/matemixer-port.c
+++ b/libmatemixer/matemixer-port.c
@@ -21,6 +21,7 @@
#include "matemixer-enums.h"
#include "matemixer-enum-types.h"
#include "matemixer-port.h"
+#include "matemixer-port-private.h"
/**
* SECTION:matemixer-port
@@ -32,7 +33,7 @@ struct _MateMixerPortPrivate
gchar *name;
gchar *description;
gchar *icon;
- gulong priority;
+ guint priority;
MateMixerPortFlags flags;
};
@@ -102,15 +103,15 @@ mate_mixer_port_class_init (MateMixerPortClass *klass)
G_PARAM_STATIC_STRINGS);
properties[PROP_PRIORITY] =
- g_param_spec_ulong ("priority",
- "Priority",
- "Priority of the port",
- 0,
- G_MAXULONG,
- 0,
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS);
+ g_param_spec_uint ("priority",
+ "Priority",
+ "Priority of the port",
+ 0,
+ G_MAXUINT,
+ 0,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS);
properties[PROP_FLAGS] =
g_param_spec_flags ("flags",
@@ -148,7 +149,7 @@ mate_mixer_port_get_property (GObject *object,
g_value_set_string (value, port->priv->icon);
break;
case PROP_PRIORITY:
- g_value_set_ulong (value, port->priv->priority);
+ g_value_set_uint (value, port->priv->priority);
break;
case PROP_FLAGS:
g_value_set_flags (value, port->priv->flags);
@@ -183,7 +184,7 @@ mate_mixer_port_set_property (GObject *object,
port->priv->icon = g_strdup (g_value_get_string (value));
break;
case PROP_PRIORITY:
- port->priv->priority = g_value_get_ulong (value);
+ port->priv->priority = g_value_get_uint (value);
break;
case PROP_FLAGS:
port->priv->flags = g_value_get_flags (value);
@@ -216,22 +217,10 @@ mate_mixer_port_finalize (GObject *object)
G_OBJECT_CLASS (mate_mixer_port_parent_class)->finalize (object);
}
-MateMixerPort *
-mate_mixer_port_new (const gchar *name,
- const gchar *description,
- const gchar *icon,
- gulong priority,
- MateMixerPortFlags flags)
-{
- return g_object_new (MATE_MIXER_TYPE_PORT,
- "name", name,
- "description", description,
- "icon", icon,
- "priority", priority,
- "flags", flags,
- NULL);
-}
-
+/**
+ * mate_mixer_port_get_name:
+ * @port: a #MateMixerPort
+ */
const gchar *
mate_mixer_port_get_name (MateMixerPort *port)
{
@@ -240,6 +229,10 @@ mate_mixer_port_get_name (MateMixerPort *port)
return port->priv->name;
}
+/**
+ * mate_mixer_port_get_description:
+ * @port: a #MateMixerPort
+ */
const gchar *
mate_mixer_port_get_description (MateMixerPort *port)
{
@@ -248,6 +241,10 @@ mate_mixer_port_get_description (MateMixerPort *port)
return port->priv->description;
}
+/**
+ * mate_mixer_port_get_icon:
+ * @port: a #MateMixerPort
+ */
const gchar *
mate_mixer_port_get_icon (MateMixerPort *port)
{
@@ -256,7 +253,11 @@ mate_mixer_port_get_icon (MateMixerPort *port)
return port->priv->icon;
}
-gulong
+/**
+ * mate_mixer_port_get_priority:
+ * @port: a #MateMixerPort
+ */
+guint
mate_mixer_port_get_priority (MateMixerPort *port)
{
g_return_val_if_fail (MATE_MIXER_IS_PORT (port), 0);
@@ -264,6 +265,10 @@ mate_mixer_port_get_priority (MateMixerPort *port)
return port->priv->priority;
}
+/**
+ * mate_mixer_port_get_flags:
+ * @port: a #MateMixerPort
+ */
MateMixerPortFlags
mate_mixer_port_get_flags (MateMixerPort *port)
{
@@ -271,3 +276,83 @@ mate_mixer_port_get_flags (MateMixerPort *port)
return port->priv->flags;
}
+
+MateMixerPort *
+_mate_mixer_port_new (const gchar *name,
+ const gchar *description,
+ const gchar *icon,
+ guint priority,
+ MateMixerPortFlags flags)
+{
+ return g_object_new (MATE_MIXER_TYPE_PORT,
+ "name", name,
+ "description", description,
+ "icon", icon,
+ "priority", priority,
+ "flags", flags,
+ NULL);
+}
+
+gboolean
+_mate_mixer_port_update_description (MateMixerPort *port, const gchar *description)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_PORT (port), FALSE);
+
+ if (g_strcmp0 (port->priv->description, description) != 0) {
+ g_free (port->priv->description);
+
+ port->priv->description = g_strdup (description);
+
+ g_object_notify_by_pspec (G_OBJECT (port), properties[PROP_DESCRIPTION]);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+gboolean
+_mate_mixer_port_update_icon (MateMixerPort *port, const gchar *icon)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_PORT (port), FALSE);
+
+ if (g_strcmp0 (port->priv->icon, icon) != 0) {
+ g_free (port->priv->icon);
+
+ port->priv->icon = g_strdup (icon);
+
+ g_object_notify_by_pspec (G_OBJECT (port), properties[PROP_ICON]);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+gboolean
+_mate_mixer_port_update_priority (MateMixerPort *port, guint priority)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_PORT (port), FALSE);
+
+ if (port->priv->priority != priority) {
+ port->priv->priority = priority;
+
+ g_object_notify_by_pspec (G_OBJECT (port), properties[PROP_PRIORITY]);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+gboolean
+_mate_mixer_port_update_flags (MateMixerPort *port, MateMixerPortFlags flags)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_PORT (port), FALSE);
+
+ if (port->priv->flags != flags) {
+ port->priv->flags = flags;
+
+ g_object_notify_by_pspec (G_OBJECT (port), properties[PROP_FLAGS]);
+ return TRUE;
+ }
+
+ return FALSE;
+}
diff --git a/libmatemixer/matemixer-port.h b/libmatemixer/matemixer-port.h
index bda13ad..61f16f5 100644
--- a/libmatemixer/matemixer-port.h
+++ b/libmatemixer/matemixer-port.h
@@ -57,17 +57,11 @@ struct _MateMixerPortClass
GType mate_mixer_port_get_type (void) G_GNUC_CONST;
-MateMixerPort * mate_mixer_port_new (const gchar *name,
- const gchar *description,
- const gchar *icon,
- gulong priority,
- MateMixerPortFlags flags);
-
-const gchar * mate_mixer_port_get_name (MateMixerPort *port);
-const gchar * mate_mixer_port_get_description (MateMixerPort *port);
-const gchar * mate_mixer_port_get_icon (MateMixerPort *port);
-gulong mate_mixer_port_get_priority (MateMixerPort *port);
-MateMixerPortFlags mate_mixer_port_get_flags (MateMixerPort *port);
+const gchar * mate_mixer_port_get_name (MateMixerPort *port);
+const gchar * mate_mixer_port_get_description (MateMixerPort *port);
+const gchar * mate_mixer_port_get_icon (MateMixerPort *port);
+guint mate_mixer_port_get_priority (MateMixerPort *port);
+MateMixerPortFlags mate_mixer_port_get_flags (MateMixerPort *port);
G_END_DECLS
diff --git a/libmatemixer/matemixer-stream.c b/libmatemixer/matemixer-stream.c
index 6f63217..6bec2be 100644
--- a/libmatemixer/matemixer-stream.c
+++ b/libmatemixer/matemixer-stream.c
@@ -79,7 +79,7 @@ mate_mixer_stream_default_init (MateMixerStreamInterface *iface)
"State",
"Current state of the stream",
MATE_MIXER_TYPE_STREAM_STATE,
- MATE_MIXER_STREAM_UNKNOWN_STATE,
+ MATE_MIXER_STREAM_STATE_UNKNOWN,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
@@ -92,16 +92,6 @@ mate_mixer_stream_default_init (MateMixerStreamInterface *iface)
G_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface,
- g_param_spec_uint ("num-channels",
- "Number of channels",
- "Number of volume channels in the stream",
- 0,
- G_MAXUINT,
- 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- g_object_interface_install_property (iface,
g_param_spec_uint ("volume",
"Volume",
"Volume of the stream",
@@ -132,13 +122,6 @@ mate_mixer_stream_default_init (MateMixerStreamInterface *iface)
G_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface,
- g_param_spec_pointer ("ports",
- "Ports",
- "GList of the sound device ports",
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- g_object_interface_install_property (iface,
g_param_spec_object ("active-port",
"Active port",
"The currently active port of the stream",
@@ -215,14 +198,14 @@ mate_mixer_stream_get_state (MateMixerStream *stream)
{
MateMixerStreamInterface *iface;
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), MATE_MIXER_STREAM_UNKNOWN_STATE);
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), MATE_MIXER_STREAM_STATE_UNKNOWN);
iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
if (iface->get_state)
return iface->get_state (stream);
- return MATE_MIXER_STREAM_UNKNOWN_STATE;
+ return MATE_MIXER_STREAM_STATE_UNKNOWN;
}
gboolean
@@ -335,14 +318,14 @@ mate_mixer_stream_get_channel_position (MateMixerStream *stream, guint channel)
{
MateMixerStreamInterface *iface;
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), MATE_MIXER_CHANNEL_UNKNOWN_POSITION);
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), MATE_MIXER_CHANNEL_UNKNOWN);
iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
if (iface->get_channel_position)
return iface->get_channel_position (stream, channel);
- return MATE_MIXER_CHANNEL_UNKNOWN_POSITION;
+ return MATE_MIXER_CHANNEL_UNKNOWN;
}
guint
@@ -410,83 +393,17 @@ mate_mixer_stream_set_channel_decibel (MateMixerStream *stream,
}
gboolean
-mate_mixer_stream_has_position (MateMixerStream *stream,
- MateMixerChannelPosition position)
-{
- MateMixerStreamInterface *iface;
-
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), FALSE);
-
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
-
- if (iface->has_position)
- return iface->has_position (stream, position);
-
- return FALSE;
-}
-
-guint
-mate_mixer_stream_get_position_volume (MateMixerStream *stream,
- MateMixerChannelPosition position)
-{
- MateMixerStreamInterface *iface;
-
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), 0);
-
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
-
- if (iface->get_position_volume)
- return iface->get_position_volume (stream, position);
-
- return 0;
-}
-
-gboolean
-mate_mixer_stream_set_position_volume (MateMixerStream *stream,
- MateMixerChannelPosition position,
- guint volume)
-{
- MateMixerStreamInterface *iface;
-
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), FALSE);
-
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
-
- if (iface->set_position_volume)
- return iface->set_position_volume (stream, position, volume);
-
- return FALSE;
-}
-
-gdouble
-mate_mixer_stream_get_position_decibel (MateMixerStream *stream,
+mate_mixer_stream_has_channel_position (MateMixerStream *stream,
MateMixerChannelPosition position)
{
MateMixerStreamInterface *iface;
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), -MATE_MIXER_INFINITY);
-
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
-
- if (iface->get_position_decibel)
- return iface->get_position_decibel (stream, position);
-
- return -MATE_MIXER_INFINITY;
-}
-
-gboolean
-mate_mixer_stream_set_position_decibel (MateMixerStream *stream,
- MateMixerChannelPosition position,
- gdouble decibel)
-{
- MateMixerStreamInterface *iface;
-
g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), FALSE);
iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
- if (iface->set_position_decibel)
- return iface->set_position_decibel (stream, position, decibel);
+ if (iface->has_channel_position)
+ return iface->has_channel_position (stream, position);
return FALSE;
}
@@ -670,12 +587,12 @@ mate_mixer_stream_get_active_port (MateMixerStream *stream)
}
gboolean
-mate_mixer_stream_set_active_port (MateMixerStream *stream, const gchar *port)
+mate_mixer_stream_set_active_port (MateMixerStream *stream, MateMixerPort *port)
{
MateMixerStreamInterface *iface;
g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), FALSE);
- g_return_val_if_fail (port != NULL, FALSE);
+ g_return_val_if_fail (MATE_MIXER_IS_PORT (port), FALSE);
iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
diff --git a/libmatemixer/matemixer-stream.h b/libmatemixer/matemixer-stream.h
index 40a4463..e91a2a5 100644
--- a/libmatemixer/matemixer-stream.h
+++ b/libmatemixer/matemixer-stream.h
@@ -51,6 +51,7 @@ struct _MateMixerStreamInterface
GTypeInterface parent_iface;
/*< private >*/
+ /* Virtual table */
const gchar * (*get_name) (MateMixerStream *stream);
const gchar * (*get_description) (MateMixerStream *stream);
MateMixerDevice * (*get_device) (MateMixerStream *stream);
@@ -78,18 +79,8 @@ struct _MateMixerStreamInterface
gboolean (*set_channel_decibel) (MateMixerStream *stream,
guint channel,
gdouble decibel);
- gboolean (*has_position) (MateMixerStream *stream,
+ gboolean (*has_channel_position) (MateMixerStream *stream,
MateMixerChannelPosition position);
- guint (*get_position_volume) (MateMixerStream *stream,
- MateMixerChannelPosition position);
- gboolean (*set_position_volume) (MateMixerStream *stream,
- MateMixerChannelPosition position,
- guint volume);
- gdouble (*get_position_decibel) (MateMixerStream *stream,
- MateMixerChannelPosition position);
- gboolean (*set_position_decibel) (MateMixerStream *stream,
- MateMixerChannelPosition position,
- gdouble decibel);
gfloat (*get_balance) (MateMixerStream *stream);
gboolean (*set_balance) (MateMixerStream *stream,
gfloat balance);
@@ -106,7 +97,7 @@ struct _MateMixerStreamInterface
const GList * (*list_ports) (MateMixerStream *stream);
MateMixerPort * (*get_active_port) (MateMixerStream *stream);
gboolean (*set_active_port) (MateMixerStream *stream,
- const gchar *port);
+ MateMixerPort *port);
guint (*get_min_volume) (MateMixerStream *stream);
guint (*get_max_volume) (MateMixerStream *stream);
guint (*get_normal_volume) (MateMixerStream *stream);
@@ -117,86 +108,74 @@ struct _MateMixerStreamInterface
gdouble value);
};
-GType mate_mixer_stream_get_type (void) G_GNUC_CONST;
-
-const gchar * mate_mixer_stream_get_name (MateMixerStream *stream);
-const gchar * mate_mixer_stream_get_description (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);
-
-gboolean mate_mixer_stream_get_mute (MateMixerStream *stream);
-gboolean mate_mixer_stream_set_mute (MateMixerStream *stream,
- gboolean mute);
+GType mate_mixer_stream_get_type (void) G_GNUC_CONST;
-guint mate_mixer_stream_get_num_channels (MateMixerStream *stream);
+const gchar * mate_mixer_stream_get_name (MateMixerStream *stream);
+const gchar * mate_mixer_stream_get_description (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);
-guint mate_mixer_stream_get_volume (MateMixerStream *stream);
-gboolean mate_mixer_stream_set_volume (MateMixerStream *stream,
- guint volume);
+gboolean mate_mixer_stream_get_mute (MateMixerStream *stream);
+gboolean mate_mixer_stream_set_mute (MateMixerStream *stream,
+ gboolean mute);
-gdouble mate_mixer_stream_get_decibel (MateMixerStream *stream);
-gboolean mate_mixer_stream_set_decibel (MateMixerStream *stream,
- gdouble decibel);
+guint mate_mixer_stream_get_num_channels (MateMixerStream *stream);
-MateMixerChannelPosition mate_mixer_stream_get_channel_position (MateMixerStream *stream,
- guint channel);
+guint mate_mixer_stream_get_volume (MateMixerStream *stream);
+gboolean mate_mixer_stream_set_volume (MateMixerStream *stream,
+ guint volume);
-guint mate_mixer_stream_get_channel_volume (MateMixerStream *stream,
- guint channel);
-gboolean mate_mixer_stream_set_channel_volume (MateMixerStream *stream,
- guint channel,
- guint volume);
+gdouble mate_mixer_stream_get_decibel (MateMixerStream *stream);
+gboolean mate_mixer_stream_set_decibel (MateMixerStream *stream,
+ gdouble decibel);
-gdouble mate_mixer_stream_get_channel_decibel (MateMixerStream *stream,
- guint channel);
-gboolean mate_mixer_stream_set_channel_decibel (MateMixerStream *stream,
- guint channel,
- gdouble decibel);
+MateMixerChannelPosition mate_mixer_stream_get_channel_position (MateMixerStream *stream,
+ guint channel);
-gboolean mate_mixer_stream_has_position (MateMixerStream *stream,
- MateMixerChannelPosition position);
+guint mate_mixer_stream_get_channel_volume (MateMixerStream *stream,
+ guint channel);
+gboolean mate_mixer_stream_set_channel_volume (MateMixerStream *stream,
+ guint channel,
+ guint volume);
-guint mate_mixer_stream_get_position_volume (MateMixerStream *stream,
- MateMixerChannelPosition position);
-gboolean mate_mixer_stream_set_position_volume (MateMixerStream *stream,
- MateMixerChannelPosition position,
- guint volume);
+gdouble mate_mixer_stream_get_channel_decibel (MateMixerStream *stream,
+ guint channel);
+gboolean mate_mixer_stream_set_channel_decibel (MateMixerStream *stream,
+ guint channel,
+ gdouble decibel);
-gdouble mate_mixer_stream_get_position_decibel (MateMixerStream *stream,
- MateMixerChannelPosition position);
-gboolean mate_mixer_stream_set_position_decibel (MateMixerStream *stream,
- MateMixerChannelPosition position,
- gdouble decibel);
+gboolean mate_mixer_stream_has_channel_position (MateMixerStream *stream,
+ MateMixerChannelPosition position);
-gfloat mate_mixer_stream_get_balance (MateMixerStream *stream);
-gboolean mate_mixer_stream_set_balance (MateMixerStream *stream,
- gfloat balance);
+gfloat mate_mixer_stream_get_balance (MateMixerStream *stream);
+gboolean mate_mixer_stream_set_balance (MateMixerStream *stream,
+ gfloat balance);
-gfloat mate_mixer_stream_get_fade (MateMixerStream *stream);
-gboolean mate_mixer_stream_set_fade (MateMixerStream *stream,
- gfloat fade);
+gfloat mate_mixer_stream_get_fade (MateMixerStream *stream);
+gboolean mate_mixer_stream_set_fade (MateMixerStream *stream,
+ gfloat fade);
-gboolean mate_mixer_stream_suspend (MateMixerStream *stream);
-gboolean mate_mixer_stream_resume (MateMixerStream *stream);
+gboolean mate_mixer_stream_suspend (MateMixerStream *stream);
+gboolean mate_mixer_stream_resume (MateMixerStream *stream);
-gboolean mate_mixer_stream_monitor_start (MateMixerStream *stream);
-void mate_mixer_stream_monitor_stop (MateMixerStream *stream);
+gboolean mate_mixer_stream_monitor_start (MateMixerStream *stream);
+void mate_mixer_stream_monitor_stop (MateMixerStream *stream);
-gboolean mate_mixer_stream_monitor_is_running (MateMixerStream *stream);
-gboolean mate_mixer_stream_monitor_set_name (MateMixerStream *stream,
- const gchar *name);
+gboolean mate_mixer_stream_monitor_is_running (MateMixerStream *stream);
+gboolean mate_mixer_stream_monitor_set_name (MateMixerStream *stream,
+ const gchar *name);
-const GList * mate_mixer_stream_list_ports (MateMixerStream *stream);
+const GList * mate_mixer_stream_list_ports (MateMixerStream *stream);
-MateMixerPort * mate_mixer_stream_get_active_port (MateMixerStream *stream);
-gboolean mate_mixer_stream_set_active_port (MateMixerStream *stream,
- const gchar *port);
+MateMixerPort * mate_mixer_stream_get_active_port (MateMixerStream *stream);
+gboolean mate_mixer_stream_set_active_port (MateMixerStream *stream,
+ MateMixerPort *port);
-guint mate_mixer_stream_get_min_volume (MateMixerStream *stream);
-guint mate_mixer_stream_get_max_volume (MateMixerStream *stream);
-guint mate_mixer_stream_get_normal_volume (MateMixerStream *stream);
-guint mate_mixer_stream_get_base_volume (MateMixerStream *stream);
+guint mate_mixer_stream_get_min_volume (MateMixerStream *stream);
+guint mate_mixer_stream_get_max_volume (MateMixerStream *stream);
+guint mate_mixer_stream_get_normal_volume (MateMixerStream *stream);
+guint mate_mixer_stream_get_base_volume (MateMixerStream *stream);
G_END_DECLS
diff --git a/libmatemixer/matemixer.c b/libmatemixer/matemixer.c
index 8965599..0ca09b9 100644
--- a/libmatemixer/matemixer.c
+++ b/libmatemixer/matemixer.c
@@ -25,11 +25,19 @@
#include "matemixer-private.h"
#include "matemixer-backend-module.h"
-static void mixer_load_modules (void);
-static gint mixer_compare_modules (gconstpointer a, gconstpointer b);
+/**
+ * SECTION:matemixer
+ * @short_description: Library initialization and support functions
+ * @title: MateMixer
+ * @include: libmatemixer/matemixer.h
+ */
+
+static void load_modules (void);
+static gint compare_modules (gconstpointer a,
+ gconstpointer b);
-static GList *mixer_modules = NULL;
-static gboolean mixer_initialized = FALSE;
+static GList *modules = NULL;
+static gboolean initialized = FALSE;
/**
* mate_mixer_init:
@@ -43,89 +51,89 @@ static gboolean mixer_initialized = FALSE;
gboolean
mate_mixer_init (void)
{
- if (!mixer_initialized) {
- mixer_load_modules ();
-
- if (mixer_modules) {
- GList *list;
-
- list = mixer_modules;
- while (list) {
- GTypeModule *module = G_TYPE_MODULE (list->data);
- GList *next = list->next;
-
- /* Attempt to load the module and remove it from the list
- * if it isn't usable */
- if (!g_type_module_use (module)) {
- g_object_unref (module);
- mixer_modules = g_list_delete_link (mixer_modules, list);
- }
- list = next;
- }
+ if (initialized == TRUE)
+ return TRUE;
+
+ load_modules ();
+
+ if (modules != NULL) {
+ GList *list = modules;
- if (mixer_modules) {
- /* Sort the usable modules by their priority */
- mixer_modules = g_list_sort (mixer_modules, mixer_compare_modules);
- mixer_initialized = TRUE;
- } else
- g_critical ("No usable backend modules have been found");
+ while (list != NULL) {
+ GTypeModule *module = G_TYPE_MODULE (list->data);
+ GList *next = list->next;
+
+ /* Load the plugin and remove it from the list if it fails */
+ if (g_type_module_use (module) == FALSE) {
+ g_object_unref (module);
+ modules = g_list_delete_link (modules, list);
+ }
+ list = next;
}
- }
- return mixer_initialized;
+ if (modules != NULL) {
+ /* Sort the usable modules by priority */
+ modules = g_list_sort (modules, compare_modules);
+ initialized = TRUE;
+ } else
+ g_critical ("No usable backend modules have been found");
+ } else
+ g_critical ("No backend modules have been found");
+
+ return initialized;
}
/**
* mate_mixer_is_initialized:
*
- * Returns TRUE if the library has been initialized.
+ * Returns %TRUE if the library has been initialized.
*
- * Returns: %TRUE or %FALSE
+ * Returns: %TRUE or %FALSE.
*/
gboolean
mate_mixer_is_initialized (void)
{
- return mixer_initialized;
+ return initialized;
}
/**
* mate_mixer_deinit:
*
- * Deinitializes the library. You should call this function when you do not need
- * to use the library any longer or before exitting the application.
+ * Deinitializes the library. You should call this function when you are done
+ * using the library.
*/
void
mate_mixer_deinit (void)
{
GList *list;
- if (!mixer_initialized)
+ if (initialized == FALSE)
return;
- list = mixer_modules;
- while (list) {
+ list = modules;
+ while (list != NULL) {
g_type_module_unuse (G_TYPE_MODULE (list->data));
list = list->next;
}
- mixer_initialized = FALSE;
+ initialized = FALSE;
}
/* Internal function: return a list of loaded backend modules */
const GList *
mate_mixer_get_modules (void)
{
- return (const GList *) mixer_modules;
+ return (const GList *) modules;
}
static void
-mixer_load_modules (void)
+load_modules (void)
{
static gboolean loaded = FALSE;
- if (loaded)
+ if (loaded == TRUE)
return;
- if (g_module_supported ()) {
+ if (G_LIKELY (g_module_supported () == TRUE)) {
GDir *dir;
GError *error = NULL;
@@ -138,34 +146,29 @@ mixer_load_modules (void)
while ((name = g_dir_read_name (dir)) != NULL) {
gchar *file;
- if (!g_str_has_suffix (name, "." G_MODULE_SUFFIX))
+ if (g_str_has_suffix (name, "." G_MODULE_SUFFIX) == FALSE)
continue;
file = g_build_filename (LIBMATEMIXER_BACKEND_DIR, name, NULL);
- mixer_modules = g_list_prepend (mixer_modules,
- mate_mixer_backend_module_new (file));
+ modules = g_list_prepend (modules, mate_mixer_backend_module_new (file));
g_free (file);
}
- if (mixer_modules == NULL)
- g_critical ("No backend modules have been found");
-
g_dir_close (dir);
} else {
g_critical ("%s", error->message);
g_error_free (error);
}
} else {
- g_critical ("Unable to load backend modules: GModule is not supported in your system");
+ g_critical ("Unable to load backend modules: not supported");
}
loaded = TRUE;
}
-/* GCompareFunc function to sort backend modules by the priority, higher number means
- * higher priority */
+/* Backend modules sorting function, higher priority number means higher priority */
static gint
-mixer_compare_modules (gconstpointer a, gconstpointer b)
+compare_modules (gconstpointer a, gconstpointer b)
{
const MateMixerBackendInfo *info1, *info2;