diff options
-rw-r--r-- | backends/alsa/alsa-constants.c | 54 | ||||
-rw-r--r-- | backends/alsa/alsa-constants.h | 6 | ||||
-rw-r--r-- | backends/alsa/alsa-device.c | 46 | ||||
-rw-r--r-- | backends/alsa/alsa-switch.c | 10 | ||||
-rw-r--r-- | backends/alsa/alsa-switch.h | 10 | ||||
-rw-r--r-- | backends/alsa/alsa-toggle.c | 12 | ||||
-rw-r--r-- | backends/alsa/alsa-toggle.h | 12 | ||||
-rw-r--r-- | backends/oss/oss-switch.c | 2 | ||||
-rw-r--r-- | backends/pulse/pulse-device-switch.c | 2 | ||||
-rw-r--r-- | backends/pulse/pulse-sink-switch.c | 2 | ||||
-rw-r--r-- | backends/pulse/pulse-source-switch.c | 2 | ||||
-rw-r--r-- | docs/reference/libmatemixer-sections.txt | 6 | ||||
-rw-r--r-- | examples/monitor.c | 24 | ||||
-rw-r--r-- | libmatemixer/matemixer-device-switch.c | 38 | ||||
-rw-r--r-- | libmatemixer/matemixer-device-switch.h | 5 | ||||
-rw-r--r-- | libmatemixer/matemixer-enum-types.c | 29 | ||||
-rw-r--r-- | libmatemixer/matemixer-enum-types.h | 7 | ||||
-rw-r--r-- | libmatemixer/matemixer-enums.h | 31 | ||||
-rw-r--r-- | libmatemixer/matemixer-stream-switch.c | 38 | ||||
-rw-r--r-- | libmatemixer/matemixer-stream-switch.h | 5 | ||||
-rw-r--r-- | libmatemixer/matemixer-switch.c | 35 | ||||
-rw-r--r-- | libmatemixer/matemixer-switch.h | 1 |
22 files changed, 228 insertions, 149 deletions
diff --git a/backends/alsa/alsa-constants.c b/backends/alsa/alsa-constants.c index 1bc29bc..853db95 100644 --- a/backends/alsa/alsa-constants.c +++ b/backends/alsa/alsa-constants.c @@ -113,35 +113,35 @@ const AlsaControlInfo alsa_controls[] = const AlsaSwitchInfo alsa_switches[] = { /* Switches */ - { "Analog Output", N_("Analog Output"), MATE_MIXER_SWITCH_ROLE_PORT }, - { "Analog Source", N_("Analog Source"), MATE_MIXER_SWITCH_ROLE_PORT }, - { "Capture Source", N_("Capture Source"), MATE_MIXER_SWITCH_ROLE_PORT }, - { "Input Source", N_("Input Source"), MATE_MIXER_SWITCH_ROLE_PORT }, - { "Input Source Select", N_("Input Source"), MATE_MIXER_SWITCH_ROLE_PORT }, - { "Digital Input Source", N_("Digital Input Source"), MATE_MIXER_SWITCH_ROLE_PORT }, - { "PCM Capture Source", N_("PCM Capture Source"), MATE_MIXER_SWITCH_ROLE_PORT }, - { "IEC958 Playback Source", N_("Digital Playback Source"), MATE_MIXER_SWITCH_ROLE_PORT }, - { "Mono Output Select", N_("Mono Output"), MATE_MIXER_SWITCH_ROLE_PORT }, - { "Shared Mic/Line in", N_("Shared Microphone/Line In"), MATE_MIXER_SWITCH_ROLE_PORT }, - { "Mic Select", N_("Microphone"), MATE_MIXER_SWITCH_ROLE_PORT }, - { "Mic Jack Mode", N_("Microphone Jack Mode"), MATE_MIXER_SWITCH_ROLE_PORT }, - { "Surround Jack Mode", N_("Surround Jack Mode"), MATE_MIXER_SWITCH_ROLE_UNKNOWN }, - { "Auto-Mute Mode", N_("Auto-Mute Mode"), MATE_MIXER_SWITCH_ROLE_UNKNOWN }, + { "Analog Output", N_("Analog Output"), MATE_MIXER_STREAM_SWITCH_ROLE_PORT }, + { "Analog Source", N_("Analog Source"), MATE_MIXER_STREAM_SWITCH_ROLE_PORT }, + { "Capture Source", N_("Capture Source"), MATE_MIXER_STREAM_SWITCH_ROLE_PORT }, + { "Input Source", N_("Input Source"), MATE_MIXER_STREAM_SWITCH_ROLE_PORT }, + { "Input Source Select", N_("Input Source"), MATE_MIXER_STREAM_SWITCH_ROLE_PORT }, + { "Digital Input Source", N_("Digital Input Source"), MATE_MIXER_STREAM_SWITCH_ROLE_PORT }, + { "PCM Capture Source", N_("PCM Capture Source"), MATE_MIXER_STREAM_SWITCH_ROLE_PORT }, + { "IEC958 Playback Source", N_("Digital Playback Source"), MATE_MIXER_STREAM_SWITCH_ROLE_PORT }, + { "Mono Output Select", N_("Mono Output"), MATE_MIXER_STREAM_SWITCH_ROLE_PORT }, + { "Shared Mic/Line in", N_("Shared Microphone/Line In"), MATE_MIXER_STREAM_SWITCH_ROLE_PORT }, + { "Mic Select", N_("Microphone"), MATE_MIXER_STREAM_SWITCH_ROLE_PORT }, + { "Mic Jack Mode", N_("Microphone Jack Mode"), MATE_MIXER_STREAM_SWITCH_ROLE_PORT }, + { "Surround Jack Mode", N_("Surround Jack Mode"), MATE_MIXER_STREAM_SWITCH_ROLE_UNKNOWN }, + { "Auto-Mute Mode", N_("Auto-Mute Mode"), MATE_MIXER_STREAM_SWITCH_ROLE_UNKNOWN }, /* Toggles */ - { "External Amplifier", N_("External Amplifier"), MATE_MIXER_SWITCH_ROLE_UNKNOWN }, - { "Bass Boost", N_("Bass Boost"), MATE_MIXER_SWITCH_ROLE_BOOST }, - { "Capture Boost", N_("Capture Boost"), MATE_MIXER_SWITCH_ROLE_BOOST }, - { "IEC958", N_("Digital"), MATE_MIXER_SWITCH_ROLE_PORT }, - { "IEC958 In", N_("Digital In"), MATE_MIXER_SWITCH_ROLE_PORT }, - { "IEC958 Default PCM", N_("Digital Default PCM"), MATE_MIXER_SWITCH_ROLE_UNKNOWN }, - { "IEC958 Optical", N_("Optical"), MATE_MIXER_SWITCH_ROLE_PORT }, - { "Auto Gain Control", N_("Auto Gain Control"), MATE_MIXER_SWITCH_ROLE_UNKNOWN }, - { "Mix", N_("Mix"), MATE_MIXER_SWITCH_ROLE_UNKNOWN }, - { "Mix Mono", N_("Mix Mono"), MATE_MIXER_SWITCH_ROLE_UNKNOWN }, - { "Mic Capture", N_("Microphone Capture"), MATE_MIXER_SWITCH_ROLE_PORT }, - { "Input 1", N_("Input 1"), MATE_MIXER_SWITCH_ROLE_PORT }, - { "Input 2", N_("Input 2"), MATE_MIXER_SWITCH_ROLE_PORT }, + { "External Amplifier", N_("External Amplifier"), MATE_MIXER_STREAM_SWITCH_ROLE_UNKNOWN }, + { "Bass Boost", N_("Bass Boost"), MATE_MIXER_STREAM_SWITCH_ROLE_BOOST }, + { "Capture Boost", N_("Capture Boost"), MATE_MIXER_STREAM_SWITCH_ROLE_BOOST }, + { "IEC958", N_("Digital"), MATE_MIXER_STREAM_SWITCH_ROLE_PORT }, + { "IEC958 In", N_("Digital In"), MATE_MIXER_STREAM_SWITCH_ROLE_PORT }, + { "IEC958 Default PCM", N_("Digital Default PCM"), MATE_MIXER_STREAM_SWITCH_ROLE_UNKNOWN }, + { "IEC958 Optical", N_("Optical"), MATE_MIXER_STREAM_SWITCH_ROLE_PORT }, + { "Auto Gain Control", N_("Auto Gain Control"), MATE_MIXER_STREAM_SWITCH_ROLE_UNKNOWN }, + { "Mix", N_("Mix"), MATE_MIXER_STREAM_SWITCH_ROLE_UNKNOWN }, + { "Mix Mono", N_("Mix Mono"), MATE_MIXER_STREAM_SWITCH_ROLE_UNKNOWN }, + { "Mic Capture", N_("Microphone Capture"), MATE_MIXER_STREAM_SWITCH_ROLE_PORT }, + { "Input 1", N_("Input 1"), MATE_MIXER_STREAM_SWITCH_ROLE_PORT }, + { "Input 2", N_("Input 2"), MATE_MIXER_STREAM_SWITCH_ROLE_PORT }, { NULL } }; diff --git a/backends/alsa/alsa-constants.h b/backends/alsa/alsa-constants.h index 8137289..9ec4a0a 100644 --- a/backends/alsa/alsa-constants.h +++ b/backends/alsa/alsa-constants.h @@ -33,9 +33,9 @@ typedef struct { } AlsaControlInfo; typedef struct { - gchar *name; - gchar *label; - MateMixerSwitchRole role; + gchar *name; + gchar *label; + MateMixerStreamSwitchRole role; } AlsaSwitchInfo; typedef struct { diff --git a/backends/alsa/alsa-device.c b/backends/alsa/alsa-device.c index a4f625c..4c78f9d 100644 --- a/backends/alsa/alsa-device.c +++ b/backends/alsa/alsa-device.c @@ -147,7 +147,7 @@ static MateMixerDirection get_switch_direction (snd_mixer_elem_t static void get_switch_info (snd_mixer_elem_t *el, gchar **name, gchar **label, - MateMixerSwitchRole *role); + MateMixerStreamSwitchRole *role); static void close_mixer (AlsaDevice *device); @@ -585,12 +585,12 @@ add_stream_output_control (AlsaDevice *device, snd_mixer_elem_t *el) static AlsaToggle * create_toggle (AlsaDevice *device, snd_mixer_elem_t *el, AlsaToggleType type) { - AlsaToggle *toggle; - AlsaSwitchOption *on; - AlsaSwitchOption *off; - gchar *name; - gchar *label; - MateMixerSwitchRole role; + 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); @@ -612,14 +612,14 @@ create_toggle (AlsaDevice *device, snd_mixer_elem_t *el, AlsaToggleType type) static void add_switch (AlsaDevice *device, AlsaStream *stream, snd_mixer_elem_t *el) { - AlsaElement *element = NULL; - GList *options = NULL; - gchar *name; - gchar *label; - gchar item[128]; - guint i; - gint count; - MateMixerSwitchRole role; + AlsaElement *element = NULL; + GList *options = NULL; + gchar *name; + gchar *label; + gchar item[128]; + guint i; + gint count; + MateMixerStreamSwitchRole role; count = snd_mixer_selem_get_enum_items (el); if G_UNLIKELY (count <= 0) { @@ -1138,15 +1138,15 @@ get_switch_direction (snd_mixer_elem_t *el) } static void -get_switch_info (snd_mixer_elem_t *el, - gchar **name, - gchar **label, - MateMixerSwitchRole *role) +get_switch_info (snd_mixer_elem_t *el, + gchar **name, + gchar **label, + MateMixerStreamSwitchRole *role) { - MateMixerSwitchRole r = MATE_MIXER_SWITCH_ROLE_UNKNOWN; - const gchar *n; - const gchar *l = NULL; - gint i; + MateMixerStreamSwitchRole r = MATE_MIXER_STREAM_SWITCH_ROLE_UNKNOWN; + const gchar *n; + const gchar *l = NULL; + gint i; n = snd_mixer_selem_get_name (el); diff --git a/backends/alsa/alsa-switch.c b/backends/alsa/alsa-switch.c index b080188..c2a95ca 100644 --- a/backends/alsa/alsa-switch.c +++ b/backends/alsa/alsa-switch.c @@ -103,11 +103,11 @@ alsa_switch_init (AlsaSwitch *swtch) } AlsaSwitch * -alsa_switch_new (AlsaStream *stream, - const gchar *name, - const gchar *label, - MateMixerSwitchRole role, - GList *options) +alsa_switch_new (AlsaStream *stream, + const gchar *name, + const gchar *label, + MateMixerStreamSwitchRole role, + GList *options) { AlsaSwitch *swtch; diff --git a/backends/alsa/alsa-switch.h b/backends/alsa/alsa-switch.h index 9ebf907..e15b960 100644 --- a/backends/alsa/alsa-switch.h +++ b/backends/alsa/alsa-switch.h @@ -57,11 +57,11 @@ struct _AlsaSwitchClass GType alsa_switch_get_type (void) G_GNUC_CONST; -AlsaSwitch *alsa_switch_new (AlsaStream *stream, - const gchar *name, - const gchar *label, - MateMixerSwitchRole role, - GList *options); +AlsaSwitch *alsa_switch_new (AlsaStream *stream, + const gchar *name, + const gchar *label, + MateMixerStreamSwitchRole role, + GList *options); G_END_DECLS diff --git a/backends/alsa/alsa-toggle.c b/backends/alsa/alsa-toggle.c index c843985..3ceedf5 100644 --- a/backends/alsa/alsa-toggle.c +++ b/backends/alsa/alsa-toggle.c @@ -78,12 +78,12 @@ alsa_toggle_init (AlsaToggle *toggle) } AlsaToggle * -alsa_toggle_new (const gchar *name, - const gchar *label, - MateMixerSwitchRole role, - AlsaToggleType type, - AlsaSwitchOption *on, - AlsaSwitchOption *off) +alsa_toggle_new (const gchar *name, + const gchar *label, + MateMixerStreamSwitchRole role, + AlsaToggleType type, + AlsaSwitchOption *on, + AlsaSwitchOption *off) { AlsaToggle *toggle; diff --git a/backends/alsa/alsa-toggle.h b/backends/alsa/alsa-toggle.h index 112b78e..2d772f9 100644 --- a/backends/alsa/alsa-toggle.h +++ b/backends/alsa/alsa-toggle.h @@ -62,12 +62,12 @@ struct _AlsaToggleClass GType alsa_toggle_get_type (void) G_GNUC_CONST; -AlsaToggle *alsa_toggle_new (const gchar *name, - const gchar *label, - MateMixerSwitchRole role, - AlsaToggleType type, - AlsaSwitchOption *on, - AlsaSwitchOption *off); +AlsaToggle *alsa_toggle_new (const gchar *name, + const gchar *label, + MateMixerStreamSwitchRole role, + AlsaToggleType type, + AlsaSwitchOption *on, + AlsaSwitchOption *off); G_END_DECLS diff --git a/backends/oss/oss-switch.c b/backends/oss/oss-switch.c index 40527b9..6b78833 100644 --- a/backends/oss/oss-switch.c +++ b/backends/oss/oss-switch.c @@ -117,7 +117,7 @@ oss_switch_new (OssStream *stream, swtch = g_object_new (OSS_TYPE_SWITCH, "name", name, "label", label, - "role", MATE_MIXER_SWITCH_ROLE_PORT, + "role", MATE_MIXER_STREAM_SWITCH_ROLE_PORT, "stream", stream, NULL); diff --git a/backends/pulse/pulse-device-switch.c b/backends/pulse/pulse-device-switch.c index b41d8ea..c6b8316 100644 --- a/backends/pulse/pulse-device-switch.c +++ b/backends/pulse/pulse-device-switch.c @@ -92,7 +92,7 @@ pulse_device_switch_new (const gchar *name, const gchar *label, PulseDevice *dev return g_object_new (PULSE_TYPE_DEVICE_SWITCH, "name", name, "label", label, - "role", MATE_MIXER_SWITCH_ROLE_DEVICE_PROFILE, + "role", MATE_MIXER_DEVICE_SWITCH_ROLE_PROFILE, "device", device, NULL); } diff --git a/backends/pulse/pulse-sink-switch.c b/backends/pulse/pulse-sink-switch.c index 0e08dac..62aca94 100644 --- a/backends/pulse/pulse-sink-switch.c +++ b/backends/pulse/pulse-sink-switch.c @@ -55,7 +55,7 @@ pulse_sink_switch_new (const gchar *name, const gchar *label, PulseSink *sink) return g_object_new (PULSE_TYPE_SINK_SWITCH, "name", name, "label", label, - "role", MATE_MIXER_SWITCH_ROLE_PORT, + "role", MATE_MIXER_STREAM_SWITCH_ROLE_PORT, "stream", sink, NULL); } diff --git a/backends/pulse/pulse-source-switch.c b/backends/pulse/pulse-source-switch.c index 178702e..9616bb1 100644 --- a/backends/pulse/pulse-source-switch.c +++ b/backends/pulse/pulse-source-switch.c @@ -55,7 +55,7 @@ pulse_source_switch_new (const gchar *name, const gchar *label, PulseSource *sou return g_object_new (PULSE_TYPE_SOURCE_SWITCH, "name", name, "label", label, - "role", MATE_MIXER_SWITCH_ROLE_PORT, + "role", MATE_MIXER_STREAM_SWITCH_ROLE_PORT, "stream", source, NULL); } diff --git a/docs/reference/libmatemixer-sections.txt b/docs/reference/libmatemixer-sections.txt index 02b0f7e..0049cfa 100644 --- a/docs/reference/libmatemixer-sections.txt +++ b/docs/reference/libmatemixer-sections.txt @@ -91,8 +91,10 @@ mate_mixer_device_get_type <SECTION> <FILE>matemixer-device-switch</FILE> <TITLE>MateMixerDeviceSwitch</TITLE> +MateMixerDeviceSwitchRole MateMixerDeviceSwitch MateMixerDeviceSwitchClass +mate_mixer_device_switch_get_role mate_mixer_device_switch_get_device <SUBSECTION Standard> MATE_MIXER_IS_DEVICE_SWITCH @@ -207,8 +209,10 @@ mate_mixer_stream_control_get_type <SECTION> <FILE>matemixer-stream-switch</FILE> <TITLE>MateMixerStreamSwitch</TITLE> +MateMixerStreamSwitchRole MateMixerStreamSwitch MateMixerStreamSwitchClass +mate_mixer_stream_switch_get_role mate_mixer_stream_switch_get_stream <SUBSECTION Standard> MATE_MIXER_IS_STREAM_SWITCH @@ -226,13 +230,11 @@ mate_mixer_stream_switch_get_type <FILE>matemixer-switch</FILE> <TITLE>MateMixerSwitch</TITLE> MateMixerSwitchFlags -MateMixerSwitchRole MateMixerSwitch MateMixerSwitchClass mate_mixer_switch_get_name mate_mixer_switch_get_label mate_mixer_switch_get_flags -mate_mixer_switch_get_role mate_mixer_switch_get_option mate_mixer_switch_list_options mate_mixer_switch_get_active_option diff --git a/examples/monitor.c b/examples/monitor.c index 0e0d24e..3e99053 100644 --- a/examples/monitor.c +++ b/examples/monitor.c @@ -95,16 +95,26 @@ get_media_role_string (MateMixerStreamControlMediaRole role) } } -/* Convert MateMixerSwitchRole constant to a string */ +/* Convert MateMixerDeviceSwitchRole constant to a string */ static const gchar * -get_switch_role_string (MateMixerSwitchRole role) +get_device_switch_role_string (MateMixerDeviceSwitchRole role) { switch (role) { - case MATE_MIXER_SWITCH_ROLE_DEVICE_PROFILE: + case MATE_MIXER_DEVICE_SWITCH_ROLE_PROFILE: return "Device Profile"; - case MATE_MIXER_SWITCH_ROLE_PORT: + default: + return "Unknown"; + } +} + +/* Convert MateMixerStreamSwitchRole constant to a string */ +static const gchar * +get_stream_switch_role_string (MateMixerStreamSwitchRole role) +{ + switch (role) { + case MATE_MIXER_STREAM_SWITCH_ROLE_PORT: return "Port"; - case MATE_MIXER_SWITCH_ROLE_BOOST: + case MATE_MIXER_STREAM_SWITCH_ROLE_BOOST: return "Boost"; default: return "Unknown"; @@ -170,7 +180,7 @@ print_devices (void) "\t\tRole : %s\n", mate_mixer_switch_get_name (swtch), mate_mixer_switch_get_label (swtch), - get_switch_role_string (mate_mixer_switch_get_role (swtch))); + get_device_switch_role_string (mate_mixer_device_switch_get_role (MATE_MIXER_DEVICE_SWITCH (swtch)))); g_print ("\tOptions:\n"); @@ -256,7 +266,7 @@ print_streams (void) "\t\tRole : %s\n", mate_mixer_switch_get_name (swtch), mate_mixer_switch_get_label (swtch), - get_switch_role_string (mate_mixer_switch_get_role (swtch))); + get_stream_switch_role_string (mate_mixer_stream_switch_get_role (MATE_MIXER_STREAM_SWITCH (swtch)))); g_print ("\tOptions:\n"); diff --git a/libmatemixer/matemixer-device-switch.c b/libmatemixer/matemixer-device-switch.c index cc0bbec..bc0ea70 100644 --- a/libmatemixer/matemixer-device-switch.c +++ b/libmatemixer/matemixer-device-switch.c @@ -19,6 +19,8 @@ #include <glib-object.h> #include "matemixer-device.h" +#include "matemixer-enums.h" +#include "matemixer-enum-types.h" #include "matemixer-switch.h" #include "matemixer-device-switch.h" @@ -29,11 +31,13 @@ struct _MateMixerDeviceSwitchPrivate { - MateMixerDevice *device; + MateMixerDevice *device; + MateMixerDeviceSwitchRole role; }; enum { PROP_0, + PROP_ROLE, PROP_DEVICE, N_PROPERTIES }; @@ -64,6 +68,16 @@ mate_mixer_device_switch_class_init (MateMixerDeviceSwitchClass *klass) object_class->get_property = mate_mixer_device_switch_get_property; object_class->set_property = mate_mixer_device_switch_set_property; + properties[PROP_ROLE] = + g_param_spec_enum ("role", + "Role", + "Role of the switch", + MATE_MIXER_TYPE_DEVICE_SWITCH_ROLE, + MATE_MIXER_DEVICE_SWITCH_ROLE_UNKNOWN, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + properties[PROP_DEVICE] = g_param_spec_object ("device", "Device", @@ -89,6 +103,9 @@ mate_mixer_device_switch_get_property (GObject *object, swtch = MATE_MIXER_DEVICE_SWITCH (object); switch (param_id) { + case PROP_ROLE: + g_value_set_enum (value, swtch->priv->role); + break; case PROP_DEVICE: g_value_set_object (value, swtch->priv->device); break; @@ -109,6 +126,9 @@ mate_mixer_device_switch_set_property (GObject *object, swtch = MATE_MIXER_DEVICE_SWITCH (object); switch (param_id) { + case PROP_ROLE: + swtch->priv->role = g_value_get_enum (value); + break; case PROP_DEVICE: /* Construct-only object */ swtch->priv->device = g_value_get_object (value); @@ -132,6 +152,22 @@ mate_mixer_device_switch_init (MateMixerDeviceSwitch *swtch) } /** + * mate_mixer_device_switch_get_role: + * @swtch: a #MateMixerDeviceSwitch + * + * Gets the role of the switch. The role identifies the purpose of the switch. + * + * Returns: the switch role. + */ +MateMixerDeviceSwitchRole +mate_mixer_device_switch_get_role (MateMixerDeviceSwitch *swtch) +{ + g_return_val_if_fail (MATE_MIXER_IS_DEVICE_SWITCH (swtch), MATE_MIXER_DEVICE_SWITCH_ROLE_UNKNOWN); + + return swtch->priv->role; +} + +/** * mate_mixer_device_switch_get_device: * @swtch: a #MateMixerDeviceSwitch */ diff --git a/libmatemixer/matemixer-device-switch.h b/libmatemixer/matemixer-device-switch.h index ad3f103..246abce 100644 --- a/libmatemixer/matemixer-device-switch.h +++ b/libmatemixer/matemixer-device-switch.h @@ -67,9 +67,10 @@ struct _MateMixerDeviceSwitchClass MateMixerSwitchClass parent_class; }; -GType mate_mixer_device_switch_get_type (void) G_GNUC_CONST; +GType mate_mixer_device_switch_get_type (void) G_GNUC_CONST; -MateMixerDevice *mate_mixer_device_switch_get_device (MateMixerDeviceSwitch *swtch); +MateMixerDeviceSwitchRole mate_mixer_device_switch_get_role (MateMixerDeviceSwitch *swtch); +MateMixerDevice * mate_mixer_device_switch_get_device (MateMixerDeviceSwitch *swtch); G_END_DECLS diff --git a/libmatemixer/matemixer-enum-types.c b/libmatemixer/matemixer-enum-types.c index 6d88a83..3d4d039 100644 --- a/libmatemixer/matemixer-enum-types.c +++ b/libmatemixer/matemixer-enum-types.c @@ -208,20 +208,37 @@ mate_mixer_switch_flags_get_type (void) } GType -mate_mixer_switch_role_get_type (void) +mate_mixer_device_switch_role_get_type (void) { static GType etype = 0; if (etype == 0) { static const GEnumValue values[] = { - { MATE_MIXER_SWITCH_ROLE_UNKNOWN, "MATE_MIXER_SWITCH_ROLE_UNKNOWN", "unknown" }, - { MATE_MIXER_SWITCH_ROLE_DEVICE_PROFILE, "MATE_MIXER_SWITCH_ROLE_DEVICE_PROFILE", "device-profile" }, - { MATE_MIXER_SWITCH_ROLE_PORT, "MATE_MIXER_SWITCH_ROLE_PORT", "port" }, - { MATE_MIXER_SWITCH_ROLE_BOOST, "MATE_MIXER_SWITCH_ROLE_BOOST", "boost" }, + { MATE_MIXER_DEVICE_SWITCH_ROLE_UNKNOWN, "MATE_MIXER_DEVICE_SWITCH_ROLE_UNKNOWN", "unknown" }, + { MATE_MIXER_DEVICE_SWITCH_ROLE_PROFILE, "MATE_MIXER_DEVICE_SWITCH_ROLE_PROFILE", "profile" }, { 0, NULL, NULL } }; etype = g_enum_register_static ( - g_intern_static_string ("MateMixerSwitchRole"), + g_intern_static_string ("MateMixerDeviceSwitchRole"), + values); + } + return etype; +} + +GType +mate_mixer_stream_switch_role_get_type (void) +{ + static GType etype = 0; + + if (etype == 0) { + static const GEnumValue values[] = { + { MATE_MIXER_STREAM_SWITCH_ROLE_UNKNOWN, "MATE_MIXER_STREAM_SWITCH_ROLE_UNKNOWN", "unknown" }, + { MATE_MIXER_STREAM_SWITCH_ROLE_PORT, "MATE_MIXER_STREAM_SWITCH_ROLE_PORT", "port" }, + { MATE_MIXER_STREAM_SWITCH_ROLE_BOOST, "MATE_MIXER_STREAM_SWITCH_ROLE_BOOST", "boost" }, + { 0, NULL, NULL } + }; + etype = g_enum_register_static ( + g_intern_static_string ("MateMixerStreamSwitchRole"), values); } return etype; diff --git a/libmatemixer/matemixer-enum-types.h b/libmatemixer/matemixer-enum-types.h index f96dc85..42b996b 100644 --- a/libmatemixer/matemixer-enum-types.h +++ b/libmatemixer/matemixer-enum-types.h @@ -52,8 +52,11 @@ GType mate_mixer_stream_control_media_role_get_type (void) G_GNUC_CONST; #define MATE_MIXER_TYPE_SWITCH_FLAGS (mate_mixer_switch_flags_get_type ()) GType mate_mixer_switch_flags_get_type (void) G_GNUC_CONST; -#define MATE_MIXER_TYPE_SWITCH_ROLE (mate_mixer_switch_role_get_type ()) -GType mate_mixer_switch_role_get_type (void) G_GNUC_CONST; +#define MATE_MIXER_TYPE_DEVICE_SWITCH_ROLE (mate_mixer_device_switch_role_get_type ()) +GType mate_mixer_device_switch_role_get_type (void) G_GNUC_CONST; + +#define MATE_MIXER_TYPE_STREAM_SWITCH_ROLE (mate_mixer_stream_switch_role_get_type ()) +GType mate_mixer_stream_switch_role_get_type (void) G_GNUC_CONST; #define MATE_MIXER_TYPE_CHANNEL_POSITION (mate_mixer_channel_position_get_type ()) GType mate_mixer_channel_position_get_type (void) G_GNUC_CONST; diff --git a/libmatemixer/matemixer-enums.h b/libmatemixer/matemixer-enums.h index befc651..6cbd78d 100644 --- a/libmatemixer/matemixer-enums.h +++ b/libmatemixer/matemixer-enums.h @@ -271,22 +271,31 @@ typedef enum { /*< flags >*/ } MateMixerSwitchFlags; /** - * MateMixerSwitchRole: - * @MATE_MIXER_SWITCH_ROLE_UNKNOWN: - * Unknown switch role. - * @MATE_MIXER_SWITCH_ROLE_DEVICE_PROFILE: + * MateMixerDeviceSwitchRole: + * @MATE_MIXER_DEVICE_SWITCH_ROLE_UNKNOWN: + * Unknown device switch role. + * @MATE_MIXER_DEVICE_SWITCH_ROLE_PROFILE: * The switch changes the active sound device profile. - * @MATE_MIXER_SWITCH_ROLE_PORT: + */ +typedef enum { + MATE_MIXER_DEVICE_SWITCH_ROLE_UNKNOWN, + MATE_MIXER_DEVICE_SWITCH_ROLE_PROFILE, +} MateMixerDeviceSwitchRole; + +/** + * MateMixerStreamSwitchRole: + * @MATE_MIXER_STREAM_SWITCH_ROLE_UNKNOWN: + * Unknown stream switch role. + * @MATE_MIXER_STREAM_SWITCH_ROLE_PORT: * The switch changes the active port. - * @MATE_MIXER_SWITCH_ROLE_BOOST: + * @MATE_MIXER_STREAM_SWITCH_ROLE_BOOST: * The switch changes the boost value. */ typedef enum { - MATE_MIXER_SWITCH_ROLE_UNKNOWN, - MATE_MIXER_SWITCH_ROLE_DEVICE_PROFILE, - MATE_MIXER_SWITCH_ROLE_PORT, - MATE_MIXER_SWITCH_ROLE_BOOST -} MateMixerSwitchRole; + MATE_MIXER_STREAM_SWITCH_ROLE_UNKNOWN, + MATE_MIXER_STREAM_SWITCH_ROLE_PORT, + MATE_MIXER_STREAM_SWITCH_ROLE_BOOST +} MateMixerStreamSwitchRole; /** * MateMixerChannelPosition: diff --git a/libmatemixer/matemixer-stream-switch.c b/libmatemixer/matemixer-stream-switch.c index 57c8c53..20af819 100644 --- a/libmatemixer/matemixer-stream-switch.c +++ b/libmatemixer/matemixer-stream-switch.c @@ -18,6 +18,8 @@ #include <glib.h> #include <glib-object.h> +#include "matemixer-enums.h" +#include "matemixer-enum-types.h" #include "matemixer-stream.h" #include "matemixer-switch.h" #include "matemixer-stream-switch.h" @@ -29,11 +31,13 @@ struct _MateMixerStreamSwitchPrivate { - MateMixerStream *stream; + MateMixerStream *stream; + MateMixerStreamSwitchRole role; }; enum { PROP_0, + PROP_ROLE, PROP_STREAM, N_PROPERTIES }; @@ -64,6 +68,16 @@ mate_mixer_stream_switch_class_init (MateMixerStreamSwitchClass *klass) object_class->get_property = mate_mixer_stream_switch_get_property; object_class->set_property = mate_mixer_stream_switch_set_property; + properties[PROP_ROLE] = + g_param_spec_enum ("role", + "Role", + "Role of the switch", + MATE_MIXER_TYPE_STREAM_SWITCH_ROLE, + MATE_MIXER_STREAM_SWITCH_ROLE_UNKNOWN, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + properties[PROP_STREAM] = g_param_spec_object ("stream", "Stream", @@ -89,6 +103,9 @@ mate_mixer_stream_switch_get_property (GObject *object, swtch = MATE_MIXER_STREAM_SWITCH (object); switch (param_id) { + case PROP_ROLE: + g_value_set_enum (value, swtch->priv->role); + break; case PROP_STREAM: g_value_set_object (value, swtch->priv->stream); break; @@ -109,6 +126,9 @@ mate_mixer_stream_switch_set_property (GObject *object, swtch = MATE_MIXER_STREAM_SWITCH (object); switch (param_id) { + case PROP_ROLE: + swtch->priv->role = g_value_get_enum (value); + break; case PROP_STREAM: /* Construct-only object */ swtch->priv->stream = g_value_get_object (value); @@ -132,6 +152,22 @@ mate_mixer_stream_switch_init (MateMixerStreamSwitch *swtch) } /** + * mate_mixer_stream_switch_get_role: + * @swtch: a #MateMixerStreamSwitch + * + * Gets the role of the switch. The role identifies the purpose of the switch. + * + * Returns: the switch role. + */ +MateMixerStreamSwitchRole +mate_mixer_stream_switch_get_role (MateMixerStreamSwitch *swtch) +{ + g_return_val_if_fail (MATE_MIXER_IS_STREAM_SWITCH (swtch), MATE_MIXER_STREAM_SWITCH_ROLE_UNKNOWN); + + return swtch->priv->role; +} + +/** * mate_mixer_stream_switch_get_stream: * @swtch: a #MateMixerStreamSwitch */ diff --git a/libmatemixer/matemixer-stream-switch.h b/libmatemixer/matemixer-stream-switch.h index ed37c5e..b6978fa 100644 --- a/libmatemixer/matemixer-stream-switch.h +++ b/libmatemixer/matemixer-stream-switch.h @@ -67,9 +67,10 @@ struct _MateMixerStreamSwitchClass MateMixerSwitchClass parent_class; }; -GType mate_mixer_stream_switch_get_type (void) G_GNUC_CONST; +GType mate_mixer_stream_switch_get_type (void) G_GNUC_CONST; -MateMixerStream *mate_mixer_stream_switch_get_stream (MateMixerStreamSwitch *swtch); +MateMixerStreamSwitchRole mate_mixer_stream_switch_get_role (MateMixerStreamSwitch *swtch); +MateMixerStream * mate_mixer_stream_switch_get_stream (MateMixerStreamSwitch *swtch); G_END_DECLS diff --git a/libmatemixer/matemixer-switch.c b/libmatemixer/matemixer-switch.c index 6466838..d0f2691 100644 --- a/libmatemixer/matemixer-switch.c +++ b/libmatemixer/matemixer-switch.c @@ -35,7 +35,6 @@ struct _MateMixerSwitchPrivate gchar *name; gchar *label; MateMixerSwitchFlags flags; - MateMixerSwitchRole role; MateMixerSwitchOption *active; }; @@ -44,7 +43,6 @@ enum { PROP_NAME, PROP_LABEL, PROP_FLAGS, - PROP_ROLE, PROP_ACTIVE_OPTION, N_PROPERTIES }; @@ -102,16 +100,6 @@ mate_mixer_switch_class_init (MateMixerSwitchClass *klass) G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - properties[PROP_ROLE] = - g_param_spec_enum ("role", - "Role", - "Role of the switch", - MATE_MIXER_TYPE_SWITCH_ROLE, - MATE_MIXER_SWITCH_ROLE_UNKNOWN, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - properties[PROP_FLAGS] = g_param_spec_flags ("flags", "Flags", @@ -156,9 +144,6 @@ mate_mixer_switch_get_property (GObject *object, case PROP_FLAGS: g_value_set_flags (value, swtch->priv->flags); break; - case PROP_ROLE: - g_value_set_enum (value, swtch->priv->role); - break; case PROP_ACTIVE_OPTION: g_value_set_object (value, swtch->priv->active); break; @@ -191,9 +176,6 @@ mate_mixer_switch_set_property (GObject *object, case PROP_FLAGS: swtch->priv->flags = g_value_get_flags (value); break; - case PROP_ROLE: - swtch->priv->role = g_value_get_enum (value); - break; case PROP_ACTIVE_OPTION: /* Construct-only object */ swtch->priv->active = g_value_dup_object (value); @@ -294,23 +276,6 @@ mate_mixer_switch_get_flags (MateMixerSwitch *swtch) } /** - * mate_mixer_switch_get_role: - * @swtch: a #MateMixerSwitch - * - * Gets the role of the switch. The role identifies the purpose of the switch. - - * Note that while the role identification should be reliable, it may be based on - * looking for well-known switch names on some sound systems. - */ -MateMixerSwitchRole -mate_mixer_switch_get_role (MateMixerSwitch *swtch) -{ - g_return_val_if_fail (MATE_MIXER_IS_SWITCH (swtch), MATE_MIXER_SWITCH_ROLE_UNKNOWN); - - return swtch->priv->role; -} - -/** * mate_mixer_switch_get_option: * @swtch: a #MateMixerSwitch * @name: the name of an option diff --git a/libmatemixer/matemixer-switch.h b/libmatemixer/matemixer-switch.h index 7881486..a6b6d49 100644 --- a/libmatemixer/matemixer-switch.h +++ b/libmatemixer/matemixer-switch.h @@ -81,7 +81,6 @@ GType mate_mixer_switch_get_type (void) G_GNUC_CONST; const gchar * mate_mixer_switch_get_name (MateMixerSwitch *swtch); const gchar * mate_mixer_switch_get_label (MateMixerSwitch *swtch); MateMixerSwitchFlags mate_mixer_switch_get_flags (MateMixerSwitch *swtch); -MateMixerSwitchRole mate_mixer_switch_get_role (MateMixerSwitch *swtch); MateMixerSwitchOption *mate_mixer_switch_get_option (MateMixerSwitch *swtch, const gchar *name); |