summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libmatemixer/matemixer-app-info.h1
-rw-r--r--libmatemixer/matemixer-backend-module.c7
-rw-r--r--libmatemixer/matemixer-backend.c38
-rw-r--r--libmatemixer/matemixer-backend.h56
-rw-r--r--libmatemixer/matemixer-context.c60
-rw-r--r--libmatemixer/matemixer-device.c19
-rw-r--r--libmatemixer/matemixer-private.h4
-rw-r--r--libmatemixer/matemixer-stream-control.c236
-rw-r--r--libmatemixer/matemixer-stream-control.h195
-rw-r--r--libmatemixer/matemixer-stream.c22
-rw-r--r--libmatemixer/matemixer-stream.h1
-rw-r--r--libmatemixer/matemixer-switch.c15
-rw-r--r--libmatemixer/matemixer-switch.h12
-rw-r--r--libmatemixer/matemixer-toggle.c5
-rw-r--r--libmatemixer/matemixer.c4
15 files changed, 323 insertions, 352 deletions
diff --git a/libmatemixer/matemixer-app-info.h b/libmatemixer/matemixer-app-info.h
index eedc1c7..69aa6f9 100644
--- a/libmatemixer/matemixer-app-info.h
+++ b/libmatemixer/matemixer-app-info.h
@@ -26,7 +26,6 @@
G_BEGIN_DECLS
#define MATE_MIXER_TYPE_APP_INFO (mate_mixer_app_info_get_type ())
-#define MATE_MIXER_APP_INFO(o) ((MateMixerAppInfo *) o)
GType mate_mixer_app_info_get_type (void) G_GNUC_CONST;
diff --git a/libmatemixer/matemixer-backend-module.c b/libmatemixer/matemixer-backend-module.c
index 7981b9f..f5f7994 100644
--- a/libmatemixer/matemixer-backend-module.c
+++ b/libmatemixer/matemixer-backend-module.c
@@ -124,7 +124,7 @@ mate_mixer_backend_module_set_property (GObject *object,
switch (param_id) {
case PROP_PATH:
/* Construct-only string */
- module->priv->path = g_strdup (g_value_get_string (value));
+ module->priv->path = g_value_dup_string (value);
g_type_module_set_name (G_TYPE_MODULE (object), module->priv->path);
break;
@@ -234,7 +234,8 @@ backend_module_load (GTypeModule *type_module)
return TRUE;
module->priv->gmodule = g_module_open (module->priv->path,
- G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
+ G_MODULE_BIND_LAZY |
+ G_MODULE_BIND_LOCAL);
if (module->priv->gmodule == NULL) {
g_warning ("Failed to load backend module %s: %s",
module->priv->path,
@@ -263,7 +264,7 @@ backend_module_load (GTypeModule *type_module)
/* Make sure get_info() returns something, so we can avoid checking it
* in other parts of the library */
- if (G_UNLIKELY (module->priv->get_info () == NULL)) {
+ if G_UNLIKELY (module->priv->get_info () == NULL) {
g_critical ("Backend module %s does not provide module information",
module->priv->path);
diff --git a/libmatemixer/matemixer-backend.c b/libmatemixer/matemixer-backend.c
index 4201e4a..56efd94 100644
--- a/libmatemixer/matemixer-backend.c
+++ b/libmatemixer/matemixer-backend.c
@@ -425,7 +425,7 @@ mate_mixer_backend_list_devices (MateMixerBackend *backend)
klass = MATE_MIXER_BACKEND_GET_CLASS (backend);
- if G_LIKELY (klass->list_devices != NULL)
+ if (klass->list_devices != NULL)
return klass->list_devices (backend);
return NULL;
@@ -440,7 +440,7 @@ mate_mixer_backend_list_streams (MateMixerBackend *backend)
klass = MATE_MIXER_BACKEND_GET_CLASS (backend);
- if G_LIKELY (klass->list_streams != NULL)
+ if (klass->list_streams != NULL)
return klass->list_streams (backend);
return NULL;
@@ -473,21 +473,26 @@ gboolean
mate_mixer_backend_set_default_input_stream (MateMixerBackend *backend,
MateMixerStream *stream)
{
+ MateMixerBackendClass *klass;
+
g_return_val_if_fail (MATE_MIXER_IS_BACKEND (backend), FALSE);
g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), FALSE);
- if (backend->priv->default_input != stream) {
- MateMixerBackendClass *klass;
+ klass = MATE_MIXER_BACKEND_GET_CLASS (backend);
+ if (klass->set_default_input_stream == NULL)
+ return FALSE;
- klass = MATE_MIXER_BACKEND_GET_CLASS (backend);
+ if (backend->priv->default_input != stream) {
+ if (mate_mixer_stream_get_direction (stream) != MATE_MIXER_DIRECTION_INPUT) {
+ g_warning ("Unable to set non-input stream as the default input stream");
+ return FALSE;
+ }
- if (klass->set_default_input_stream == NULL ||
- klass->set_default_input_stream (backend, stream) == FALSE)
+ if (klass->set_default_input_stream (backend, stream) == FALSE)
return FALSE;
_mate_mixer_backend_set_default_input_stream (backend, stream);
}
-
return TRUE;
}
@@ -503,21 +508,26 @@ gboolean
mate_mixer_backend_set_default_output_stream (MateMixerBackend *backend,
MateMixerStream *stream)
{
+ MateMixerBackendClass *klass;
+
g_return_val_if_fail (MATE_MIXER_IS_BACKEND (backend), FALSE);
g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), FALSE);
- if (backend->priv->default_input != stream) {
- MateMixerBackendClass *klass;
+ klass = MATE_MIXER_BACKEND_GET_CLASS (backend);
+ if (klass->set_default_output_stream == NULL)
+ return FALSE;
- klass = MATE_MIXER_BACKEND_GET_CLASS (backend);
+ if (backend->priv->default_input != stream) {
+ if (mate_mixer_stream_get_direction (stream) != MATE_MIXER_DIRECTION_OUTPUT) {
+ g_warning ("Unable to set non-output stream as the default output stream");
+ return FALSE;
+ }
- if (klass->set_default_output_stream == NULL ||
- klass->set_default_output_stream (backend, stream) == FALSE)
+ if (klass->set_default_output_stream (backend, stream) == FALSE)
return FALSE;
_mate_mixer_backend_set_default_output_stream (backend, stream);
}
-
return TRUE;
}
diff --git a/libmatemixer/matemixer-backend.h b/libmatemixer/matemixer-backend.h
index 06082f9..08dc92c 100644
--- a/libmatemixer/matemixer-backend.h
+++ b/libmatemixer/matemixer-backend.h
@@ -90,44 +90,44 @@ struct _MateMixerBackendClass
GType mate_mixer_backend_get_type (void) G_GNUC_CONST;
-void mate_mixer_backend_set_app_info (MateMixerBackend *backend,
- MateMixerAppInfo *info);
-void mate_mixer_backend_set_server_address (MateMixerBackend *backend,
- const gchar *address);
+void mate_mixer_backend_set_app_info (MateMixerBackend *backend,
+ MateMixerAppInfo *info);
+void mate_mixer_backend_set_server_address (MateMixerBackend *backend,
+ const gchar *address);
-gboolean mate_mixer_backend_open (MateMixerBackend *backend);
-void mate_mixer_backend_close (MateMixerBackend *backend);
+gboolean mate_mixer_backend_open (MateMixerBackend *backend);
+void mate_mixer_backend_close (MateMixerBackend *backend);
-MateMixerState mate_mixer_backend_get_state (MateMixerBackend *backend);
+MateMixerState mate_mixer_backend_get_state (MateMixerBackend *backend);
-MateMixerDevice * mate_mixer_backend_get_device (MateMixerBackend *backend,
- const gchar *name);
-MateMixerStream * mate_mixer_backend_get_stream (MateMixerBackend *backend,
- const gchar *name);
-MateMixerStoredControl *mate_mixer_backend_get_stored_control (MateMixerBackend *backend,
- const gchar *name);
+MateMixerDevice * mate_mixer_backend_get_device (MateMixerBackend *backend,
+ const gchar *name);
+MateMixerStream * mate_mixer_backend_get_stream (MateMixerBackend *backend,
+ const gchar *name);
+MateMixerStoredControl *mate_mixer_backend_get_stored_control (MateMixerBackend *backend,
+ const gchar *name);
-const GList * mate_mixer_backend_list_devices (MateMixerBackend *backend);
-const GList * mate_mixer_backend_list_streams (MateMixerBackend *backend);
-const GList * mate_mixer_backend_list_stored_controls (MateMixerBackend *backend);
+const GList * mate_mixer_backend_list_devices (MateMixerBackend *backend);
+const GList * mate_mixer_backend_list_streams (MateMixerBackend *backend);
+const GList * mate_mixer_backend_list_stored_controls (MateMixerBackend *backend);
-MateMixerStream * mate_mixer_backend_get_default_input_stream (MateMixerBackend *backend);
-gboolean mate_mixer_backend_set_default_input_stream (MateMixerBackend *backend,
- MateMixerStream *stream);
+MateMixerStream * mate_mixer_backend_get_default_input_stream (MateMixerBackend *backend);
+gboolean mate_mixer_backend_set_default_input_stream (MateMixerBackend *backend,
+ MateMixerStream *stream);
-MateMixerStream * mate_mixer_backend_get_default_output_stream (MateMixerBackend *backend);
-gboolean mate_mixer_backend_set_default_output_stream (MateMixerBackend *backend,
- MateMixerStream *stream);
+MateMixerStream * mate_mixer_backend_get_default_output_stream (MateMixerBackend *backend);
+gboolean mate_mixer_backend_set_default_output_stream (MateMixerBackend *backend,
+ MateMixerStream *stream);
/* Protected functions */
-void _mate_mixer_backend_set_state (MateMixerBackend *backend,
- MateMixerState state);
+void _mate_mixer_backend_set_state (MateMixerBackend *backend,
+ MateMixerState state);
-void _mate_mixer_backend_set_default_input_stream (MateMixerBackend *backend,
- MateMixerStream *stream);
+void _mate_mixer_backend_set_default_input_stream (MateMixerBackend *backend,
+ MateMixerStream *stream);
-void _mate_mixer_backend_set_default_output_stream (MateMixerBackend *backend,
- MateMixerStream *stream);
+void _mate_mixer_backend_set_default_output_stream (MateMixerBackend *backend,
+ MateMixerStream *stream);
G_END_DECLS
diff --git a/libmatemixer/matemixer-context.c b/libmatemixer/matemixer-context.c
index 0251d97..dacbc9a 100644
--- a/libmatemixer/matemixer-context.c
+++ b/libmatemixer/matemixer-context.c
@@ -15,7 +15,6 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#include <string.h>
#include <glib.h>
#include <glib-object.h>
@@ -582,18 +581,20 @@ mate_mixer_context_new (void)
* be used to alter this behavior and make the @context use the selected sound
* system.
*
- * Setting the sound system backend only succeeds if the selected backend module
- * is available in the target system.
+ * Setting the backend type only succeeds if the selected backend module is
+ * available in the target system.
+ *
+ * If you have used this function before and want restore the default automatic
+ * backend type discovery, set the backend type to %MATE_MIXER_BACKEND_UNKNOWN.
*
* This function must be used before opening a connection to a sound system with
* mate_mixer_context_open(), otherwise it will fail.
*
* Returns: %TRUE on success or %FALSE on failure.
*/
-// XXX handle UNKNOWN
gboolean
-mate_mixer_context_set_backend_type (MateMixerContext *context,
- MateMixerBackendType backend_type)
+mate_mixer_context_set_backend_type (MateMixerContext *context,
+ MateMixerBackendType backend_type)
{
MateMixerBackendModule *module;
const GList *modules;
@@ -605,8 +606,13 @@ mate_mixer_context_set_backend_type (MateMixerContext *context,
context->priv->state == MATE_MIXER_STATE_READY)
return FALSE;
- modules = _mate_mixer_list_modules ();
+ /* Allow setting the backend to unknown to restore the auto-detection */
+ if (backend_type == MATE_MIXER_BACKEND_UNKNOWN) {
+ context->priv->backend_type = backend_type;
+ return TRUE;
+ }
+ modules = _mate_mixer_list_modules ();
while (modules != NULL) {
module = MATE_MIXER_BACKEND_MODULE (modules->data);
info = mate_mixer_backend_module_get_info (module);
@@ -644,9 +650,7 @@ mate_mixer_context_set_app_name (MateMixerContext *context, const gchar *app_nam
_mate_mixer_app_info_set_name (context->priv->app_info, app_name);
- g_object_notify_by_pspec (G_OBJECT (context),
- properties[PROP_APP_NAME]);
-
+ g_object_notify_by_pspec (G_OBJECT (context), properties[PROP_APP_NAME]);
return TRUE;
}
@@ -674,9 +678,7 @@ mate_mixer_context_set_app_id (MateMixerContext *context, const gchar *app_id)
_mate_mixer_app_info_set_id (context->priv->app_info, app_id);
- g_object_notify_by_pspec (G_OBJECT (context),
- properties[PROP_APP_ID]);
-
+ g_object_notify_by_pspec (G_OBJECT (context), properties[PROP_APP_ID]);
return TRUE;
}
@@ -704,9 +706,7 @@ mate_mixer_context_set_app_version (MateMixerContext *context, const gchar *app_
_mate_mixer_app_info_set_version (context->priv->app_info, app_version);
- g_object_notify_by_pspec (G_OBJECT (context),
- properties[PROP_APP_VERSION]);
-
+ g_object_notify_by_pspec (G_OBJECT (context), properties[PROP_APP_VERSION]);
return TRUE;
}
@@ -734,9 +734,7 @@ mate_mixer_context_set_app_icon (MateMixerContext *context, const gchar *app_ico
_mate_mixer_app_info_set_icon (context->priv->app_info, app_icon);
- g_object_notify_by_pspec (G_OBJECT (context),
- properties[PROP_APP_ICON]);
-
+ g_object_notify_by_pspec (G_OBJECT (context), properties[PROP_APP_ICON]);
return TRUE;
}
@@ -767,9 +765,7 @@ mate_mixer_context_set_server_address (MateMixerContext *context, const gchar *a
context->priv->server_address = g_strdup (address);
- g_object_notify_by_pspec (G_OBJECT (context),
- properties[PROP_SERVER_ADDRESS]);
-
+ g_object_notify_by_pspec (G_OBJECT (context), properties[PROP_SERVER_ADDRESS]);
return TRUE;
}
@@ -820,7 +816,7 @@ mate_mixer_context_open (MateMixerContext *context)
return FALSE;
/* We are going to choose the first backend to try. It will be either the one
- * specified by the application or the one with the highest priority */
+ * selected by the application or the one with the highest priority */
modules = _mate_mixer_list_modules ();
if (context->priv->backend_type != MATE_MIXER_BACKEND_UNKNOWN) {
@@ -877,8 +873,8 @@ mate_mixer_context_open (MateMixerContext *context)
state = mate_mixer_backend_get_state (context->priv->backend);
- if (G_UNLIKELY (state != MATE_MIXER_STATE_READY &&
- state != MATE_MIXER_STATE_CONNECTING)) {
+ if G_UNLIKELY (state != MATE_MIXER_STATE_READY &&
+ state != MATE_MIXER_STATE_CONNECTING) {
/* This would be a backend bug */
g_warn_if_reached ();
@@ -1108,11 +1104,6 @@ mate_mixer_context_set_default_input_stream (MateMixerContext *context,
if (context->priv->state != MATE_MIXER_STATE_READY)
return FALSE;
- if (mate_mixer_stream_get_direction (stream) != MATE_MIXER_DIRECTION_INPUT) {
- g_warning ("Unable to set non-input stream as the default input stream");
- return FALSE;
- }
-
return mate_mixer_backend_set_default_input_stream (context->priv->backend, stream);
}
@@ -1159,11 +1150,6 @@ mate_mixer_context_set_default_output_stream (MateMixerContext *context,
if (context->priv->state != MATE_MIXER_STATE_READY)
return FALSE;
- if (mate_mixer_stream_get_direction (stream) != MATE_MIXER_DIRECTION_OUTPUT) {
- g_warning ("Unable to set non-output stream as the default output stream");
- return FALSE;
- }
-
return mate_mixer_backend_set_default_output_stream (context->priv->backend, stream);
}
@@ -1398,8 +1384,8 @@ try_next_backend (MateMixerContext *context)
state = mate_mixer_backend_get_state (context->priv->backend);
- if (G_UNLIKELY (state != MATE_MIXER_STATE_READY &&
- state != MATE_MIXER_STATE_CONNECTING)) {
+ if G_UNLIKELY (state != MATE_MIXER_STATE_READY &&
+ state != MATE_MIXER_STATE_CONNECTING) {
/* This would be a backend bug */
g_warn_if_reached ();
diff --git a/libmatemixer/matemixer-device.c b/libmatemixer/matemixer-device.c
index f45f9b9..f9d368b 100644
--- a/libmatemixer/matemixer-device.c
+++ b/libmatemixer/matemixer-device.c
@@ -76,18 +76,18 @@ static void mate_mixer_device_finalize (GObject *object);
G_DEFINE_ABSTRACT_TYPE (MateMixerDevice, mate_mixer_device, G_TYPE_OBJECT)
-static MateMixerStream *mate_mixer_device_real_get_stream (MateMixerDevice *device,
- const gchar *name);
-static MateMixerSwitch *mate_mixer_device_real_get_switch (MateMixerDevice *device,
- const gchar *name);
+static MateMixerStream *mate_mixer_device_real_get_stream (MateMixerDevice *device,
+ const gchar *name);
+static MateMixerSwitch *mate_mixer_device_real_get_switch (MateMixerDevice *device,
+ const gchar *name);
static void
mate_mixer_device_class_init (MateMixerDeviceClass *klass)
{
GObjectClass *object_class;
- klass->get_stream = mate_mixer_device_real_get_stream;
- klass->get_switch = mate_mixer_device_real_get_switch;
+ klass->get_stream = mate_mixer_device_real_get_stream;
+ klass->get_switch = mate_mixer_device_real_get_switch;
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = mate_mixer_device_finalize;
@@ -252,6 +252,7 @@ mate_mixer_device_get_property (GObject *object,
case PROP_ICON:
g_value_set_string (value, device->priv->icon);
break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -271,15 +272,15 @@ mate_mixer_device_set_property (GObject *object,
switch (param_id) {
case PROP_NAME:
/* Construct-only string */
- device->priv->name = g_strdup (g_value_get_string (value));
+ device->priv->name = g_value_dup_string (value);
break;
case PROP_LABEL:
/* Construct-only string */
- device->priv->label = g_strdup (g_value_get_string (value));
+ device->priv->label = g_value_dup_string (value);
break;
case PROP_ICON:
/* Construct-only string */
- device->priv->icon = g_strdup (g_value_get_string (value));
+ device->priv->icon = g_value_dup_string (value);
break;
default:
diff --git a/libmatemixer/matemixer-private.h b/libmatemixer/matemixer-private.h
index 41cd2e7..37c430d 100644
--- a/libmatemixer/matemixer-private.h
+++ b/libmatemixer/matemixer-private.h
@@ -106,10 +106,10 @@ G_BEGIN_DECLS
#define MATE_MIXER_CHANNEL_MASK_HAS_FRONT(m) ((m) & MATE_MIXER_CHANNEL_MASK_FRONT)
#define MATE_MIXER_CHANNEL_MASK_HAS_BACK(m) ((m) & MATE_MIXER_CHANNEL_MASK_BACK)
-G_GNUC_INTERNAL
const GList *_mate_mixer_list_modules (void);
-guint32 _mate_mixer_create_channel_mask (MateMixerChannelPosition *positions, guint n);
+guint32 _mate_mixer_create_channel_mask (MateMixerChannelPosition *positions,
+ guint n) G_GNUC_PURE;
G_END_DECLS
diff --git a/libmatemixer/matemixer-stream-control.c b/libmatemixer/matemixer-stream-control.c
index 161396e..5d97709 100644
--- a/libmatemixer/matemixer-stream-control.c
+++ b/libmatemixer/matemixer-stream-control.c
@@ -374,12 +374,11 @@ mate_mixer_stream_control_get_app_info (MateMixerStreamControl *control)
g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), NULL);
if (control->priv->role == MATE_MIXER_STREAM_CONTROL_ROLE_APPLICATION) {
- MateMixerStreamControlClass *klass;
+ MateMixerStreamControlClass *klass =
+ MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
-
- if G_LIKELY (klass->get_app_info != NULL)
- return klass->get_app_info (control);
+ /* Implementation required for application role controls */
+ return klass->get_app_info (control);
}
return NULL;
}
@@ -405,15 +404,17 @@ gboolean
mate_mixer_stream_control_set_stream (MateMixerStreamControl *control,
MateMixerStream *stream)
{
- g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), 0);
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), FALSE);
- if (control->priv->stream != stream) {
- MateMixerStreamControlClass *klass;
+ if ((control->priv->flags & MATE_MIXER_STREAM_CONTROL_MOVABLE) == 0)
+ return FALSE;
- klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
+ if (control->priv->stream != stream) {
+ MateMixerStreamControlClass *klass =
+ MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- if (klass->set_stream == NULL ||
- klass->set_stream (control, stream) == FALSE)
+ /* Implementation required when the flag is available */
+ if (klass->set_stream (control, stream) == FALSE)
return FALSE;
_mate_mixer_stream_control_set_stream (control, stream);
@@ -443,22 +444,20 @@ mate_mixer_stream_control_set_mute (MateMixerStreamControl *control, gboolean mu
{
g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), FALSE);
- if (control->priv->mute == mute)
- return TRUE;
-
- if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_MUTE_WRITABLE) {
- MateMixerStreamControlClass *klass;
+ if ((control->priv->flags & MATE_MIXER_STREAM_CONTROL_MUTE_WRITABLE) == 0)
+ return FALSE;
- klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
+ if (control->priv->mute != mute) {
+ MateMixerStreamControlClass *klass =
+ MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- if (klass->set_mute == NULL ||
- klass->set_mute (control, mute) == FALSE)
+ /* Implementation required when the flag is available */
+ if (klass->set_mute (control, mute) == FALSE)
return FALSE;
_mate_mixer_stream_control_set_mute (control, mute);
- return TRUE;
}
- return FALSE;
+ return TRUE;
}
/**
@@ -494,8 +493,8 @@ mate_mixer_stream_control_get_volume (MateMixerStreamControl *control)
klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_VOLUME_READABLE) {
- if G_LIKELY (klass->get_volume != NULL)
- return klass->get_volume (control);
+ /* Implementation required when the flag is available */
+ return klass->get_volume (control);
}
return klass->get_min_volume (control);
}
@@ -511,12 +510,11 @@ mate_mixer_stream_control_set_volume (MateMixerStreamControl *control, guint vol
g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), FALSE);
if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_VOLUME_WRITABLE) {
- MateMixerStreamControlClass *klass;
+ MateMixerStreamControlClass *klass =
+ MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
-
- if G_LIKELY (klass->set_volume != NULL)
- return klass->set_volume (control, volume);
+ /* Implementation required when the flag is available */
+ return klass->set_volume (control, volume);
}
return FALSE;
}
@@ -530,13 +528,13 @@ mate_mixer_stream_control_get_decibel (MateMixerStreamControl *control)
{
g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), -MATE_MIXER_INFINITY);
- if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL) {
- MateMixerStreamControlClass *klass;
-
- klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
+ if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL &&
+ control->priv->flags & MATE_MIXER_STREAM_CONTROL_VOLUME_READABLE) {
+ MateMixerStreamControlClass *klass =
+ MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- if G_LIKELY (klass->get_decibel != NULL)
- return klass->get_decibel (control);
+ /* Implementation required when the flags are available */
+ return klass->get_decibel (control);
}
return -MATE_MIXER_INFINITY;
}
@@ -553,12 +551,11 @@ mate_mixer_stream_control_set_decibel (MateMixerStreamControl *control, gdouble
if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL &&
control->priv->flags & MATE_MIXER_STREAM_CONTROL_VOLUME_WRITABLE) {
- MateMixerStreamControlClass *klass;
-
- klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
+ MateMixerStreamControlClass *klass =
+ MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- if G_LIKELY (klass->set_decibel != NULL)
- return klass->set_decibel (control, decibel);
+ /* Implementation required when the flags are available */
+ return klass->set_decibel (control, decibel);
}
return FALSE;
}
@@ -569,8 +566,8 @@ mate_mixer_stream_control_set_decibel (MateMixerStreamControl *control, gdouble
* @position: to channel position to check
*/
gboolean
-mate_mixer_stream_control_has_channel_position (MateMixerStreamControl *control,
- MateMixerChannelPosition position)
+mate_mixer_stream_control_has_channel_position (MateMixerStreamControl *control,
+ MateMixerChannelPosition position)
{
MateMixerStreamControlClass *klass;
@@ -612,17 +609,17 @@ mate_mixer_stream_control_get_channel_position (MateMixerStreamControl *control,
guint
mate_mixer_stream_control_get_channel_volume (MateMixerStreamControl *control, guint channel)
{
- g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), 0);
+ MateMixerStreamControlClass *klass;
- if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_VOLUME_READABLE) {
- MateMixerStreamControlClass *klass;
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), 0);
- klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
+ klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- if G_LIKELY (klass->get_channel_volume != NULL)
- return klass->get_channel_volume (control, channel);
+ if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_VOLUME_READABLE) {
+ /* Implementation required when the flag is available */
+ return klass->get_channel_volume (control, channel);
}
- return 0;
+ return klass->get_min_volume (control);
}
/**
@@ -638,13 +635,12 @@ mate_mixer_stream_control_set_channel_volume (MateMixerStreamControl *control,
{
g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), FALSE);
- if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_VOLUME_READABLE) {
- MateMixerStreamControlClass *klass;
-
- klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
+ if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_VOLUME_WRITABLE) {
+ MateMixerStreamControlClass *klass =
+ MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- if G_LIKELY (klass->set_channel_volume != NULL)
- return klass->set_channel_volume (control, channel, volume);
+ /* Implementation required when the flag is available */
+ return klass->set_channel_volume (control, channel, volume);
}
return FALSE;
}
@@ -659,13 +655,13 @@ mate_mixer_stream_control_get_channel_decibel (MateMixerStreamControl *control,
{
g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), -MATE_MIXER_INFINITY);
- if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL) {
- MateMixerStreamControlClass *klass;
-
- klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
+ if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL &&
+ control->priv->flags & MATE_MIXER_STREAM_CONTROL_VOLUME_READABLE) {
+ MateMixerStreamControlClass *klass =
+ MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- if G_LIKELY (klass->get_channel_decibel != NULL)
- return klass->get_channel_decibel (control, channel);
+ /* Implementation required when the flags are available */
+ return klass->get_channel_decibel (control, channel);
}
return -MATE_MIXER_INFINITY;
}
@@ -683,13 +679,13 @@ mate_mixer_stream_control_set_channel_decibel (MateMixerStreamControl *control,
{
g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), FALSE);
- if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL) {
- MateMixerStreamControlClass *klass;
-
- klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
+ if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL &&
+ control->priv->flags & MATE_MIXER_STREAM_CONTROL_VOLUME_WRITABLE) {
+ MateMixerStreamControlClass *klass =
+ MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- if G_LIKELY (klass->set_channel_decibel != NULL)
- return klass->set_channel_decibel (control, channel, decibel);
+ /* Implementation required when the flags are available */
+ return klass->set_channel_decibel (control, channel, decibel);
}
return FALSE;
}
@@ -718,23 +714,22 @@ gboolean
mate_mixer_stream_control_set_balance (MateMixerStreamControl *control, gfloat balance)
{
g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), FALSE);
+ g_return_val_if_fail (balance >= -1.0f && balance <= 1.0f, FALSE);
- if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_CAN_BALANCE) {
- MateMixerStreamControlClass *klass;
-
- if (balance < -1.0f || balance > 1.0f)
- return FALSE;
+ if ((control->priv->flags & MATE_MIXER_STREAM_CONTROL_CAN_BALANCE) == 0)
+ return FALSE;
- klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
+ if (control->priv->balance != balance) {
+ MateMixerStreamControlClass *klass =
+ MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- if (klass->set_balance == NULL ||
- klass->set_balance (control, balance) == FALSE)
+ /* Implementation required when the flag is available */
+ if (klass->set_balance (control, balance) == FALSE)
return FALSE;
_mate_mixer_stream_control_set_balance (control, balance);
- return TRUE;
}
- return FALSE;
+ return TRUE;
}
/**
@@ -761,23 +756,22 @@ gboolean
mate_mixer_stream_control_set_fade (MateMixerStreamControl *control, gfloat fade)
{
g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), FALSE);
+ g_return_val_if_fail (fade >= -1.0f && fade <= 1.0f, FALSE);
- if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_CAN_FADE) {
- MateMixerStreamControlClass *klass;
+ if ((control->priv->flags & MATE_MIXER_STREAM_CONTROL_CAN_FADE) == 0)
+ return FALSE;
- if (fade < -1.0f || fade > 1.0f)
- return FALSE;
+ if (control->priv->fade != fade) {
+ MateMixerStreamControlClass *klass =
+ MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
-
- if (klass->set_fade == NULL ||
- klass->set_fade (control, fade) == FALSE)
+ /* Implementation required when the flag is available */
+ if (klass->set_fade (control, fade) == FALSE)
return FALSE;
_mate_mixer_stream_control_set_fade (control, fade);
- return TRUE;
}
- return FALSE;
+ return TRUE;
}
/**
@@ -790,11 +784,11 @@ mate_mixer_stream_control_get_monitor_enabled (MateMixerStreamControl *control)
g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), FALSE);
if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_HAS_MONITOR) {
- MateMixerStreamControlClass *klass;
+ MateMixerStreamControlClass *klass =
+ MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- if (klass->get_monitor_enabled != NULL)
- return klass->get_monitor_enabled (control);
+ /* Implementation required when the flag is available */
+ return klass->get_monitor_enabled (control);
}
return FALSE;
}
@@ -809,25 +803,11 @@ mate_mixer_stream_control_set_monitor_enabled (MateMixerStreamControl *control,
{
g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), FALSE);
- if (enabled == mate_mixer_stream_control_get_monitor_enabled (control))
- return TRUE;
-
- if (control->priv->flags & MATE_MIXER_STREAM_CONTROL_HAS_MONITOR) {
- MateMixerStreamControlClass *klass;
+ if ((control->priv->flags & MATE_MIXER_STREAM_CONTROL_HAS_MONITOR) == 0)
+ return FALSE;
- klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
- if (klass->set_monitor_enabled == NULL ||
- klass->set_monitor_enabled (control, enabled) == FALSE)
- return FALSE;
-
- if (enabled == TRUE)
- g_debug ("Control %s monitor enabled",
- control->priv->name);
- else
- g_debug ("Control %s monitor disabled",
- control->priv->name);
- }
- return FALSE;
+ /* Implementation required when the flag is available */
+ return MATE_MIXER_STREAM_CONTROL_GET_CLASS (control)->set_monitor_enabled (control, enabled);
}
/**
@@ -837,16 +817,10 @@ mate_mixer_stream_control_set_monitor_enabled (MateMixerStreamControl *control,
guint
mate_mixer_stream_control_get_min_volume (MateMixerStreamControl *control)
{
- MateMixerStreamControlClass *klass;
-
g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), 0);
- klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
-
- if (klass->get_min_volume != NULL)
- return klass->get_min_volume (control);
-
- return 0;
+ /* Implementation required */
+ return MATE_MIXER_STREAM_CONTROL_GET_CLASS (control)->get_min_volume (control);
}
/**
@@ -856,16 +830,10 @@ mate_mixer_stream_control_get_min_volume (MateMixerStreamControl *control)
guint
mate_mixer_stream_control_get_max_volume (MateMixerStreamControl *control)
{
- MateMixerStreamControlClass *klass;
-
g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), 0);
- klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
-
- if (klass->get_max_volume != NULL)
- return klass->get_max_volume (control);
-
- return 0;
+ /* Implementation required */
+ return MATE_MIXER_STREAM_CONTROL_GET_CLASS (control)->get_max_volume (control);
}
/**
@@ -875,16 +843,10 @@ mate_mixer_stream_control_get_max_volume (MateMixerStreamControl *control)
guint
mate_mixer_stream_control_get_normal_volume (MateMixerStreamControl *control)
{
- MateMixerStreamControlClass *klass;
-
g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), 0);
- klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
-
- if (klass->get_normal_volume != NULL)
- return klass->get_normal_volume (control);
-
- return 0;
+ /* Implementation required */
+ return MATE_MIXER_STREAM_CONTROL_GET_CLASS (control)->get_normal_volume (control);
}
/**
@@ -894,16 +856,10 @@ mate_mixer_stream_control_get_normal_volume (MateMixerStreamControl *control)
guint
mate_mixer_stream_control_get_base_volume (MateMixerStreamControl *control)
{
- MateMixerStreamControlClass *klass;
-
g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), 0);
- klass = MATE_MIXER_STREAM_CONTROL_GET_CLASS (control);
-
- if (klass->get_base_volume != NULL)
- return klass->get_base_volume (control);
-
- return 0;
+ /* Implementation required */
+ return MATE_MIXER_STREAM_CONTROL_GET_CLASS (control)->get_base_volume (control);
}
/* Protected functions */
diff --git a/libmatemixer/matemixer-stream-control.h b/libmatemixer/matemixer-stream-control.h
index bcedd24..fe9faca 100644
--- a/libmatemixer/matemixer-stream-control.h
+++ b/libmatemixer/matemixer-stream-control.h
@@ -74,122 +74,121 @@ struct _MateMixerStreamControlClass
GObjectClass parent_class;
/*< private >*/
- MateMixerAppInfo * (*get_app_info) (MateMixerStreamControl *control);
+ MateMixerAppInfo * (*get_app_info) (MateMixerStreamControl *control);
- gboolean (*set_stream) (MateMixerStreamControl *control,
- MateMixerStream *stream);
+ gboolean (*set_stream) (MateMixerStreamControl *control,
+ MateMixerStream *stream);
- gboolean (*set_mute) (MateMixerStreamControl *control,
- gboolean mute);
+ gboolean (*set_mute) (MateMixerStreamControl *control,
+ gboolean mute);
- guint (*get_num_channels) (MateMixerStreamControl *control);
+ guint (*get_num_channels) (MateMixerStreamControl *control);
- guint (*get_volume) (MateMixerStreamControl *control);
- gboolean (*set_volume) (MateMixerStreamControl *control,
- guint volume);
+ guint (*get_volume) (MateMixerStreamControl *control);
+ gboolean (*set_volume) (MateMixerStreamControl *control,
+ guint volume);
- gdouble (*get_decibel) (MateMixerStreamControl *control);
- gboolean (*set_decibel) (MateMixerStreamControl *control,
- gdouble decibel);
+ gdouble (*get_decibel) (MateMixerStreamControl *control);
+ gboolean (*set_decibel) (MateMixerStreamControl *control,
+ gdouble decibel);
- gboolean (*has_channel_position) (MateMixerStreamControl *control,
- MateMixerChannelPosition position);
- MateMixerChannelPosition (*get_channel_position) (MateMixerStreamControl *control,
- guint channel);
+ gboolean (*has_channel_position) (MateMixerStreamControl *control,
+ MateMixerChannelPosition position);
+ MateMixerChannelPosition (*get_channel_position) (MateMixerStreamControl *control,
+ guint channel);
- guint (*get_channel_volume) (MateMixerStreamControl *control,
- guint channel);
- gboolean (*set_channel_volume) (MateMixerStreamControl *control,
- guint channel,
- guint volume);
+ guint (*get_channel_volume) (MateMixerStreamControl *control,
+ guint channel);
+ gboolean (*set_channel_volume) (MateMixerStreamControl *control,
+ guint channel,
+ guint volume);
- gdouble (*get_channel_decibel) (MateMixerStreamControl *control,
- guint channel);
- gboolean (*set_channel_decibel) (MateMixerStreamControl *control,
- guint channel,
- gdouble decibel);
+ gdouble (*get_channel_decibel) (MateMixerStreamControl *control,
+ guint channel);
+ gboolean (*set_channel_decibel) (MateMixerStreamControl *control,
+ guint channel,
+ gdouble decibel);
- gboolean (*set_balance) (MateMixerStreamControl *control,
- gfloat balance);
+ gboolean (*set_balance) (MateMixerStreamControl *control,
+ gfloat balance);
- gboolean (*set_fade) (MateMixerStreamControl *control,
- gfloat fade);
+ gboolean (*set_fade) (MateMixerStreamControl *control,
+ gfloat fade);
- gboolean (*get_monitor_enabled) (MateMixerStreamControl *control);
- gboolean (*set_monitor_enabled) (MateMixerStreamControl *control,
- gboolean enabled);
+ gboolean (*get_monitor_enabled) (MateMixerStreamControl *control);
+ gboolean (*set_monitor_enabled) (MateMixerStreamControl *control,
+ gboolean enabled);
- guint (*get_min_volume) (MateMixerStreamControl *control);
- guint (*get_max_volume) (MateMixerStreamControl *control);
- guint (*get_normal_volume) (MateMixerStreamControl *control);
- guint (*get_base_volume) (MateMixerStreamControl *control);
+ guint (*get_min_volume) (MateMixerStreamControl *control);
+ guint (*get_max_volume) (MateMixerStreamControl *control);
+ guint (*get_normal_volume) (MateMixerStreamControl *control);
+ guint (*get_base_volume) (MateMixerStreamControl *control);
/* Signals */
- void (*monitor_value) (MateMixerStreamControl *control,
- gdouble value);
+ void (*monitor_value) (MateMixerStreamControl *control, gdouble value);
};
GType mate_mixer_stream_control_get_type (void) G_GNUC_CONST;
-const gchar * mate_mixer_stream_control_get_name (MateMixerStreamControl *control);
-const gchar * mate_mixer_stream_control_get_label (MateMixerStreamControl *control);
-MateMixerStreamControlFlags mate_mixer_stream_control_get_flags (MateMixerStreamControl *control);
-MateMixerStreamControlRole mate_mixer_stream_control_get_role (MateMixerStreamControl *control);
-MateMixerStreamControlMediaRole mate_mixer_stream_control_get_media_role (MateMixerStreamControl *control);
-
-MateMixerAppInfo * mate_mixer_stream_control_get_app_info (MateMixerStreamControl *control);
-
-MateMixerStream * mate_mixer_stream_control_get_stream (MateMixerStreamControl *control);
-gboolean mate_mixer_stream_control_set_stream (MateMixerStreamControl *control,
- MateMixerStream *stream);
-
-gboolean mate_mixer_stream_control_get_mute (MateMixerStreamControl *control);
-gboolean mate_mixer_stream_control_set_mute (MateMixerStreamControl *control,
- gboolean mute);
-
-guint mate_mixer_stream_control_get_num_channels (MateMixerStreamControl *control);
-
-guint mate_mixer_stream_control_get_volume (MateMixerStreamControl *control);
-gboolean mate_mixer_stream_control_set_volume (MateMixerStreamControl *control,
- guint volume);
-
-gdouble mate_mixer_stream_control_get_decibel (MateMixerStreamControl *control);
-gboolean mate_mixer_stream_control_set_decibel (MateMixerStreamControl *control,
- gdouble decibel);
-
-gboolean mate_mixer_stream_control_has_channel_position (MateMixerStreamControl *control,
- MateMixerChannelPosition position);
-MateMixerChannelPosition mate_mixer_stream_control_get_channel_position (MateMixerStreamControl *control,
- guint channel);
-
-guint mate_mixer_stream_control_get_channel_volume (MateMixerStreamControl *control,
- guint channel);
-gboolean mate_mixer_stream_control_set_channel_volume (MateMixerStreamControl *control,
- guint channel,
- guint volume);
-
-gdouble mate_mixer_stream_control_get_channel_decibel (MateMixerStreamControl *control,
- guint channel);
-gboolean mate_mixer_stream_control_set_channel_decibel (MateMixerStreamControl *control,
- guint channel,
- gdouble decibel);
-
-gfloat mate_mixer_stream_control_get_balance (MateMixerStreamControl *control);
-gboolean mate_mixer_stream_control_set_balance (MateMixerStreamControl *control,
- gfloat balance);
-
-gfloat mate_mixer_stream_control_get_fade (MateMixerStreamControl *control);
-gboolean mate_mixer_stream_control_set_fade (MateMixerStreamControl *control,
- gfloat fade);
-
-gboolean mate_mixer_stream_control_get_monitor_enabled (MateMixerStreamControl *control);
-gboolean mate_mixer_stream_control_set_monitor_enabled (MateMixerStreamControl *control,
- gboolean enabled);
-
-guint mate_mixer_stream_control_get_min_volume (MateMixerStreamControl *control);
-guint mate_mixer_stream_control_get_max_volume (MateMixerStreamControl *control);
-guint mate_mixer_stream_control_get_normal_volume (MateMixerStreamControl *control);
-guint mate_mixer_stream_control_get_base_volume (MateMixerStreamControl *control);
+const gchar * mate_mixer_stream_control_get_name (MateMixerStreamControl *control);
+const gchar * mate_mixer_stream_control_get_label (MateMixerStreamControl *control);
+MateMixerStreamControlFlags mate_mixer_stream_control_get_flags (MateMixerStreamControl *control);
+MateMixerStreamControlRole mate_mixer_stream_control_get_role (MateMixerStreamControl *control);
+MateMixerStreamControlMediaRole mate_mixer_stream_control_get_media_role (MateMixerStreamControl *control);
+
+MateMixerAppInfo * mate_mixer_stream_control_get_app_info (MateMixerStreamControl *control);
+
+MateMixerStream * mate_mixer_stream_control_get_stream (MateMixerStreamControl *control);
+gboolean mate_mixer_stream_control_set_stream (MateMixerStreamControl *control,
+ MateMixerStream *stream);
+
+gboolean mate_mixer_stream_control_get_mute (MateMixerStreamControl *control);
+gboolean mate_mixer_stream_control_set_mute (MateMixerStreamControl *control,
+ gboolean mute);
+
+guint mate_mixer_stream_control_get_num_channels (MateMixerStreamControl *control);
+
+guint mate_mixer_stream_control_get_volume (MateMixerStreamControl *control);
+gboolean mate_mixer_stream_control_set_volume (MateMixerStreamControl *control,
+ guint volume);
+
+gdouble mate_mixer_stream_control_get_decibel (MateMixerStreamControl *control);
+gboolean mate_mixer_stream_control_set_decibel (MateMixerStreamControl *control,
+ gdouble decibel);
+
+gboolean mate_mixer_stream_control_has_channel_position (MateMixerStreamControl *control,
+ MateMixerChannelPosition position);
+MateMixerChannelPosition mate_mixer_stream_control_get_channel_position (MateMixerStreamControl *control,
+ guint channel);
+
+guint mate_mixer_stream_control_get_channel_volume (MateMixerStreamControl *control,
+ guint channel);
+gboolean mate_mixer_stream_control_set_channel_volume (MateMixerStreamControl *control,
+ guint channel,
+ guint volume);
+
+gdouble mate_mixer_stream_control_get_channel_decibel (MateMixerStreamControl *control,
+ guint channel);
+gboolean mate_mixer_stream_control_set_channel_decibel (MateMixerStreamControl *control,
+ guint channel,
+ gdouble decibel);
+
+gfloat mate_mixer_stream_control_get_balance (MateMixerStreamControl *control);
+gboolean mate_mixer_stream_control_set_balance (MateMixerStreamControl *control,
+ gfloat balance);
+
+gfloat mate_mixer_stream_control_get_fade (MateMixerStreamControl *control);
+gboolean mate_mixer_stream_control_set_fade (MateMixerStreamControl *control,
+ gfloat fade);
+
+gboolean mate_mixer_stream_control_get_monitor_enabled (MateMixerStreamControl *control);
+gboolean mate_mixer_stream_control_set_monitor_enabled (MateMixerStreamControl *control,
+ gboolean enabled);
+
+guint mate_mixer_stream_control_get_min_volume (MateMixerStreamControl *control);
+guint mate_mixer_stream_control_get_max_volume (MateMixerStreamControl *control);
+guint mate_mixer_stream_control_get_normal_volume (MateMixerStreamControl *control);
+guint mate_mixer_stream_control_get_base_volume (MateMixerStreamControl *control);
G_END_DECLS
diff --git a/libmatemixer/matemixer-stream.c b/libmatemixer/matemixer-stream.c
index a4e2de4..3d8b96e 100644
--- a/libmatemixer/matemixer-stream.c
+++ b/libmatemixer/matemixer-stream.c
@@ -300,6 +300,7 @@ mate_mixer_stream_finalize (GObject *object)
stream = MATE_MIXER_STREAM (object);
g_free (stream->priv->name);
+ g_free (stream->priv->label);
G_OBJECT_CLASS (mate_mixer_stream_parent_class)->finalize (object);
}
@@ -399,9 +400,16 @@ mate_mixer_stream_get_default_control (MateMixerStream *stream)
const GList *
mate_mixer_stream_list_controls (MateMixerStream *stream)
{
+ MateMixerStreamClass *klass;
+
g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), NULL);
- return MATE_MIXER_STREAM_GET_CLASS (stream)->list_controls (stream);
+ klass = MATE_MIXER_STREAM_GET_CLASS (stream);
+
+ if G_LIKELY (klass->list_controls != NULL)
+ return klass->list_controls (stream);
+
+ return NULL;
}
/**
@@ -411,9 +419,16 @@ mate_mixer_stream_list_controls (MateMixerStream *stream)
const GList *
mate_mixer_stream_list_switches (MateMixerStream *stream)
{
+ MateMixerStreamClass *klass;
+
g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), NULL);
- return MATE_MIXER_STREAM_GET_CLASS (stream)->list_switches (stream);
+ klass = MATE_MIXER_STREAM_GET_CLASS (stream);
+
+ if G_LIKELY (klass->list_switches != NULL)
+ return klass->list_switches (stream);
+
+ return NULL;
}
static MateMixerStreamControl *
@@ -483,6 +498,5 @@ _mate_mixer_stream_set_default_control (MateMixerStream *stream,
mate_mixer_stream_get_name (stream));
}
- g_object_notify_by_pspec (G_OBJECT (stream),
- properties[PROP_DEFAULT_CONTROL]);
+ g_object_notify_by_pspec (G_OBJECT (stream), properties[PROP_DEFAULT_CONTROL]);
}
diff --git a/libmatemixer/matemixer-stream.h b/libmatemixer/matemixer-stream.h
index 969095b..7f7c857 100644
--- a/libmatemixer/matemixer-stream.h
+++ b/libmatemixer/matemixer-stream.h
@@ -91,6 +91,7 @@ GType mate_mixer_stream_get_type (void) G_GNUC_CONS
const gchar * mate_mixer_stream_get_name (MateMixerStream *stream);
const gchar * mate_mixer_stream_get_label (MateMixerStream *stream);
+
MateMixerDirection mate_mixer_stream_get_direction (MateMixerStream *stream);
MateMixerDevice * mate_mixer_stream_get_device (MateMixerStream *stream);
diff --git a/libmatemixer/matemixer-switch.c b/libmatemixer/matemixer-switch.c
index 926c9a6..87580dd 100644
--- a/libmatemixer/matemixer-switch.c
+++ b/libmatemixer/matemixer-switch.c
@@ -356,14 +356,16 @@ gboolean
mate_mixer_switch_set_active_option (MateMixerSwitch *swtch,
MateMixerSwitchOption *option)
{
+ MateMixerSwitchClass *klass;
+
g_return_val_if_fail (MATE_MIXER_IS_SWITCH (swtch), FALSE);
- if (swtch->priv->active != option) {
- MateMixerSwitchClass *klass;
+ klass = MATE_MIXER_SWITCH_GET_CLASS (swtch);
+ if (klass->set_active_option == NULL)
+ return FALSE;
- klass = MATE_MIXER_SWITCH_GET_CLASS (swtch);
- if (klass->set_active_option == NULL ||
- klass->set_active_option (swtch, option) == FALSE)
+ if (swtch->priv->active != option) {
+ if (klass->set_active_option (swtch, option) == FALSE)
return FALSE;
_mate_mixer_switch_set_active_option (swtch, option);
@@ -409,8 +411,7 @@ _mate_mixer_switch_set_active_option (MateMixerSwitch *swtch,
else
swtch->priv->active = NULL;
- g_object_notify_by_pspec (G_OBJECT (swtch),
- properties[PROP_ACTIVE_OPTION]);
+ g_object_notify_by_pspec (G_OBJECT (swtch), properties[PROP_ACTIVE_OPTION]);
}
static MateMixerSwitchOption *
diff --git a/libmatemixer/matemixer-switch.h b/libmatemixer/matemixer-switch.h
index 5ebbd32..7881486 100644
--- a/libmatemixer/matemixer-switch.h
+++ b/libmatemixer/matemixer-switch.h
@@ -26,17 +26,17 @@
G_BEGIN_DECLS
-#define MATE_MIXER_TYPE_SWITCH \
+#define MATE_MIXER_TYPE_SWITCH \
(mate_mixer_switch_get_type ())
-#define MATE_MIXER_SWITCH(o) \
+#define MATE_MIXER_SWITCH(o) \
(G_TYPE_CHECK_INSTANCE_CAST ((o), MATE_MIXER_TYPE_SWITCH, MateMixerSwitch))
-#define MATE_MIXER_IS_SWITCH(o) \
+#define MATE_MIXER_IS_SWITCH(o) \
(G_TYPE_CHECK_INSTANCE_TYPE ((o), MATE_MIXER_TYPE_SWITCH))
-#define MATE_MIXER_SWITCH_CLASS(k) \
+#define MATE_MIXER_SWITCH_CLASS(k) \
(G_TYPE_CHECK_CLASS_CAST ((k), MATE_MIXER_TYPE_SWITCH, MateMixerSwitchClass))
-#define MATE_MIXER_IS_SWITCH_CLASS(k) \
+#define MATE_MIXER_IS_SWITCH_CLASS(k) \
(G_TYPE_CHECK_CLASS_TYPE ((k), MATE_MIXER_TYPE_SWITCH))
-#define MATE_MIXER_SWITCH_GET_CLASS(o) \
+#define MATE_MIXER_SWITCH_GET_CLASS(o) \
(G_TYPE_INSTANCE_GET_CLASS ((o), MATE_MIXER_TYPE_SWITCH, MateMixerSwitchClass))
typedef struct _MateMixerSwitchClass MateMixerSwitchClass;
diff --git a/libmatemixer/matemixer-toggle.c b/libmatemixer/matemixer-toggle.c
index 5a85076..78f7f5b 100644
--- a/libmatemixer/matemixer-toggle.c
+++ b/libmatemixer/matemixer-toggle.c
@@ -92,7 +92,7 @@ mate_mixer_toggle_class_init (MateMixerToggleClass *klass)
"State",
"Current state of the toggle",
FALSE,
- G_PARAM_READABLE |
+ G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS);
/**
@@ -166,6 +166,9 @@ mate_mixer_toggle_set_property (GObject *object,
toggle = MATE_MIXER_TOGGLE (object);
switch (param_id) {
+ case PROP_STATE:
+ mate_mixer_toggle_set_state (toggle, g_value_get_boolean (value));
+ break;
case PROP_ON_STATE_OPTION:
/* Construct-only object */
toggle->priv->on = g_value_dup_object (value);
diff --git a/libmatemixer/matemixer.c b/libmatemixer/matemixer.c
index 51dc029..5e7c825 100644
--- a/libmatemixer/matemixer.c
+++ b/libmatemixer/matemixer.c
@@ -153,7 +153,7 @@ load_modules (void)
if (loaded == TRUE)
return;
- if (G_LIKELY (g_module_supported () == TRUE)) {
+ if G_LIKELY (g_module_supported () == TRUE) {
GDir *dir;
GError *error = NULL;
@@ -181,7 +181,7 @@ load_modules (void)
g_error_free (error);
}
} else {
- g_critical ("Unable to load backend modules: not supported");
+ g_critical ("Unable to load backend modules: Not supported");
}
loaded = TRUE;