summaryrefslogtreecommitdiff
path: root/libmatemixer
diff options
context:
space:
mode:
authorMichal Ratajsky <[email protected]>2014-07-25 23:47:46 +0200
committerMichal Ratajsky <[email protected]>2014-07-25 23:47:46 +0200
commit59a9aabf7b66e130f68b797c5a3674798fae437b (patch)
tree2645bf1511fb6e23540941796373b60a04767bfb /libmatemixer
parent0bc3aa762cd794da510f03229840d939ee7bc0c9 (diff)
downloadlibmatemixer-59a9aabf7b66e130f68b797c5a3674798fae437b.tar.bz2
libmatemixer-59a9aabf7b66e130f68b797c5a3674798fae437b.tar.xz
Support OSS
Diffstat (limited to 'libmatemixer')
-rw-r--r--libmatemixer/Makefile.am4
-rw-r--r--libmatemixer/matemixer-backend.c33
-rw-r--r--libmatemixer/matemixer-enum-types.c31
-rw-r--r--libmatemixer/matemixer-enum-types.h3
-rw-r--r--libmatemixer/matemixer-enums.h55
-rw-r--r--libmatemixer/matemixer-stream-control.c445
-rw-r--r--libmatemixer/matemixer-stream-control.h148
-rw-r--r--libmatemixer/matemixer-stream.c475
-rw-r--r--libmatemixer/matemixer-stream.h156
9 files changed, 813 insertions, 537 deletions
diff --git a/libmatemixer/Makefile.am b/libmatemixer/Makefile.am
index 8c219d4..9666684 100644
--- a/libmatemixer/Makefile.am
+++ b/libmatemixer/Makefile.am
@@ -17,6 +17,7 @@ libmatemixer_include_HEADERS = \
matemixer-enums.h \
matemixer-port.h \
matemixer-stream.h \
+ matemixer-stream-control.h \
matemixer-version.h
libmatemixer_la_CFLAGS = $(GLIB_CFLAGS)
@@ -37,7 +38,8 @@ libmatemixer_la_SOURCES = \
matemixer-enum-types.h \
matemixer-port.c \
matemixer-port-private.h \
- matemixer-stream.c
+ matemixer-stream.c \
+ matemixer-stream-control.c
libmatemixer_la_LIBADD = $(GLIB_LIBS)
diff --git a/libmatemixer/matemixer-backend.c b/libmatemixer/matemixer-backend.c
index be5c704..e070090 100644
--- a/libmatemixer/matemixer-backend.c
+++ b/libmatemixer/matemixer-backend.c
@@ -176,10 +176,15 @@ mate_mixer_backend_close (MateMixerBackend *backend)
MateMixerState
mate_mixer_backend_get_state (MateMixerBackend *backend)
{
+ MateMixerState state = MATE_MIXER_STATE_UNKNOWN;
+
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);
+ g_object_get (G_OBJECT (backend),
+ "state", &state,
+ NULL);
+
+ return state;
}
GList *
@@ -230,16 +235,18 @@ mate_mixer_backend_list_cached_streams (MateMixerBackend *backend)
MateMixerStream *
mate_mixer_backend_get_default_input_stream (MateMixerBackend *backend)
{
- MateMixerBackendInterface *iface;
+ MateMixerStream *stream = NULL;
g_return_val_if_fail (MATE_MIXER_IS_BACKEND (backend), NULL);
- iface = MATE_MIXER_BACKEND_GET_INTERFACE (backend);
+ g_object_get (G_OBJECT (stream),
+ "default-input", &stream,
+ NULL);
- if (iface->get_default_input_stream)
- return iface->get_default_input_stream (backend);
+ if (stream != NULL)
+ g_object_unref (stream);
- return NULL;
+ return stream;
}
gboolean
@@ -261,16 +268,18 @@ mate_mixer_backend_set_default_input_stream (MateMixerBackend *backend,
MateMixerStream *
mate_mixer_backend_get_default_output_stream (MateMixerBackend *backend)
{
- MateMixerBackendInterface *iface;
+ MateMixerStream *stream = NULL;
g_return_val_if_fail (MATE_MIXER_IS_BACKEND (backend), NULL);
- iface = MATE_MIXER_BACKEND_GET_INTERFACE (backend);
+ g_object_get (G_OBJECT (stream),
+ "default-output", &stream,
+ NULL);
- if (iface->get_default_output_stream)
- return iface->get_default_output_stream (backend);
+ if (stream != NULL)
+ g_object_unref (stream);
- return NULL;
+ return stream;
}
gboolean
diff --git a/libmatemixer/matemixer-enum-types.c b/libmatemixer/matemixer-enum-types.c
index 339b673..50e3bf4 100644
--- a/libmatemixer/matemixer-enum-types.c
+++ b/libmatemixer/matemixer-enum-types.c
@@ -94,14 +94,7 @@ 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_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_SUSPEND, "MATE_MIXER_STREAM_CAN_SUSPEND", "can-suspend" },
{ 0, NULL, NULL }
};
@@ -133,6 +126,30 @@ mate_mixer_stream_state_get_type (void)
}
GType
+mate_mixer_stream_control_flags_get_type (void)
+{
+ static GType etype = 0;
+
+ if (etype == 0) {
+ static const GFlagsValue values[] = {
+ { MATE_MIXER_STREAM_CONTROL_NO_FLAGS, "MATE_MIXER_STREAM_CONTROL_NO_FLAGS", "no-flags" },
+ { MATE_MIXER_STREAM_CONTROL_HAS_MUTE, "MATE_MIXER_STREAM_CONTROL_HAS_MUTE", "has-mute" },
+ { MATE_MIXER_STREAM_CONTROL_HAS_VOLUME, "MATE_MIXER_STREAM_CONTROL_HAS_VOLUME", "has-volume" },
+ { MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL_VOLUME, "MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL_VOLUME", "has-decibel-volume" },
+ { MATE_MIXER_STREAM_CONTROL_HAS_FLAT_VOLUME, "MATE_MIXER_STREAM_CONTROL_HAS_FLAT_VOLUME", "has-flat-volume" },
+ { MATE_MIXER_STREAM_CONTROL_CAN_SET_VOLUME, "MATE_MIXER_STREAM_CONTROL_CAN_SET_VOLUME", "can-set-volume" },
+ { MATE_MIXER_STREAM_CONTROL_CAN_BALANCE, "MATE_MIXER_STREAM_CONTROL_CAN_BALANCE", "can-balance" },
+ { MATE_MIXER_STREAM_CONTROL_CAN_FADE, "MATE_MIXER_STREAM_CONTROL_CAN_FADE", "can-fade" },
+ { 0, NULL, NULL }
+ };
+ etype = g_flags_register_static (
+ g_intern_static_string ("MateMixerStreamControlFlags"),
+ values);
+ }
+ return etype;
+}
+
+GType
mate_mixer_client_stream_flags_get_type (void)
{
static GType etype = 0;
diff --git a/libmatemixer/matemixer-enum-types.h b/libmatemixer/matemixer-enum-types.h
index 03c1297..1dc13cc 100644
--- a/libmatemixer/matemixer-enum-types.h
+++ b/libmatemixer/matemixer-enum-types.h
@@ -43,6 +43,9 @@ 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_STREAM_CONTROL_FLAGS (mate_mixer_stream_control_flags_get_type ())
+GType mate_mixer_stream_control_flags_get_type (void) G_GNUC_CONST;
+
#define MATE_MIXER_TYPE_CLIENT_STREAM_FLAGS (mate_mixer_client_stream_flags_get_type ())
GType mate_mixer_client_stream_flags_get_type (void) G_GNUC_CONST;
diff --git a/libmatemixer/matemixer-enums.h b/libmatemixer/matemixer-enums.h
index 7e523bb..b99f4c5 100644
--- a/libmatemixer/matemixer-enums.h
+++ b/libmatemixer/matemixer-enums.h
@@ -48,6 +48,7 @@ typedef enum {
* will be the first one to try unless you select a specific backend
* to connect to.
* @MATE_MIXER_BACKEND_OSS:
+ * @MATE_MIXER_BACKEND_OSS4:
* @MATE_MIXER_BACKEND_NULL:
* Fallback backend which never fails to initialize, but provides no
* functionality. This backend has the lowest priority and will be used
@@ -58,6 +59,7 @@ typedef enum {
MATE_MIXER_BACKEND_UNKNOWN,
MATE_MIXER_BACKEND_PULSEAUDIO,
MATE_MIXER_BACKEND_OSS,
+ MATE_MIXER_BACKEND_OSS4,
MATE_MIXER_BACKEND_NULL
} MateMixerBackendType;
@@ -81,14 +83,7 @@ typedef enum { /*< 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 >*/
@@ -96,15 +91,10 @@ typedef enum { /*< flags >*/
MATE_MIXER_STREAM_INPUT = 1 << 0,
MATE_MIXER_STREAM_OUTPUT = 1 << 1,
MATE_MIXER_STREAM_CLIENT = 1 << 2,
- 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
+ MATE_MIXER_STREAM_HAS_MONITOR = 1 << 3,
+ MATE_MIXER_STREAM_CAN_SUSPEND = 1 << 4,
+ MATE_MIXER_STREAM_PORTS_FIXED = 1 << 5,
+ MATE_MIXER_STREAM_PORTS_EXCLUSIVE = 1 << 6,
} MateMixerStreamFlags;
/**
@@ -122,6 +112,39 @@ typedef enum {
} MateMixerStreamState;
/**
+ * MateMixerStreamControlFlags:
+ * @MATE_MIXER_STREAM_CONTROL_NO_FLAGS:
+ * @MATE_MIXER_STREAM_CONTROL_HAS_MUTE:
+ * @MATE_MIXER_STREAM_CONTROL_HAS_VOLUME:
+ * @MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL_VOLUME:
+ * @MATE_MIXER_STREAM_CONTROL_HAS_FLAT_VOLUME:
+ * @MATE_MIXER_STREAM_CONTROL_CAN_SET_VOLUME:
+ * @MATE_MIXER_STREAM_CONTROL_CAN_BALANCE:
+ * @MATE_MIXER_STREAM_CONTROL_CAN_FADE:
+ */
+typedef enum {
+ MATE_MIXER_STREAM_CONTROL_NO_FLAGS = 0,
+ MATE_MIXER_STREAM_CONTROL_HAS_MUTE = 1 << 0,
+ MATE_MIXER_STREAM_CONTROL_HAS_VOLUME = 1 << 1,
+ MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL_VOLUME = 1 << 2,
+ MATE_MIXER_STREAM_CONTROL_HAS_FLAT_VOLUME = 1 << 3,
+ MATE_MIXER_STREAM_CONTROL_CAN_SET_VOLUME = 1 << 4,
+ MATE_MIXER_STREAM_CONTROL_CAN_BALANCE = 1 << 5,
+ MATE_MIXER_STREAM_CONTROL_CAN_FADE = 1 << 6
+} MateMixerStreamControlFlags;
+
+typedef enum {
+ MATE_MIXER_STREAM_CONTROL_ROLE_UNKNOWN,
+ MATE_MIXER_STREAM_CONTROL_ROLE_MASTER,
+ MATE_MIXER_STREAM_CONTROL_ROLE_PCM,
+ MATE_MIXER_STREAM_CONTROL_ROLE_BASS,
+ MATE_MIXER_STREAM_CONTROL_ROLE_TREBLE,
+ MATE_MIXER_STREAM_CONTROL_ROLE_CD,
+ MATE_MIXER_STREAM_CONTROL_ROLE_SPEAKER,
+ MATE_MIXER_STREAM_CONTROL_ROLE_PORT
+} MateMixerStreamControlRole;
+
+/**
* MateMixerClientStreamFlags:
* @MATE_MIXER_CLIENT_STREAM_NO_FLAGS:
* @MATE_MIXER_CLIENT_STREAM_APPLICATION:
diff --git a/libmatemixer/matemixer-stream-control.c b/libmatemixer/matemixer-stream-control.c
new file mode 100644
index 0000000..19d35a1
--- /dev/null
+++ b/libmatemixer/matemixer-stream-control.c
@@ -0,0 +1,445 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "matemixer-enums.h"
+#include "matemixer-enum-types.h"
+#include "matemixer-stream-control.h"
+
+/**
+ * SECTION:matemixer-stream-control
+ * @include: libmatemixer/matemixer.h
+ */
+
+G_DEFINE_INTERFACE (MateMixerStreamControl, mate_mixer_stream_control, G_TYPE_OBJECT)
+
+static void
+mate_mixer_stream_control_default_init (MateMixerStreamControlInterface *iface)
+{
+ g_object_interface_install_property (iface,
+ g_param_spec_string ("name",
+ "Name",
+ "Name of the stream control",
+ NULL,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_interface_install_property (iface,
+ g_param_spec_string ("description",
+ "Description",
+ "Description of the stream control",
+ NULL,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_interface_install_property (iface,
+ g_param_spec_flags ("flags",
+ "Flags",
+ "Capability flags of the stream control",
+ MATE_MIXER_TYPE_STREAM_CONTROL_FLAGS,
+ MATE_MIXER_STREAM_CONTROL_NO_FLAGS,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_interface_install_property (iface,
+ g_param_spec_boolean ("mute",
+ "Mute",
+ "Mute state of the stream control",
+ FALSE,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_interface_install_property (iface,
+ g_param_spec_uint ("volume",
+ "Volume",
+ "Volume of the stream control",
+ 0,
+ G_MAXUINT,
+ 0,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_interface_install_property (iface,
+ g_param_spec_float ("balance",
+ "Balance",
+ "Balance value of the stream control",
+ -1.0f,
+ 1.0f,
+ 0.0f,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_interface_install_property (iface,
+ g_param_spec_float ("fade",
+ "Fade",
+ "Fade value of the stream control",
+ -1.0f,
+ 1.0f,
+ 0.0f,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+}
+
+const gchar *
+mate_mixer_stream_control_get_name (MateMixerStreamControl *ctl)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), NULL);
+
+ /* Implementation required */
+ return MATE_MIXER_STREAM_CONTROL_GET_INTERFACE (ctl)->get_name (ctl);
+}
+
+const gchar *
+mate_mixer_stream_control_get_description (MateMixerStreamControl *ctl)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), NULL);
+
+ /* Implementation required */
+ return MATE_MIXER_STREAM_CONTROL_GET_INTERFACE (ctl)->get_description (ctl);
+}
+
+MateMixerStreamControlFlags
+mate_mixer_stream_control_get_flags (MateMixerStreamControl *ctl)
+{
+ MateMixerStreamControlFlags flags = MATE_MIXER_STREAM_CONTROL_NO_FLAGS;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), MATE_MIXER_STREAM_CONTROL_NO_FLAGS);
+
+ g_object_get (G_OBJECT (ctl),
+ "flags", &flags,
+ NULL);
+
+ return flags;
+}
+
+gboolean
+mate_mixer_stream_control_get_mute (MateMixerStreamControl *ctl)
+{
+ gboolean mute = FALSE;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), FALSE);
+
+ g_object_get (G_OBJECT (ctl),
+ "mute", &mute,
+ NULL);
+
+ return mute;
+}
+
+gboolean
+mate_mixer_stream_control_set_mute (MateMixerStreamControl *ctl, gboolean mute)
+{
+ MateMixerStreamControlInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), FALSE);
+
+ iface = MATE_MIXER_STREAM_CONTROL_GET_INTERFACE (ctl);
+
+ if (iface->set_mute != NULL)
+ return iface->set_mute (ctl, mute);
+
+ return FALSE;
+}
+
+guint
+mate_mixer_stream_control_get_volume (MateMixerStreamControl *ctl)
+{
+ guint volume = 0;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), 0);
+
+ g_object_get (G_OBJECT (ctl),
+ "volume", &volume,
+ NULL);
+
+ return volume;
+}
+
+gboolean
+mate_mixer_stream_control_set_volume (MateMixerStreamControl *ctl, guint volume)
+{
+ MateMixerStreamControlInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), FALSE);
+
+ iface = MATE_MIXER_STREAM_CONTROL_GET_INTERFACE (ctl);
+
+ if (iface->set_volume != NULL)
+ return iface->set_volume (ctl, volume);
+
+ return FALSE;
+}
+
+gdouble
+mate_mixer_stream_control_get_decibel (MateMixerStreamControl *ctl)
+{
+ MateMixerStreamControlInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), -MATE_MIXER_INFINITY);
+
+ iface = MATE_MIXER_STREAM_CONTROL_GET_INTERFACE (ctl);
+
+ if (iface->get_decibel != NULL)
+ return iface->get_decibel (ctl);
+
+ return -MATE_MIXER_INFINITY;
+}
+
+gboolean
+mate_mixer_stream_control_set_decibel (MateMixerStreamControl *ctl, gdouble decibel)
+{
+ MateMixerStreamControlInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), FALSE);
+
+ iface = MATE_MIXER_STREAM_CONTROL_GET_INTERFACE (ctl);
+
+ if (iface->set_decibel != NULL)
+ return iface->set_decibel (ctl, decibel);
+
+ return FALSE;
+}
+
+guint
+mate_mixer_stream_control_get_num_channels (MateMixerStreamControl *ctl)
+{
+ MateMixerStreamControlInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), 0);
+
+ iface = MATE_MIXER_STREAM_CONTROL_GET_INTERFACE (ctl);
+
+ if (iface->get_num_channels != NULL)
+ return iface->get_num_channels (ctl);
+
+ return 0;
+}
+
+MateMixerChannelPosition
+mate_mixer_stream_control_get_channel_position (MateMixerStreamControl *ctl, guint channel)
+{
+ MateMixerStreamControlInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), MATE_MIXER_CHANNEL_UNKNOWN);
+
+ iface = MATE_MIXER_STREAM_CONTROL_GET_INTERFACE (ctl);
+
+ if (iface->get_channel_position != NULL)
+ return iface->get_channel_position (ctl, channel);
+
+ return MATE_MIXER_CHANNEL_UNKNOWN;
+}
+
+guint
+mate_mixer_stream_control_get_channel_volume (MateMixerStreamControl *ctl, guint channel)
+{
+ MateMixerStreamControlInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), 0);
+
+ iface = MATE_MIXER_STREAM_CONTROL_GET_INTERFACE (ctl);
+
+ if (iface->get_channel_volume != NULL)
+ return iface->get_channel_volume (ctl, channel);
+
+ return 0;
+}
+
+gboolean
+mate_mixer_stream_control_set_channel_volume (MateMixerStreamControl *ctl,
+ guint channel,
+ guint volume)
+{
+ MateMixerStreamControlInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), FALSE);
+
+ iface = MATE_MIXER_STREAM_CONTROL_GET_INTERFACE (ctl);
+
+ if (iface->set_channel_volume != NULL)
+ return iface->set_channel_volume (ctl, channel, volume);
+
+ return FALSE;
+}
+
+gdouble
+mate_mixer_stream_control_get_channel_decibel (MateMixerStreamControl *ctl, guint channel)
+{
+ MateMixerStreamControlInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), -MATE_MIXER_INFINITY);
+
+ iface = MATE_MIXER_STREAM_CONTROL_GET_INTERFACE (ctl);
+
+ if (iface->get_channel_decibel != NULL)
+ return iface->get_channel_decibel (ctl, channel);
+
+ return -MATE_MIXER_INFINITY;
+}
+
+gboolean
+mate_mixer_stream_control_set_channel_decibel (MateMixerStreamControl *ctl,
+ guint channel,
+ gdouble decibel)
+{
+ MateMixerStreamControlInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), FALSE);
+
+ iface = MATE_MIXER_STREAM_CONTROL_GET_INTERFACE (ctl);
+
+ if (iface->set_channel_decibel != NULL)
+ return iface->set_channel_decibel (ctl, channel, decibel);
+
+ return FALSE;
+}
+
+gboolean
+mate_mixer_stream_control_has_channel_position (MateMixerStreamControl *ctl,
+ MateMixerChannelPosition position)
+{
+ MateMixerStreamControlInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), FALSE);
+
+ iface = MATE_MIXER_STREAM_CONTROL_GET_INTERFACE (ctl);
+
+ if (iface->has_channel_position != NULL)
+ return iface->has_channel_position (ctl, position);
+
+ return FALSE;
+}
+
+gfloat
+mate_mixer_stream_control_get_balance (MateMixerStreamControl *ctl)
+{
+ gfloat balance = 0.0f;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), 0.0f);
+
+ g_object_get (G_OBJECT (ctl),
+ "balance", &balance,
+ NULL);
+
+ return 0.0f;
+}
+
+gboolean
+mate_mixer_stream_control_set_balance (MateMixerStreamControl *ctl, gfloat balance)
+{
+ MateMixerStreamControlInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), FALSE);
+
+ iface = MATE_MIXER_STREAM_CONTROL_GET_INTERFACE (ctl);
+
+ if (iface->set_balance != NULL)
+ return iface->set_balance (ctl, balance);
+
+ return FALSE;
+}
+
+gfloat
+mate_mixer_stream_control_get_fade (MateMixerStreamControl *ctl)
+{
+ gfloat fade = 0.0f;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), 0.0f);
+
+ g_object_get (G_OBJECT (ctl),
+ "fade", &fade,
+ NULL);
+
+ return fade;
+}
+
+gboolean
+mate_mixer_stream_control_set_fade (MateMixerStreamControl *ctl, gfloat fade)
+{
+ MateMixerStreamControlInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), FALSE);
+
+ iface = MATE_MIXER_STREAM_CONTROL_GET_INTERFACE (ctl);
+
+ if (iface->set_fade != NULL)
+ return iface->set_fade (ctl, fade);
+
+ return FALSE;
+}
+
+guint
+mate_mixer_stream_control_get_min_volume (MateMixerStreamControl *ctl)
+{
+ MateMixerStreamControlInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), 0);
+
+ iface = MATE_MIXER_STREAM_CONTROL_GET_INTERFACE (ctl);
+
+ if (iface->get_min_volume != NULL)
+ return iface->get_min_volume (ctl);
+
+ return 0;
+}
+
+guint
+mate_mixer_stream_control_get_max_volume (MateMixerStreamControl *ctl)
+{
+ MateMixerStreamControlInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), 0);
+
+ iface = MATE_MIXER_STREAM_CONTROL_GET_INTERFACE (ctl);
+
+ if (iface->get_max_volume != NULL)
+ return iface->get_max_volume (ctl);
+
+ return 0;
+}
+
+guint
+mate_mixer_stream_control_get_normal_volume (MateMixerStreamControl *ctl)
+{
+ MateMixerStreamControlInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), 0);
+
+ iface = MATE_MIXER_STREAM_CONTROL_GET_INTERFACE (ctl);
+
+ if (iface->get_normal_volume != NULL)
+ return iface->get_normal_volume (ctl);
+
+ return 0;
+}
+
+guint
+mate_mixer_stream_control_get_base_volume (MateMixerStreamControl *ctl)
+{
+ MateMixerStreamControlInterface *iface;
+
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (ctl), 0);
+
+ iface = MATE_MIXER_STREAM_CONTROL_GET_INTERFACE (ctl);
+
+ if (iface->get_base_volume != NULL)
+ return iface->get_base_volume (ctl);
+
+ return 0;
+}
diff --git a/libmatemixer/matemixer-stream-control.h b/libmatemixer/matemixer-stream-control.h
new file mode 100644
index 0000000..727ed54
--- /dev/null
+++ b/libmatemixer/matemixer-stream-control.h
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MATEMIXER_STREAM_CONTROL_H
+#define MATEMIXER_STREAM_CONTROL_H
+
+#include <math.h>
+#include <glib.h>
+#include <glib-object.h>
+
+#include <libmatemixer/matemixer-enums.h>
+
+G_BEGIN_DECLS
+
+#ifdef INFINITY
+# define MATE_MIXER_INFINITY INFINITY
+#else
+# define MATE_MIXER_INFINITY G_MAXDOUBLE
+#endif
+
+#define MATE_MIXER_TYPE_STREAM_CONTROL \
+ (mate_mixer_stream_control_get_type ())
+#define MATE_MIXER_STREAM_CONTROL(o) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((o), MATE_MIXER_TYPE_STREAM_CONTROL, MateMixerStreamControl))
+#define MATE_MIXER_IS_STREAM_CONTROL(o) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((o), MATE_MIXER_TYPE_STREAM_CONTROL))
+#define MATE_MIXER_STREAM_CONTROL_GET_INTERFACE(o) \
+ (G_TYPE_INSTANCE_GET_INTERFACE ((o), MATE_MIXER_TYPE_STREAM_CONTROL, MateMixerStreamControlInterface))
+
+typedef struct _MateMixerStreamControl MateMixerStreamControl; /* dummy object */
+typedef struct _MateMixerStreamControlInterface MateMixerStreamControlInterface;
+
+struct _MateMixerStreamControlInterface
+{
+ GTypeInterface parent_iface;
+
+ /*< private >*/
+ const gchar * (*get_name) (MateMixerStreamControl *ctl);
+ const gchar * (*get_description) (MateMixerStreamControl *ctl);
+
+ gboolean (*set_mute) (MateMixerStreamControl *ctl,
+ gboolean mute);
+
+ guint (*get_num_channels) (MateMixerStreamControl *ctl);
+
+ gboolean (*set_volume) (MateMixerStreamControl *ctl,
+ guint volume);
+
+ gdouble (*get_decibel) (MateMixerStreamControl *ctl);
+ gboolean (*set_decibel) (MateMixerStreamControl *ctl,
+ gdouble decibel);
+
+ gboolean (*has_channel_position) (MateMixerStreamControl *ctl,
+ MateMixerChannelPosition position);
+ MateMixerChannelPosition (*get_channel_position) (MateMixerStreamControl *ctl,
+ guint channel);
+
+ guint (*get_channel_volume) (MateMixerStreamControl *ctl,
+ guint channel);
+ gboolean (*set_channel_volume) (MateMixerStreamControl *ctl,
+ guint channel,
+ guint volume);
+
+ gdouble (*get_channel_decibel) (MateMixerStreamControl *ctl,
+ guint channel);
+ gboolean (*set_channel_decibel) (MateMixerStreamControl *ctl,
+ guint channel,
+ gdouble decibel);
+
+ gboolean (*set_balance) (MateMixerStreamControl *ctl,
+ gfloat balance);
+
+ gboolean (*set_fade) (MateMixerStreamControl *ctl,
+ gfloat fade);
+
+ guint (*get_min_volume) (MateMixerStreamControl *ctl);
+ guint (*get_max_volume) (MateMixerStreamControl *ctl);
+ guint (*get_normal_volume) (MateMixerStreamControl *ctl);
+ guint (*get_base_volume) (MateMixerStreamControl *ctl);
+};
+
+GType mate_mixer_stream_control_get_type (void) G_GNUC_CONST;
+
+const gchar * mate_mixer_stream_control_get_name (MateMixerStreamControl *ctl);
+const gchar * mate_mixer_stream_control_get_description (MateMixerStreamControl *ctl);
+MateMixerStreamControlFlags mate_mixer_stream_control_get_flags (MateMixerStreamControl *ctl);
+
+gboolean mate_mixer_stream_control_get_mute (MateMixerStreamControl *ctl);
+gboolean mate_mixer_stream_control_set_mute (MateMixerStreamControl *ctl,
+ gboolean mute);
+
+guint mate_mixer_stream_control_get_num_channels (MateMixerStreamControl *ctl);
+
+guint mate_mixer_stream_control_get_volume (MateMixerStreamControl *ctl);
+gboolean mate_mixer_stream_control_set_volume (MateMixerStreamControl *ctl,
+ guint volume);
+
+gdouble mate_mixer_stream_control_get_decibel (MateMixerStreamControl *ctl);
+gboolean mate_mixer_stream_control_set_decibel (MateMixerStreamControl *ctl,
+ gdouble decibel);
+
+gboolean mate_mixer_stream_control_has_channel_position (MateMixerStreamControl *ctl,
+ MateMixerChannelPosition position);
+MateMixerChannelPosition mate_mixer_stream_control_get_channel_position (MateMixerStreamControl *ctl,
+ guint channel);
+
+guint mate_mixer_stream_control_get_channel_volume (MateMixerStreamControl *ctl,
+ guint channel);
+gboolean mate_mixer_stream_control_set_channel_volume (MateMixerStreamControl *ctl,
+ guint channel,
+ guint volume);
+
+gdouble mate_mixer_stream_control_get_channel_decibel (MateMixerStreamControl *ctl,
+ guint channel);
+gboolean mate_mixer_stream_control_set_channel_decibel (MateMixerStreamControl *ctl,
+ guint channel,
+ gdouble decibel);
+
+gfloat mate_mixer_stream_control_get_balance (MateMixerStreamControl *ctl);
+gboolean mate_mixer_stream_control_set_balance (MateMixerStreamControl *ctl,
+ gfloat balance);
+
+gfloat mate_mixer_stream_control_get_fade (MateMixerStreamControl *ctl);
+gboolean mate_mixer_stream_control_set_fade (MateMixerStreamControl *ctl,
+ gfloat fade);
+
+guint mate_mixer_stream_control_get_min_volume (MateMixerStreamControl *ctl);
+guint mate_mixer_stream_control_get_max_volume (MateMixerStreamControl *ctl);
+guint mate_mixer_stream_control_get_normal_volume (MateMixerStreamControl *ctl);
+guint mate_mixer_stream_control_get_base_volume (MateMixerStreamControl *ctl);
+
+G_END_DECLS
+
+#endif /* MATEMIXER_STREAM_CONTROL_H */
diff --git a/libmatemixer/matemixer-stream.c b/libmatemixer/matemixer-stream.c
index 6bec2be..888fddb 100644
--- a/libmatemixer/matemixer-stream.c
+++ b/libmatemixer/matemixer-stream.c
@@ -84,44 +84,6 @@ mate_mixer_stream_default_init (MateMixerStreamInterface *iface)
G_PARAM_STATIC_STRINGS));
g_object_interface_install_property (iface,
- g_param_spec_boolean ("mute",
- "Mute",
- "Mute state of the stream",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- g_object_interface_install_property (iface,
- g_param_spec_uint ("volume",
- "Volume",
- "Volume of the stream",
- 0,
- G_MAXUINT,
- 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- g_object_interface_install_property (iface,
- g_param_spec_float ("balance",
- "Balance",
- "Balance value of the stream",
- -1.0f,
- 1.0f,
- 0.0f,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- g_object_interface_install_property (iface,
- g_param_spec_float ("fade",
- "Fade",
- "Fade value of the stream",
- -1.0f,
- 1.0f,
- 0.0f,
- 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",
@@ -145,327 +107,161 @@ mate_mixer_stream_default_init (MateMixerStreamInterface *iface)
const gchar *
mate_mixer_stream_get_name (MateMixerStream *stream)
{
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), NULL);
+
+ /* Implementation required */
return MATE_MIXER_STREAM_GET_INTERFACE (stream)->get_name (stream);
}
const gchar *
mate_mixer_stream_get_description (MateMixerStream *stream)
{
- MateMixerStreamInterface *iface;
-
g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), NULL);
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
-
- if (iface->get_description)
- return iface->get_description (stream);
-
- return NULL;
+ /* Implementation required */
+ return MATE_MIXER_STREAM_GET_INTERFACE (stream)->get_description (stream);
}
MateMixerDevice *
mate_mixer_stream_get_device (MateMixerStream *stream)
{
- MateMixerStreamInterface *iface;
+ MateMixerDevice *device = NULL;
g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), NULL);
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
+ g_object_get (G_OBJECT (stream),
+ "device", &device,
+ NULL);
- if (iface->get_device)
- return iface->get_device (stream);
+ if (device != NULL)
+ g_object_unref (device);
+
+ return device;
- return NULL;
}
MateMixerStreamFlags
mate_mixer_stream_get_flags (MateMixerStream *stream)
{
- MateMixerStreamInterface *iface;
+ MateMixerStreamFlags flags = MATE_MIXER_STREAM_NO_FLAGS;
g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), MATE_MIXER_STREAM_NO_FLAGS);
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
-
- if (iface->get_flags)
- return iface->get_flags (stream);
+ g_object_get (G_OBJECT (stream),
+ "flags", &flags,
+ NULL);
- return MATE_MIXER_STREAM_NO_FLAGS;
+ return flags;
}
MateMixerStreamState
mate_mixer_stream_get_state (MateMixerStream *stream)
{
- MateMixerStreamInterface *iface;
+ MateMixerStreamState state = MATE_MIXER_STREAM_STATE_UNKNOWN;
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);
+ g_object_get (G_OBJECT (stream),
+ "state", &state,
+ NULL);
- return MATE_MIXER_STREAM_STATE_UNKNOWN;
+ return state;
}
-gboolean
-mate_mixer_stream_get_mute (MateMixerStream *stream)
+MateMixerStreamControl *
+mate_mixer_stream_get_control (MateMixerStream *stream, const gchar *name)
{
- MateMixerStreamInterface *iface;
-
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), FALSE);
-
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
-
- if (iface->get_mute)
- return iface->get_mute (stream);
-
- return FALSE;
-}
-
-gboolean
-mate_mixer_stream_set_mute (MateMixerStream *stream, gboolean mute)
-{
- MateMixerStreamInterface *iface;
-
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), FALSE);
-
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
-
- if (iface->set_mute)
- return iface->set_mute (stream, mute);
-
- return FALSE;
-}
-
-guint
-mate_mixer_stream_get_volume (MateMixerStream *stream)
-{
- MateMixerStreamInterface *iface;
-
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), 0);
-
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
-
- if (iface->get_volume)
- return iface->get_volume (stream);
-
- return 0;
-}
-
-gboolean
-mate_mixer_stream_set_volume (MateMixerStream *stream, 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_volume)
- return iface->set_volume (stream, volume);
-
- return FALSE;
-}
-
-gdouble
-mate_mixer_stream_get_decibel (MateMixerStream *stream)
-{
- 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_decibel)
- return iface->get_decibel (stream);
-
- return -MATE_MIXER_INFINITY;
-}
-
-gboolean
-mate_mixer_stream_set_decibel (MateMixerStream *stream, 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_decibel)
- return iface->set_decibel (stream, decibel);
-
- return FALSE;
-}
-
-guint
-mate_mixer_stream_get_num_channels (MateMixerStream *stream)
-{
- MateMixerStreamInterface *iface;
-
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), 0);
-
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
-
- if (iface->get_num_channels)
- return iface->get_num_channels (stream);
-
- return 0;
-}
-
-MateMixerChannelPosition
-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);
-
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
-
- if (iface->get_channel_position)
- return iface->get_channel_position (stream, channel);
-
- return MATE_MIXER_CHANNEL_UNKNOWN;
-}
-
-guint
-mate_mixer_stream_get_channel_volume (MateMixerStream *stream, guint channel)
-{
- MateMixerStreamInterface *iface;
-
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), 0);
-
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
-
- if (iface->get_channel_volume)
- return iface->get_channel_volume (stream, channel);
-
- return 0;
-}
-
-gboolean
-mate_mixer_stream_set_channel_volume (MateMixerStream *stream,
- guint channel,
- 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_channel_volume)
- return iface->set_channel_volume (stream, channel, volume);
-
- return FALSE;
-}
-
-gdouble
-mate_mixer_stream_get_channel_decibel (MateMixerStream *stream, guint channel)
-{
- 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_channel_decibel)
- return iface->get_channel_decibel (stream, channel);
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), NULL);
- return -MATE_MIXER_INFINITY;
+ /* Implementation required */
+ return MATE_MIXER_STREAM_GET_INTERFACE (stream)->get_control (stream, name);
}
-gboolean
-mate_mixer_stream_set_channel_decibel (MateMixerStream *stream,
- guint channel,
- gdouble decibel)
+MateMixerStreamControl *
+mate_mixer_stream_get_default_control (MateMixerStream *stream)
{
- MateMixerStreamInterface *iface;
-
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), FALSE);
-
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
-
- if (iface->set_channel_decibel)
- return iface->set_channel_decibel (stream, channel, decibel);
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), NULL);
- return FALSE;
+ /* Implementation required */
+ return MATE_MIXER_STREAM_GET_INTERFACE (stream)->get_default_control (stream);
}
-gboolean
-mate_mixer_stream_has_channel_position (MateMixerStream *stream,
- MateMixerChannelPosition position)
+MateMixerPort *
+mate_mixer_stream_get_port (MateMixerStream *stream, const gchar *name)
{
MateMixerStreamInterface *iface;
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), FALSE);
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), NULL);
iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
- if (iface->has_channel_position)
- return iface->has_channel_position (stream, position);
+ if (iface->get_port != NULL)
+ return iface->get_port (stream, name);
return FALSE;
}
-gfloat
-mate_mixer_stream_get_balance (MateMixerStream *stream)
+MateMixerPort *
+mate_mixer_stream_get_active_port (MateMixerStream *stream)
{
- MateMixerStreamInterface *iface;
+ MateMixerPort *port = NULL;
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), 0.0f);
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), NULL);
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
+ g_object_get (G_OBJECT (stream),
+ "active-port", &port,
+ NULL);
- if (iface->get_balance)
- return iface->get_balance (stream);
+ if (port != NULL)
+ g_object_unref (port);
- return 0.0f;
+ return port;
}
gboolean
-mate_mixer_stream_set_balance (MateMixerStream *stream, gfloat balance)
+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 (MATE_MIXER_IS_PORT (port), FALSE);
iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
- if (iface->set_balance)
- return iface->set_balance (stream, balance);
+ if (iface->set_active_port != NULL)
+ return iface->set_active_port (stream, port);
return FALSE;
}
-gfloat
-mate_mixer_stream_get_fade (MateMixerStream *stream)
+const GList *
+mate_mixer_stream_list_controls (MateMixerStream *stream)
{
MateMixerStreamInterface *iface;
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), 0.0f);
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), NULL);
iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
- if (iface->get_fade)
- return iface->get_fade (stream);
+ if (iface->list_controls != NULL)
+ return iface->list_controls (stream);
- return 0.0f;
+ return NULL;
}
-gboolean
-mate_mixer_stream_set_fade (MateMixerStream *stream, gfloat fade)
+const GList *
+mate_mixer_stream_list_ports (MateMixerStream *stream)
{
MateMixerStreamInterface *iface;
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), FALSE);
+ g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), NULL);
iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
- if (iface->set_fade)
- return iface->set_fade (stream, fade);
+ if (iface->list_ports != NULL)
+ return iface->list_ports (stream);
- return FALSE;
+ return NULL;
}
gboolean
@@ -477,7 +273,7 @@ mate_mixer_stream_suspend (MateMixerStream *stream)
iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
- if (iface->suspend)
+ if (iface->suspend != NULL)
return iface->suspend (stream);
return FALSE;
@@ -492,57 +288,28 @@ mate_mixer_stream_resume (MateMixerStream *stream)
iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
- if (iface->resume)
+ if (iface->resume != NULL)
return iface->resume (stream);
return FALSE;
}
gboolean
-mate_mixer_stream_monitor_start (MateMixerStream *stream)
-{
- MateMixerStreamInterface *iface;
-
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), FALSE);
-
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
-
- if (iface->monitor_start)
- return iface->monitor_start (stream);
-
- return FALSE;
-}
-
-void
-mate_mixer_stream_monitor_stop (MateMixerStream *stream)
-{
- MateMixerStreamInterface *iface;
-
- g_return_if_fail (MATE_MIXER_IS_STREAM (stream));
-
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
-
- if (iface->monitor_stop)
- iface->monitor_stop (stream);
-}
-
-gboolean
-mate_mixer_stream_monitor_is_running (MateMixerStream *stream)
+mate_mixer_stream_monitor_get_enabled (MateMixerStream *stream)
{
- MateMixerStreamInterface *iface;
+ gboolean enabled = FALSE;
g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), FALSE);
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
-
- if (iface->monitor_is_running)
- return iface->monitor_is_running (stream);
+ g_object_get (G_OBJECT (stream),
+ "monitor-enabled", &enabled,
+ NULL);
- return FALSE;
+ return enabled;
}
gboolean
-mate_mixer_stream_monitor_set_name (MateMixerStream *stream, const gchar *name)
+mate_mixer_stream_monitor_set_enabled (MateMixerStream *stream, gboolean enabled)
{
MateMixerStreamInterface *iface;
@@ -550,29 +317,14 @@ mate_mixer_stream_monitor_set_name (MateMixerStream *stream, const gchar *name)
iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
- if (iface->monitor_set_name)
- return iface->monitor_set_name (stream, name);
+ if (iface->monitor_set_enabled != NULL)
+ return iface->monitor_set_enabled (stream, enabled);
return FALSE;
}
-const GList *
-mate_mixer_stream_list_ports (MateMixerStream *stream)
-{
- MateMixerStreamInterface *iface;
-
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), NULL);
-
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
-
- if (iface->list_ports)
- return iface->list_ports (stream);
-
- return NULL;
-}
-
-MateMixerPort *
-mate_mixer_stream_get_active_port (MateMixerStream *stream)
+const gchar *
+mate_mixer_stream_monitor_get_name (MateMixerStream *stream)
{
MateMixerStreamInterface *iface;
@@ -580,84 +332,23 @@ mate_mixer_stream_get_active_port (MateMixerStream *stream)
iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
- if (iface->get_active_port)
- return iface->get_active_port (stream);
+ if (iface->monitor_get_name != NULL)
+ return iface->monitor_get_name (stream);
- return NULL;
+ return FALSE;
}
gboolean
-mate_mixer_stream_set_active_port (MateMixerStream *stream, MateMixerPort *port)
+mate_mixer_stream_monitor_set_name (MateMixerStream *stream, const gchar *name)
{
MateMixerStreamInterface *iface;
g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), FALSE);
- g_return_val_if_fail (MATE_MIXER_IS_PORT (port), FALSE);
iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
- if (iface->set_active_port)
- return iface->set_active_port (stream, port);
+ if (iface->monitor_set_name != NULL)
+ return iface->monitor_set_name (stream, name);
return FALSE;
}
-
-guint
-mate_mixer_stream_get_min_volume (MateMixerStream *stream)
-{
- MateMixerStreamInterface *iface;
-
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), 0);
-
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
-
- if (iface->get_min_volume)
- return iface->get_min_volume (stream);
-
- return 0;
-}
-
-guint
-mate_mixer_stream_get_max_volume (MateMixerStream *stream)
-{
- MateMixerStreamInterface *iface;
-
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), 0);
-
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
-
- if (iface->get_max_volume)
- return iface->get_max_volume (stream);
-
- return 0;
-}
-
-guint
-mate_mixer_stream_get_normal_volume (MateMixerStream *stream)
-{
- MateMixerStreamInterface *iface;
-
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), 0);
-
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
-
- if (iface->get_normal_volume)
- return iface->get_normal_volume (stream);
-
- return 0;
-}
-
-guint
-mate_mixer_stream_get_base_volume (MateMixerStream *stream)
-{
- MateMixerStreamInterface *iface;
-
- g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), 0);
-
- iface = MATE_MIXER_STREAM_GET_INTERFACE (stream);
-
- if (iface->get_base_volume)
- return iface->get_base_volume (stream);
-
- return 0;
-}
diff --git a/libmatemixer/matemixer-stream.h b/libmatemixer/matemixer-stream.h
index e91a2a5..aecf40e 100644
--- a/libmatemixer/matemixer-stream.h
+++ b/libmatemixer/matemixer-stream.h
@@ -18,13 +18,13 @@
#ifndef MATEMIXER_STREAM_H
#define MATEMIXER_STREAM_H
-#include <math.h>
#include <glib.h>
#include <glib-object.h>
#include <libmatemixer/matemixer-device.h>
#include <libmatemixer/matemixer-enums.h>
#include <libmatemixer/matemixer-port.h>
+#include <libmatemixer/matemixer-stream-control.h>
G_BEGIN_DECLS
@@ -51,131 +51,69 @@ 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);
- MateMixerStreamFlags (*get_flags) (MateMixerStream *stream);
- MateMixerStreamState (*get_state) (MateMixerStream *stream);
- gboolean (*get_mute) (MateMixerStream *stream);
- gboolean (*set_mute) (MateMixerStream *stream,
- gboolean mute);
- guint (*get_num_channels) (MateMixerStream *stream);
- guint (*get_volume) (MateMixerStream *stream);
- gboolean (*set_volume) (MateMixerStream *stream,
- guint volume);
- gdouble (*get_decibel) (MateMixerStream *stream);
- gboolean (*set_decibel) (MateMixerStream *stream,
- gdouble decibel);
- MateMixerChannelPosition (*get_channel_position) (MateMixerStream *stream,
- guint channel);
- guint (*get_channel_volume) (MateMixerStream *stream,
- guint channel);
- gboolean (*set_channel_volume) (MateMixerStream *stream,
- guint channel,
- guint volume);
- gdouble (*get_channel_decibel) (MateMixerStream *stream,
- guint channel);
- gboolean (*set_channel_decibel) (MateMixerStream *stream,
- guint channel,
- gdouble decibel);
- gboolean (*has_channel_position) (MateMixerStream *stream,
- MateMixerChannelPosition position);
- gfloat (*get_balance) (MateMixerStream *stream);
- gboolean (*set_balance) (MateMixerStream *stream,
- gfloat balance);
- gfloat (*get_fade) (MateMixerStream *stream);
- gboolean (*set_fade) (MateMixerStream *stream,
- gfloat fade);
- gboolean (*suspend) (MateMixerStream *stream);
- gboolean (*resume) (MateMixerStream *stream);
- gboolean (*monitor_start) (MateMixerStream *stream);
- void (*monitor_stop) (MateMixerStream *stream);
- gboolean (*monitor_is_running) (MateMixerStream *stream);
- gboolean (*monitor_set_name) (MateMixerStream *stream,
- const gchar *name);
- const GList * (*list_ports) (MateMixerStream *stream);
- MateMixerPort * (*get_active_port) (MateMixerStream *stream);
- gboolean (*set_active_port) (MateMixerStream *stream,
- MateMixerPort *port);
- guint (*get_min_volume) (MateMixerStream *stream);
- guint (*get_max_volume) (MateMixerStream *stream);
- guint (*get_normal_volume) (MateMixerStream *stream);
- guint (*get_base_volume) (MateMixerStream *stream);
+ const gchar * (*get_name) (MateMixerStream *stream);
+ const gchar * (*get_description) (MateMixerStream *stream);
- /* Signals */
- void (*monitor_value) (MateMixerStream *stream,
- gdouble value);
-};
-
-GType mate_mixer_stream_get_type (void) G_GNUC_CONST;
+ MateMixerStreamControl *(*get_control) (MateMixerStream *stream,
+ const gchar *name);
+ MateMixerStreamControl *(*get_default_control) (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);
+ MateMixerPort * (*get_port) (MateMixerStream *stream,
+ const gchar *name);
-gboolean mate_mixer_stream_get_mute (MateMixerStream *stream);
-gboolean mate_mixer_stream_set_mute (MateMixerStream *stream,
- gboolean mute);
+ gboolean (*set_active_port) (MateMixerStream *stream,
+ MateMixerPort *port);
-guint mate_mixer_stream_get_num_channels (MateMixerStream *stream);
+ const GList * (*list_controls) (MateMixerStream *stream);
+ const GList * (*list_ports) (MateMixerStream *stream);
-guint mate_mixer_stream_get_volume (MateMixerStream *stream);
-gboolean mate_mixer_stream_set_volume (MateMixerStream *stream,
- guint volume);
+ gboolean (*suspend) (MateMixerStream *stream);
+ gboolean (*resume) (MateMixerStream *stream);
-gdouble mate_mixer_stream_get_decibel (MateMixerStream *stream);
-gboolean mate_mixer_stream_set_decibel (MateMixerStream *stream,
- gdouble decibel);
+ gboolean (*monitor_set_enabled) (MateMixerStream *stream,
+ gboolean enabled);
-MateMixerChannelPosition mate_mixer_stream_get_channel_position (MateMixerStream *stream,
- guint channel);
+ const gchar * (*monitor_get_name) (MateMixerStream *stream);
+ gboolean (*monitor_set_name) (MateMixerStream *stream,
+ const gchar *name);
-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_channel_decibel (MateMixerStream *stream,
- guint channel);
-gboolean mate_mixer_stream_set_channel_decibel (MateMixerStream *stream,
- guint channel,
- gdouble decibel);
+ /* Signals */
+ void (*monitor_value) (MateMixerStream *stream,
+ gdouble value);
+};
-gboolean mate_mixer_stream_has_channel_position (MateMixerStream *stream,
- MateMixerChannelPosition position);
+GType mate_mixer_stream_get_type (void) G_GNUC_CONST;
-gfloat mate_mixer_stream_get_balance (MateMixerStream *stream);
-gboolean mate_mixer_stream_set_balance (MateMixerStream *stream,
- gfloat balance);
+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);
-gfloat mate_mixer_stream_get_fade (MateMixerStream *stream);
-gboolean mate_mixer_stream_set_fade (MateMixerStream *stream,
- gfloat fade);
+MateMixerStreamControl *mate_mixer_stream_get_control (MateMixerStream *stream,
+ const gchar *name);
+MateMixerStreamControl *mate_mixer_stream_get_default_control (MateMixerStream *stream);
-gboolean mate_mixer_stream_suspend (MateMixerStream *stream);
-gboolean mate_mixer_stream_resume (MateMixerStream *stream);
+MateMixerPort * mate_mixer_stream_get_port (MateMixerStream *stream,
+ const gchar *name);
-gboolean mate_mixer_stream_monitor_start (MateMixerStream *stream);
-void mate_mixer_stream_monitor_stop (MateMixerStream *stream);
+MateMixerPort * mate_mixer_stream_get_active_port (MateMixerStream *stream);
+gboolean mate_mixer_stream_set_active_port (MateMixerStream *stream,
+ MateMixerPort *port);
-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_controls (MateMixerStream *stream);
+const GList * mate_mixer_stream_list_ports (MateMixerStream *stream);
-const GList * mate_mixer_stream_list_ports (MateMixerStream *stream);
+gboolean mate_mixer_stream_suspend (MateMixerStream *stream);
+gboolean mate_mixer_stream_resume (MateMixerStream *stream);
-MateMixerPort * mate_mixer_stream_get_active_port (MateMixerStream *stream);
-gboolean mate_mixer_stream_set_active_port (MateMixerStream *stream,
- MateMixerPort *port);
+gboolean mate_mixer_stream_monitor_get_enabled (MateMixerStream *stream);
+gboolean mate_mixer_stream_monitor_set_enabled (MateMixerStream *stream,
+ gboolean enabled);
-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);
+const gchar * mate_mixer_stream_monitor_get_name (MateMixerStream *stream);
+gboolean mate_mixer_stream_monitor_set_name (MateMixerStream *stream,
+ const gchar *name);
G_END_DECLS