summaryrefslogtreecommitdiff
path: root/backends/alsa
diff options
context:
space:
mode:
authorMichal Ratajsky <[email protected]>2014-11-08 22:18:34 +0100
committerMichal Ratajsky <[email protected]>2014-11-08 22:18:34 +0100
commit068d95e1c28b0e20e692c5ecb24f044542e82ae9 (patch)
tree5be0c066ba9d6ce605c4b82e8e0ae2ec8c00bb9c /backends/alsa
parente72c6f834323e65a41f2ab50047d6fd98f1e09db (diff)
downloadlibmatemixer-068d95e1c28b0e20e692c5ecb24f044542e82ae9.tar.bz2
libmatemixer-068d95e1c28b0e20e692c5ecb24f044542e82ae9.tar.xz
alsa: Use MateMixerStreamSwitch
Also introduce alsa-types.h and move instance typedefs there to fix cross referencing introduced by this change
Diffstat (limited to 'backends/alsa')
-rw-r--r--backends/alsa/Makefile.am3
-rw-r--r--backends/alsa/alsa-backend.h3
-rw-r--r--backends/alsa/alsa-device.c3
-rw-r--r--backends/alsa/alsa-device.h3
-rw-r--r--backends/alsa/alsa-element.h3
-rw-r--r--backends/alsa/alsa-stream-control.h3
-rw-r--r--backends/alsa/alsa-stream-input-control.h3
-rw-r--r--backends/alsa/alsa-stream-output-control.h3
-rw-r--r--backends/alsa/alsa-stream.c13
-rw-r--r--backends/alsa/alsa-stream.h5
-rw-r--r--backends/alsa/alsa-switch-option.h3
-rw-r--r--backends/alsa/alsa-switch.c12
-rw-r--r--backends/alsa/alsa-switch.h10
-rw-r--r--backends/alsa/alsa-toggle.h3
-rw-r--r--backends/alsa/alsa-types.h36
15 files changed, 76 insertions, 30 deletions
diff --git a/backends/alsa/Makefile.am b/backends/alsa/Makefile.am
index 48dcaba..c192cfb 100644
--- a/backends/alsa/Makefile.am
+++ b/backends/alsa/Makefile.am
@@ -33,7 +33,8 @@ libmatemixer_alsa_la_SOURCES = \
alsa-switch-option.c \
alsa-switch-option.h \
alsa-toggle.c \
- alsa-toggle.h
+ alsa-toggle.h \
+ alsa-types.h
libmatemixer_alsa_la_LIBADD = \
$(GLIB_LIBS) \
diff --git a/backends/alsa/alsa-backend.h b/backends/alsa/alsa-backend.h
index 03fedf0..5fb60a1 100644
--- a/backends/alsa/alsa-backend.h
+++ b/backends/alsa/alsa-backend.h
@@ -23,6 +23,8 @@
#include <libmatemixer/matemixer.h>
#include <libmatemixer/matemixer-private.h>
+#include "alsa-types.h"
+
#define ALSA_TYPE_BACKEND \
(alsa_backend_get_type ())
#define ALSA_BACKEND(o) \
@@ -36,7 +38,6 @@
#define ALSA_BACKEND_GET_CLASS(o) \
(G_TYPE_INSTANCE_GET_CLASS ((o), ALSA_TYPE_BACKEND, AlsaBackendClass))
-typedef struct _AlsaBackend AlsaBackend;
typedef struct _AlsaBackendClass AlsaBackendClass;
typedef struct _AlsaBackendPrivate AlsaBackendPrivate;
diff --git a/backends/alsa/alsa-device.c b/backends/alsa/alsa-device.c
index 24fdefb..a4f625c 100644
--- a/backends/alsa/alsa-device.c
+++ b/backends/alsa/alsa-device.c
@@ -659,7 +659,8 @@ add_switch (AlsaDevice *device, AlsaStream *stream, snd_mixer_elem_t *el)
get_switch_info (el, &name, &label, &role);
/* Takes ownership of options */
- element = ALSA_ELEMENT (alsa_switch_new (name, label,
+ element = ALSA_ELEMENT (alsa_switch_new (stream,
+ name, label,
role,
g_list_reverse (options)));
g_free (name);
diff --git a/backends/alsa/alsa-device.h b/backends/alsa/alsa-device.h
index 9e908cf..7232e0b 100644
--- a/backends/alsa/alsa-device.h
+++ b/backends/alsa/alsa-device.h
@@ -22,7 +22,7 @@
#include <glib-object.h>
#include <libmatemixer/matemixer.h>
-#include "alsa-stream.h"
+#include "alsa-types.h"
G_BEGIN_DECLS
@@ -39,7 +39,6 @@ G_BEGIN_DECLS
#define ALSA_DEVICE_GET_CLASS(o) \
(G_TYPE_INSTANCE_GET_CLASS ((o), ALSA_TYPE_DEVICE, AlsaDeviceClass))
-typedef struct _AlsaDevice AlsaDevice;
typedef struct _AlsaDeviceClass AlsaDeviceClass;
typedef struct _AlsaDevicePrivate AlsaDevicePrivate;
diff --git a/backends/alsa/alsa-element.h b/backends/alsa/alsa-element.h
index 1c30f68..4c37f12 100644
--- a/backends/alsa/alsa-element.h
+++ b/backends/alsa/alsa-element.h
@@ -22,6 +22,8 @@
#include <glib-object.h>
#include <alsa/asoundlib.h>
+#include "alsa-types.h"
+
G_BEGIN_DECLS
#define ALSA_TYPE_ELEMENT \
@@ -33,7 +35,6 @@ G_BEGIN_DECLS
#define ALSA_ELEMENT_GET_INTERFACE(o) \
(G_TYPE_INSTANCE_GET_INTERFACE ((o), ALSA_TYPE_ELEMENT, AlsaElementInterface))
-typedef struct _AlsaElement AlsaElement; /* dummy object */
typedef struct _AlsaElementInterface AlsaElementInterface;
struct _AlsaElementInterface
diff --git a/backends/alsa/alsa-stream-control.h b/backends/alsa/alsa-stream-control.h
index 2b96b33..0acb73a 100644
--- a/backends/alsa/alsa-stream-control.h
+++ b/backends/alsa/alsa-stream-control.h
@@ -23,6 +23,8 @@
#include <alsa/asoundlib.h>
#include <libmatemixer/matemixer.h>
+#include "alsa-types.h"
+
G_BEGIN_DECLS
typedef struct {
@@ -54,7 +56,6 @@ typedef struct {
#define ALSA_STREAM_CONTROL_GET_CLASS(o) \
(G_TYPE_INSTANCE_GET_CLASS ((o), ALSA_TYPE_STREAM_CONTROL, AlsaStreamControlClass))
-typedef struct _AlsaStreamControl AlsaStreamControl;
typedef struct _AlsaStreamControlClass AlsaStreamControlClass;
typedef struct _AlsaStreamControlPrivate AlsaStreamControlPrivate;
diff --git a/backends/alsa/alsa-stream-input-control.h b/backends/alsa/alsa-stream-input-control.h
index 0ce885a..1ce16f5 100644
--- a/backends/alsa/alsa-stream-input-control.h
+++ b/backends/alsa/alsa-stream-input-control.h
@@ -22,8 +22,8 @@
#include <glib-object.h>
#include <libmatemixer/matemixer.h>
-#include "alsa-stream.h"
#include "alsa-stream-control.h"
+#include "alsa-types.h"
G_BEGIN_DECLS
@@ -40,7 +40,6 @@ G_BEGIN_DECLS
#define ALSA_STREAM_INPUT_CONTROL_GET_CLASS(o) \
(G_TYPE_INSTANCE_GET_CLASS ((o), ALSA_TYPE_STREAM_INPUT_CONTROL, AlsaStreamInputControlClass))
-typedef struct _AlsaStreamInputControl AlsaStreamInputControl;
typedef struct _AlsaStreamInputControlClass AlsaStreamInputControlClass;
typedef struct _AlsaStreamInputControlPrivate AlsaStreamInputControlPrivate;
diff --git a/backends/alsa/alsa-stream-output-control.h b/backends/alsa/alsa-stream-output-control.h
index 9a5b708..e29319d 100644
--- a/backends/alsa/alsa-stream-output-control.h
+++ b/backends/alsa/alsa-stream-output-control.h
@@ -22,8 +22,8 @@
#include <glib-object.h>
#include <libmatemixer/matemixer.h>
-#include "alsa-stream.h"
#include "alsa-stream-control.h"
+#include "alsa-types.h"
G_BEGIN_DECLS
@@ -40,7 +40,6 @@ G_BEGIN_DECLS
#define ALSA_STREAM_OUTPUT_CONTROL_GET_CLASS(o) \
(G_TYPE_INSTANCE_GET_CLASS ((o), ALSA_TYPE_STREAM_OUTPUT_CONTROL, AlsaStreamOutputControlClass))
-typedef struct _AlsaStreamOutputControl AlsaStreamOutputControl;
typedef struct _AlsaStreamOutputControlClass AlsaStreamOutputControlClass;
typedef struct _AlsaStreamOutputControlPrivate AlsaStreamOutputControlPrivate;
diff --git a/backends/alsa/alsa-stream.c b/backends/alsa/alsa-stream.c
index bc9c1b5..bce66ec 100644
--- a/backends/alsa/alsa-stream.c
+++ b/backends/alsa/alsa-stream.c
@@ -24,6 +24,7 @@
#include "alsa-stream.h"
#include "alsa-stream-control.h"
#include "alsa-switch.h"
+#include "alsa-toggle.h"
struct _AlsaStreamPrivate
{
@@ -37,13 +38,13 @@ static void alsa_stream_dispose (GObject *object);
G_DEFINE_TYPE (AlsaStream, alsa_stream, MATE_MIXER_TYPE_STREAM)
-static const GList *alsa_stream_list_controls (MateMixerStream *mms);
-static const GList *alsa_stream_list_switches (MateMixerStream *mms);
+static const GList *alsa_stream_list_controls (MateMixerStream *mms);
+static const GList *alsa_stream_list_switches (MateMixerStream *mms);
-static gint compare_control_name (gconstpointer a,
- gconstpointer b);
-static gint compare_switch_name (gconstpointer a,
- gconstpointer b);
+static gint compare_control_name (gconstpointer a,
+ gconstpointer b);
+static gint compare_switch_name (gconstpointer a,
+ gconstpointer b);
static void
alsa_stream_class_init (AlsaStreamClass *klass)
diff --git a/backends/alsa/alsa-stream.h b/backends/alsa/alsa-stream.h
index 5aa3095..90f0aa0 100644
--- a/backends/alsa/alsa-stream.h
+++ b/backends/alsa/alsa-stream.h
@@ -22,9 +22,7 @@
#include <glib-object.h>
#include <libmatemixer/matemixer.h>
-#include "alsa-stream-control.h"
-#include "alsa-switch.h"
-#include "alsa-toggle.h"
+#include "alsa-types.h"
G_BEGIN_DECLS
@@ -41,7 +39,6 @@ G_BEGIN_DECLS
#define ALSA_STREAM_GET_CLASS(o) \
(G_TYPE_INSTANCE_GET_CLASS ((o), ALSA_TYPE_STREAM, AlsaStreamClass))
-typedef struct _AlsaStream AlsaStream;
typedef struct _AlsaStreamClass AlsaStreamClass;
typedef struct _AlsaStreamPrivate AlsaStreamPrivate;
diff --git a/backends/alsa/alsa-switch-option.h b/backends/alsa/alsa-switch-option.h
index 98d4f57..e12cf5b 100644
--- a/backends/alsa/alsa-switch-option.h
+++ b/backends/alsa/alsa-switch-option.h
@@ -22,6 +22,8 @@
#include <glib-object.h>
#include <libmatemixer/matemixer.h>
+#include "alsa-types.h"
+
G_BEGIN_DECLS
#define ALSA_TYPE_SWITCH_OPTION \
@@ -37,7 +39,6 @@ G_BEGIN_DECLS
#define ALSA_SWITCH_OPTION_GET_CLASS(o) \
(G_TYPE_INSTANCE_GET_CLASS ((o), ALSA_TYPE_SWITCH_OPTION, AlsaSwitchOptionClass))
-typedef struct _AlsaSwitchOption AlsaSwitchOption;
typedef struct _AlsaSwitchOptionClass AlsaSwitchOptionClass;
typedef struct _AlsaSwitchOptionPrivate AlsaSwitchOptionPrivate;
diff --git a/backends/alsa/alsa-switch.c b/backends/alsa/alsa-switch.c
index 6a0f1f4..b080188 100644
--- a/backends/alsa/alsa-switch.c
+++ b/backends/alsa/alsa-switch.c
@@ -23,6 +23,7 @@
#include <libmatemixer/matemixer-private.h>
#include "alsa-element.h"
+#include "alsa-stream.h"
#include "alsa-switch.h"
#include "alsa-switch-option.h"
@@ -40,7 +41,7 @@ static void alsa_switch_init (AlsaSwitch *swtch);
static void alsa_switch_dispose (GObject *object);
G_DEFINE_TYPE_WITH_CODE (AlsaSwitch, alsa_switch,
- MATE_MIXER_TYPE_SWITCH,
+ MATE_MIXER_TYPE_STREAM_SWITCH,
G_IMPLEMENT_INTERFACE (ALSA_TYPE_ELEMENT,
alsa_element_interface_init))
@@ -102,17 +103,24 @@ alsa_switch_init (AlsaSwitch *swtch)
}
AlsaSwitch *
-alsa_switch_new (const gchar *name,
+alsa_switch_new (AlsaStream *stream,
+ const gchar *name,
const gchar *label,
MateMixerSwitchRole role,
GList *options)
{
AlsaSwitch *swtch;
+ g_return_val_if_fail (ALSA_IS_STREAM (stream), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (label != NULL, NULL);
+ g_return_val_if_fail (options != NULL, NULL);
+
swtch = g_object_new (ALSA_TYPE_SWITCH,
"name", name,
"label", label,
"role", role,
+ "stream", stream,
NULL);
/* Takes ownership of options */
diff --git a/backends/alsa/alsa-switch.h b/backends/alsa/alsa-switch.h
index b7f5931..9ebf907 100644
--- a/backends/alsa/alsa-switch.h
+++ b/backends/alsa/alsa-switch.h
@@ -22,6 +22,8 @@
#include <glib-object.h>
#include <libmatemixer/matemixer.h>
+#include "alsa-types.h"
+
G_BEGIN_DECLS
#define ALSA_TYPE_SWITCH \
@@ -37,13 +39,12 @@ G_BEGIN_DECLS
#define ALSA_SWITCH_GET_CLASS(o) \
(G_TYPE_INSTANCE_GET_CLASS ((o), ALSA_TYPE_SWITCH, AlsaSwitchClass))
-typedef struct _AlsaSwitch AlsaSwitch;
typedef struct _AlsaSwitchClass AlsaSwitchClass;
typedef struct _AlsaSwitchPrivate AlsaSwitchPrivate;
struct _AlsaSwitch
{
- MateMixerSwitch parent;
+ MateMixerStreamSwitch parent;
/*< private >*/
AlsaSwitchPrivate *priv;
@@ -51,12 +52,13 @@ struct _AlsaSwitch
struct _AlsaSwitchClass
{
- MateMixerSwitchClass parent_class;
+ MateMixerStreamSwitchClass parent_class;
};
GType alsa_switch_get_type (void) G_GNUC_CONST;
-AlsaSwitch *alsa_switch_new (const gchar *name,
+AlsaSwitch *alsa_switch_new (AlsaStream *stream,
+ const gchar *name,
const gchar *label,
MateMixerSwitchRole role,
GList *options);
diff --git a/backends/alsa/alsa-toggle.h b/backends/alsa/alsa-toggle.h
index 1e1993c..112b78e 100644
--- a/backends/alsa/alsa-toggle.h
+++ b/backends/alsa/alsa-toggle.h
@@ -22,7 +22,7 @@
#include <glib-object.h>
#include <libmatemixer/matemixer.h>
-#include "alsa-switch-option.h"
+#include "alsa-types.h"
G_BEGIN_DECLS
@@ -44,7 +44,6 @@ typedef enum {
#define ALSA_TOGGLE_GET_CLASS(o) \
(G_TYPE_INSTANCE_GET_CLASS ((o), ALSA_TYPE_TOGGLE, AlsaToggleClass))
-typedef struct _AlsaToggle AlsaToggle;
typedef struct _AlsaToggleClass AlsaToggleClass;
typedef struct _AlsaTogglePrivate AlsaTogglePrivate;
diff --git a/backends/alsa/alsa-types.h b/backends/alsa/alsa-types.h
new file mode 100644
index 0000000..0c7f4dd
--- /dev/null
+++ b/backends/alsa/alsa-types.h
@@ -0,0 +1,36 @@
+/*
+ * 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 ALSA_TYPES_H
+#define ALSA_TYPES_H
+
+G_BEGIN_DECLS
+
+typedef struct _AlsaBackend AlsaBackend;
+typedef struct _AlsaDevice AlsaDevice;
+typedef struct _AlsaElement AlsaElement;
+typedef struct _AlsaStream AlsaStream;
+typedef struct _AlsaStreamControl AlsaStreamControl;
+typedef struct _AlsaStreamInputControl AlsaStreamInputControl;
+typedef struct _AlsaStreamOutputControl AlsaStreamOutputControl;
+typedef struct _AlsaSwitch AlsaSwitch;
+typedef struct _AlsaSwitchOption AlsaSwitchOption;
+typedef struct _AlsaToggle AlsaToggle;
+
+G_END_DECLS
+
+#endif /* ALSA_TYPES_H */