]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
ctl: elem-info-boolean: add class for element information of boolean type
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Thu, 2 Jun 2022 09:26:26 +0000 (18:26 +0900)
committer坂本 貴史 <o-takashi@sakamocchi.jp>
Thu, 2 Jun 2022 09:32:52 +0000 (18:32 +0900)
Nothing specific.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
src/ctl/alsactl.h
src/ctl/alsactl.map
src/ctl/elem-info-boolean.c [new file with mode: 0644]
src/ctl/elem-info-boolean.h [new file with mode: 0644]
src/ctl/meson.build
tests/alsactl-elem-info-boolean [new file with mode: 0644]
tests/meson.build

index 5955d9d44d58b616e258e620ed0dec20eda18d24..710e13ff27b635649cf043956289b49bebbdf7f6 100644 (file)
@@ -20,6 +20,7 @@
 #include <card-info.h>
 #include <elem-info.h>
 #include <elem-info-iec60958.h>
+#include <elem-info-boolean.h>
 #include <elem-value.h>
 #include <card.h>
 
index 4a5efd459e065233cb0f139f46da9fbc8dd41f2e..96aa3ea29e578b484abdb5604f2f47e5935ae395 100644 (file)
@@ -88,4 +88,7 @@ ALSA_GOBJECT_0_3_0 {
     "alsactl_elem_info_iec60958_new";
 
     "alsactl_elem_info_single_array_get_type";
+
+    "alsactl_elem_info_boolean_get_type";
+    "alsactl_elem_info_boolean_new";
 } ALSA_GOBJECT_0_2_0;
diff --git a/src/ctl/elem-info-boolean.c b/src/ctl/elem-info-boolean.c
new file mode 100644 (file)
index 0000000..331d744
--- /dev/null
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+#include "privates.h"
+
+/**
+ * ALSACtlElemInfoBoolean:
+ * An object to express information for boolean type of element.
+ *
+ * A [class@GObject.Object] derived object class for boolean type of element.
+ *
+ * The object wraps `struct snd_ctl_elem_info` in UAPI of Linux sound subsystem.
+ */
+typedef struct {
+    struct snd_ctl_elem_info data;
+} ALSACtlElemInfoBooleanPrivate;
+
+static void elem_info_common_iface_init(ALSACtlElemInfoCommonInterface *iface);
+static void elem_info_single_array_iface_init(ALSACtlElemInfoSingleArrayInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE(ALSACtlElemInfoBoolean, alsactl_elem_info_boolean, G_TYPE_OBJECT,
+                        G_ADD_PRIVATE(ALSACtlElemInfoBoolean)
+                        G_IMPLEMENT_INTERFACE(ALSACTL_TYPE_ELEM_INFO_COMMON,
+                                              elem_info_common_iface_init)
+                        G_IMPLEMENT_INTERFACE(ALSACTL_TYPE_ELEM_INFO_SINGLE_ARRAY,
+                                              elem_info_single_array_iface_init))
+
+static void ctl_elem_info_boolean_set_property(GObject *obj, guint id, const GValue *val,
+                                              GParamSpec *spec)
+{
+    ALSACtlElemInfoBoolean *self = ALSACTL_ELEM_INFO_BOOLEAN(obj);
+    ALSACtlElemInfoBooleanPrivate *priv = alsactl_elem_info_boolean_get_instance_private(self);
+    struct snd_ctl_elem_info *data = &priv->data;
+
+    elem_info_single_array_set_property(data, obj, id, val, spec);
+}
+
+static void ctl_elem_info_boolean_get_property(GObject *obj, guint id, GValue *val,
+                                              GParamSpec *spec)
+{
+    ALSACtlElemInfoBoolean *self = ALSACTL_ELEM_INFO_BOOLEAN(obj);
+    ALSACtlElemInfoBooleanPrivate *priv = alsactl_elem_info_boolean_get_instance_private(self);
+    const struct snd_ctl_elem_info *data = &priv->data;
+
+    elem_info_single_array_get_property(data, obj, id, val, spec);
+}
+
+static void alsactl_elem_info_boolean_class_init(ALSACtlElemInfoBooleanClass *klass)
+{
+    GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
+
+    gobject_class->set_property = ctl_elem_info_boolean_set_property;
+    gobject_class->get_property = ctl_elem_info_boolean_get_property;
+
+    elem_info_single_array_class_override_properties(gobject_class);
+}
+
+static void alsactl_elem_info_boolean_init(ALSACtlElemInfoBoolean *self)
+{
+    return;
+}
+
+static void elem_info_single_array_iface_init(ALSACtlElemInfoSingleArrayInterface *iface)
+{
+    return;
+}
+
+static void elem_info_common_iface_init(ALSACtlElemInfoCommonInterface *iface)
+{
+    return;
+}
+
+/**
+ * alsactl_elem_info_boolean_new:
+ *
+ * Allocate and return an instance of [class@ElemInfoBoolean].
+ *
+ * Returns: An instance of [class@ElemInfoBoolean].
+ */
+ALSACtlElemInfoBoolean *alsactl_elem_info_boolean_new()
+{
+    return g_object_new(ALSACTL_TYPE_ELEM_INFO_BOOLEAN,
+                        ELEM_TYPE_PROP_NAME, ALSACTL_ELEM_TYPE_BOOLEAN, NULL);
+}
diff --git a/src/ctl/elem-info-boolean.h b/src/ctl/elem-info-boolean.h
new file mode 100644 (file)
index 0000000..0567859
--- /dev/null
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: LGPL-3.0-or-later
+#ifndef __ALSA_GOBJECT_ALSACTL_ELEM_INFO_BOOLEAN_H__
+#define __ALSA_GOBJECT_ALSACTL_ELEM_INFO_BOOLEAN_H__
+
+#include <alsactl.h>
+
+G_BEGIN_DECLS
+
+#define ALSACTL_TYPE_ELEM_INFO_BOOLEAN      (alsactl_elem_info_boolean_get_type())
+
+G_DECLARE_DERIVABLE_TYPE(ALSACtlElemInfoBoolean, alsactl_elem_info_boolean, ALSACTL,
+                         ELEM_INFO_BOOLEAN, GObject)
+
+struct _ALSACtlElemInfoBooleanClass {
+    GObjectClass parent_class;
+};
+
+ALSACtlElemInfoBoolean *alsactl_elem_info_boolean_new();
+
+G_END_DECLS
+
+#endif
index 9073ae7ebae9a025ec54aead18159ff635f3d466..2e49ab45518aea0bda973f0576955b1df96e50b8 100644 (file)
@@ -18,6 +18,7 @@ sources = files(
   'elem-info-common.c',
   'elem-info-iec60958.c',
   'elem-info-single-array.c',
+  'elem-info-boolean.c',
 )
 
 headers = files(
@@ -30,6 +31,7 @@ headers = files(
   'elem-info-common.h',
   'elem-info-iec60958.h',
   'elem-info-single-array.h',
+  'elem-info-boolean.h',
 )
 
 privates = files(
diff --git a/tests/alsactl-elem-info-boolean b/tests/alsactl-elem-info-boolean
new file mode 100644 (file)
index 0000000..5000201
--- /dev/null
@@ -0,0 +1,26 @@
+#!/usr/bin/env python3
+
+from sys import exit
+from errno import ENXIO
+
+from helper import test
+
+import gi
+gi.require_version('ALSACtl', '0.0')
+from gi.repository import ALSACtl
+
+target = ALSACtl.ElemInfoBoolean.new()
+props = (
+    'elem-id',
+    'elem-type',
+    'access',
+    'owner',
+    'value-count',
+)
+methods = (
+    'new',
+)
+signals = ()
+
+if not test(target, props, methods, signals):
+    exit(ENXIO)
index a6f3c163ef3e4920fff832b8decfc7493b9bae6f..015cd6883507b6ad4d0ef5085a9041844f22b179 100644 (file)
@@ -8,6 +8,7 @@ tests = {
     'alsactl-card-info',
     'alsactl-elem-info',
     'alsactl-elem-info-iec60958',
+    'alsactl-elem-info-boolean',
     'alsactl-elem-value',
   ],
   'timer': [