]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
seq: event_fixed: add constructor
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Wed, 1 Apr 2020 09:13:28 +0000 (18:13 +0900)
committer坂本 貴史 <o-takashi@sakamocchi.jp>
Fri, 3 Apr 2020 13:06:25 +0000 (22:06 +0900)
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
src/seq/alsaseq.map
src/seq/event-fixed.c
src/seq/event-fixed.h
tests/alsaseq-event-fixed

index 2ca157fe1e7d1bbc1d661e864d370bdff537b69a..92dd9d9a4da8f772ce699003b498bec6b5711bfc 100644 (file)
@@ -62,6 +62,7 @@ ALSA_GOBJECT_0_0_0 {
     "alsaseq_event_get_type";
 
     "alsaseq_event_fixed_get_type";
+    "alsaseq_event_fixed_new";
   local:
     *;
 };
index 105c361eb0ab60603e8859aef436bd94ff01f2d1..a7f875d55125881a65abff4586057f18fe7c90fd 100644 (file)
@@ -1,5 +1,8 @@
 // SPDX-License-Identifier: LGPL-3.0-or-later
 #include "event-fixed.h"
+#include "privates.h"
+
+#include <errno.h>
 
 G_DEFINE_TYPE(ALSASeqEventFixed, alsaseq_event_fixed, ALSASEQ_TYPE_EVENT)
 
@@ -12,3 +15,34 @@ static void alsaseq_event_fixed_init(ALSASeqEventFixed *self)
 {
     return;
 }
+
+/**
+ * alsaseq_event_fixed_new:
+ * @event_type: A #ALSASeqEventType.
+ * @error: A #GError.
+ *
+ * Allocate and returns an instance of #ALSASeqEventFixed class.
+ *
+ * Returns: (transfer full): A #ALSASeqEventFixed.
+ */
+ALSASeqEventFixed *alsaseq_event_fixed_new(ALSASeqEventType event_type,
+                                           GError **error)
+{
+    switch (event_type) {
+    case ALSASEQ_EVENT_TYPE_BOUNCE:
+    case ALSASEQ_EVENT_TYPE_USR_VAR0:
+    case ALSASEQ_EVENT_TYPE_USR_VAR1:
+    case ALSASEQ_EVENT_TYPE_USR_VAR2:
+    case ALSASEQ_EVENT_TYPE_USR_VAR3:
+    case ALSASEQ_EVENT_TYPE_USR_VAR4:
+        generate_error(error, EINVAL);
+        return NULL;
+    default:
+       break;
+    }
+
+    return g_object_new(ALSASEQ_TYPE_EVENT_FIXED,
+                        "type", event_type,
+                        "length-mode", ALSASEQ_EVENT_LENGTH_MODE_FIXED,
+                        NULL);
+}
index aabc7e67fd16e23b891201ff1cfd6c06fe454966..6c7adc81424de18734f044d5948233ec92043264 100644 (file)
@@ -44,6 +44,9 @@ struct _ALSASeqEventFixedClass {
 
 GType alsaseq_event_fixed_get_type() G_GNUC_CONST;
 
+ALSASeqEventFixed *alsaseq_event_fixed_new(ALSASeqEventType event_type,
+                                           GError **error);
+
 G_END_DECLS
 
 #endif
index e1aa9d0fec7f8b42289307e9cfee4ff8c1b30337..edc9649b8df346aab5e6c14cd4f28dd82e404460 100644 (file)
@@ -11,7 +11,9 @@ from gi.repository import ALSASeq
 
 target = ALSASeq.EventFixed()
 props = ()
-methods = ()
+methods = (
+    'new',
+)
 signals = ()
 
 if not test(target, props, methods, signals):