]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
seq: system_info: add properties
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/system-info.c
src/seq/system-info.h
tests/alsaseq-system-info

index a06ebf41899a7a97ca0987d073b2464935b07c63..bdb0458677d4a552b46ae6eea0f0ec7eacb968b1 100644 (file)
 // SPDX-License-Identifier: LGPL-3.0-or-later
 #include "system-info.h"
 
-G_DEFINE_TYPE(ALSASeqSystemInfo, alsaseq_system_info, G_TYPE_OBJECT)
+#include <sound/asequencer.h>
+
+struct _ALSASeqSystemInfoPrivate {
+    struct snd_seq_system_info info;
+};
+G_DEFINE_TYPE_WITH_PRIVATE(ALSASeqSystemInfo, alsaseq_system_info, G_TYPE_OBJECT)
+
+enum seq_system_info_prop_type {
+    SEQ_SYSTEM_INFO_PROP_MAXIMUM_QUEUE_COUNT = 1,
+    SEQ_SYSTEM_INFO_PROP_MAXIMUM_CLIENT_COUNT,
+    SEQ_SYSTEM_INFO_PROP_MAXIMUM_PORT_COUNT,
+    SEQ_SYSTEM_INFO_PROP_MAXIMUM_CHANNEL_COUNT,
+    SEQ_SYSTEM_INFO_PROP_CURRENT_CLIENT_COUNT,
+    SEQ_SYSTEM_INFO_PROP_CURRENT_QUEUE_COUNT,
+    SEQ_SYSTEM_INFO_PROP_COUNT,
+};
+static GParamSpec *seq_system_info_props[SEQ_SYSTEM_INFO_PROP_COUNT] = { NULL, };
+
+static void seq_system_info_get_property(GObject *obj, guint id, GValue *val,
+                                         GParamSpec *spec)
+{
+    ALSASeqSystemInfo *self = ALSASEQ_SYSTEM_INFO(obj);
+    ALSASeqSystemInfoPrivate *priv =
+                                alsaseq_system_info_get_instance_private(self);
+
+    switch (id) {
+    case SEQ_SYSTEM_INFO_PROP_MAXIMUM_QUEUE_COUNT:
+        g_value_set_int(val, priv->info.queues);
+        break;
+    case SEQ_SYSTEM_INFO_PROP_MAXIMUM_CLIENT_COUNT:
+        g_value_set_int(val, priv->info.clients);
+        break;
+    case SEQ_SYSTEM_INFO_PROP_MAXIMUM_PORT_COUNT:
+        g_value_set_int(val, priv->info.ports);
+        break;
+    case SEQ_SYSTEM_INFO_PROP_MAXIMUM_CHANNEL_COUNT:
+        g_value_set_int(val, priv->info.channels);
+        break;
+    case SEQ_SYSTEM_INFO_PROP_CURRENT_CLIENT_COUNT:
+        g_value_set_int(val, priv->info.cur_clients);
+        break;
+    case SEQ_SYSTEM_INFO_PROP_CURRENT_QUEUE_COUNT:
+        g_value_set_int(val, priv->info.cur_queues);
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, id, spec);
+        break;
+    }
+}
 
 static void alsaseq_system_info_class_init(ALSASeqSystemInfoClass *klass)
 {
-    return;
+    GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
+
+    gobject_class->get_property = seq_system_info_get_property;
+
+    seq_system_info_props[SEQ_SYSTEM_INFO_PROP_MAXIMUM_QUEUE_COUNT] =
+        g_param_spec_int("maximum-queue-count", "maximum-queue-count",
+                         "The maximum number of available queues.",
+                         0, G_MAXINT,
+                         0,
+                         G_PARAM_READABLE);
+
+    seq_system_info_props[SEQ_SYSTEM_INFO_PROP_MAXIMUM_CLIENT_COUNT] =
+        g_param_spec_int("maximum-client-count", "maximum-client-count",
+                         "The maximum number of clients.",
+                         0, G_MAXINT,
+                         0,
+                         G_PARAM_READABLE);
+
+    seq_system_info_props[SEQ_SYSTEM_INFO_PROP_MAXIMUM_PORT_COUNT] =
+        g_param_spec_int("maximum-port-count", "maximum-port-count",
+                         "The maximum number of ports.",
+                         0, G_MAXINT,
+                         0,
+                         G_PARAM_READABLE);
+
+    seq_system_info_props[SEQ_SYSTEM_INFO_PROP_MAXIMUM_CHANNEL_COUNT] =
+        g_param_spec_int("maximum-channel-count", "maximum-channel-count",
+                         "The maximum number of channels.",
+                         0, G_MAXINT,
+                         0,
+                         G_PARAM_READABLE);
+
+    seq_system_info_props[SEQ_SYSTEM_INFO_PROP_CURRENT_CLIENT_COUNT] =
+        g_param_spec_int("current-client-count", "current-client-count",
+                         "The current number of clients.",
+                         0, G_MAXINT,
+                         0,
+                         G_PARAM_READABLE);
+
+    seq_system_info_props[SEQ_SYSTEM_INFO_PROP_CURRENT_QUEUE_COUNT] =
+        g_param_spec_int("current-queue-count", "current-queue-count",
+                         "The current number of queues.",
+                         0, G_MAXINT,
+                         0,
+                         G_PARAM_READABLE);
+
+    g_object_class_install_properties(gobject_class,
+                                      SEQ_SYSTEM_INFO_PROP_COUNT,
+                                      seq_system_info_props);
+
 }
 
 static void alsaseq_system_info_init(ALSASeqSystemInfo *self)
index 4859170da4f09000e0f60f190817cba661c1e48d..ac190e50a05ff62e2faa88def266d167ba28a82b 100644 (file)
@@ -31,9 +31,12 @@ G_BEGIN_DECLS
 
 typedef struct _ALSASeqSystemInfo           ALSASeqSystemInfo;
 typedef struct _ALSASeqSystemInfoClass      ALSASeqSystemInfoClass;
+typedef struct _ALSASeqSystemInfoPrivate    ALSASeqSystemInfoPrivate;
 
 struct _ALSASeqSystemInfo {
     GObject parent_instance;
+
+    ALSASeqSystemInfoPrivate *priv;
 };
 
 struct _ALSASeqSystemInfoClass {
index 91a058c2a361a1802133bc8fc76e2a5c8d40aae3..22e5909b8c4c8af2767aedc0b0f2f2a180e41b85 100644 (file)
@@ -10,7 +10,14 @@ gi.require_version('ALSASeq', '0.0')
 from gi.repository import ALSASeq
 
 target = ALSASeq.SystemInfo()
-props = ()
+props = (
+    'maximum-queue-count',
+    'maximum-client-count',
+    'maximum-port-count',
+    'maximum-channel-count',
+    'current-client-count',
+    'current-queue-count',
+)
 methods = ()
 signals = ()