summaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
Diffstat (limited to 'backends')
-rw-r--r--backends/alsa/alsa-device.c83
-rw-r--r--backends/alsa/alsa-toggle.c13
-rw-r--r--backends/alsa/alsa-toggle.h7
3 files changed, 55 insertions, 48 deletions
diff --git a/backends/alsa/alsa-device.c b/backends/alsa/alsa-device.c
index 4c78f9d..66bb80a 100644
--- a/backends/alsa/alsa-device.c
+++ b/backends/alsa/alsa-device.c
@@ -92,6 +92,11 @@ static void add_switch (AlsaDevice
AlsaStream *stream,
snd_mixer_elem_t *el);
+static void add_toggle (AlsaDevice *device,
+ AlsaStream *stream,
+ AlsaToggleType type,
+ snd_mixer_elem_t *el);
+
static void add_stream_input_switch (AlsaDevice *device,
snd_mixer_elem_t *el);
static void add_stream_output_switch (AlsaDevice *device,
@@ -582,33 +587,6 @@ add_stream_output_control (AlsaDevice *device, snd_mixer_elem_t *el)
g_object_unref (control);
}
-static AlsaToggle *
-create_toggle (AlsaDevice *device, snd_mixer_elem_t *el, AlsaToggleType type)
-{
- AlsaToggle *toggle;
- AlsaSwitchOption *on;
- AlsaSwitchOption *off;
- gchar *name;
- gchar *label;
- MateMixerStreamSwitchRole role;
-
- on = alsa_switch_option_new ("On", _("On"), NULL, 1);
- off = alsa_switch_option_new ("Off", _("Off"), NULL, 0);
-
- get_switch_info (el, &name, &label, &role);
-
- toggle = alsa_toggle_new (name, label, role, type, on, off);
-
- alsa_element_set_snd_element (ALSA_ELEMENT (toggle), el);
-
- g_free (name);
- g_free (label);
- g_object_unref (on);
- g_object_unref (off);
-
- return toggle;
-}
-
static void
add_switch (AlsaDevice *device, AlsaStream *stream, snd_mixer_elem_t *el)
{
@@ -674,6 +652,41 @@ add_switch (AlsaDevice *device, AlsaStream *stream, snd_mixer_elem_t *el)
}
static void
+add_toggle (AlsaDevice *device,
+ AlsaStream *stream,
+ AlsaToggleType type,
+ snd_mixer_elem_t *el)
+{
+ AlsaElement *element;
+ AlsaSwitchOption *on;
+ AlsaSwitchOption *off;
+ gchar *name;
+ gchar *label;
+ MateMixerStreamSwitchRole role;
+
+ on = alsa_switch_option_new ("On", _("On"), NULL, 1);
+ off = alsa_switch_option_new ("Off", _("Off"), NULL, 0);
+
+ get_switch_info (el, &name, &label, &role);
+
+ element = ALSA_ELEMENT (alsa_toggle_new (stream,
+ name, label,
+ role,
+ type,
+ on, off));
+ g_free (name);
+ g_free (label);
+ g_object_unref (on);
+ g_object_unref (off);
+
+ alsa_element_set_snd_element (element, el);
+
+ add_element (device, stream, element);
+
+ g_object_unref (element);
+}
+
+static void
add_stream_input_switch (AlsaDevice *device, snd_mixer_elem_t *el)
{
g_debug ("Reading device %s input switch %s (%d items)",
@@ -698,33 +711,21 @@ add_stream_output_switch (AlsaDevice *device, snd_mixer_elem_t *el)
static void
add_stream_input_toggle (AlsaDevice *device, snd_mixer_elem_t *el)
{
- AlsaToggle *toggle;
-
g_debug ("Reading device %s input toggle %s",
mate_mixer_device_get_name (MATE_MIXER_DEVICE (device)),
snd_mixer_selem_get_name (el));
- toggle = create_toggle (device, el, ALSA_TOGGLE_CAPTURE);
-
- add_element (device, device->priv->input, ALSA_ELEMENT (toggle));
-
- g_object_unref (toggle);
+ add_toggle (device, device->priv->input, ALSA_TOGGLE_CAPTURE, el);
}
static void
add_stream_output_toggle (AlsaDevice *device, snd_mixer_elem_t *el)
{
- AlsaToggle *toggle;
-
g_debug ("Reading device %s output toggle %s",
mate_mixer_device_get_name (MATE_MIXER_DEVICE (device)),
snd_mixer_selem_get_name (el));
- toggle = create_toggle (device, el, ALSA_TOGGLE_PLAYBACK);
-
- add_element (device, device->priv->output, ALSA_ELEMENT (toggle));
-
- g_object_unref (toggle);
+ add_toggle (device, device->priv->output, ALSA_TOGGLE_PLAYBACK, el);
}
static void
diff --git a/backends/alsa/alsa-toggle.c b/backends/alsa/alsa-toggle.c
index 3ceedf5..c41e29a 100644
--- a/backends/alsa/alsa-toggle.c
+++ b/backends/alsa/alsa-toggle.c
@@ -23,6 +23,7 @@
#include <libmatemixer/matemixer-private.h>
#include "alsa-element.h"
+#include "alsa-stream.h"
#include "alsa-switch-option.h"
#include "alsa-toggle.h"
@@ -38,7 +39,7 @@ static void alsa_element_interface_init (AlsaElementInterface *iface);
static void alsa_toggle_class_init (AlsaToggleClass *klass);
static void alsa_toggle_init (AlsaToggle *toggle);
-G_DEFINE_TYPE_WITH_CODE (AlsaToggle, alsa_toggle, MATE_MIXER_TYPE_TOGGLE,
+G_DEFINE_TYPE_WITH_CODE (AlsaToggle, alsa_toggle, MATE_MIXER_TYPE_STREAM_TOGGLE,
G_IMPLEMENT_INTERFACE (ALSA_TYPE_ELEMENT,
alsa_element_interface_init))
@@ -78,7 +79,8 @@ alsa_toggle_init (AlsaToggle *toggle)
}
AlsaToggle *
-alsa_toggle_new (const gchar *name,
+alsa_toggle_new (AlsaStream *stream,
+ const gchar *name,
const gchar *label,
MateMixerStreamSwitchRole role,
AlsaToggleType type,
@@ -92,6 +94,7 @@ alsa_toggle_new (const gchar *name,
"label", label,
"flags", MATE_MIXER_SWITCH_TOGGLE,
"role", role,
+ "stream", stream,
"on-state-option", on,
"off-state-option", off,
NULL);
@@ -212,9 +215,11 @@ alsa_toggle_load (AlsaElement *element)
MateMixerSwitchOption *active;
if (value > 0)
- active = mate_mixer_toggle_get_state_option (MATE_MIXER_TOGGLE (toggle), TRUE);
+ active = mate_mixer_stream_toggle_get_state_option (MATE_MIXER_STREAM_TOGGLE (toggle),
+ TRUE);
else
- active = mate_mixer_toggle_get_state_option (MATE_MIXER_TOGGLE (toggle), FALSE);
+ active = mate_mixer_stream_toggle_get_state_option (MATE_MIXER_STREAM_TOGGLE (toggle),
+ FALSE);
_mate_mixer_switch_set_active_option (MATE_MIXER_SWITCH (toggle), active);
return TRUE;
diff --git a/backends/alsa/alsa-toggle.h b/backends/alsa/alsa-toggle.h
index 2d772f9..16a0410 100644
--- a/backends/alsa/alsa-toggle.h
+++ b/backends/alsa/alsa-toggle.h
@@ -49,7 +49,7 @@ typedef struct _AlsaTogglePrivate AlsaTogglePrivate;
struct _AlsaToggle
{
- MateMixerToggle parent;
+ MateMixerStreamToggle parent;
/*< private >*/
AlsaTogglePrivate *priv;
@@ -57,12 +57,13 @@ struct _AlsaToggle
struct _AlsaToggleClass
{
- MateMixerToggleClass parent_class;
+ MateMixerStreamToggleClass parent_class;
};
GType alsa_toggle_get_type (void) G_GNUC_CONST;
-AlsaToggle *alsa_toggle_new (const gchar *name,
+AlsaToggle *alsa_toggle_new (AlsaStream *stream,
+ const gchar *name,
const gchar *label,
MateMixerStreamSwitchRole role,
AlsaToggleType type,