From: Takashi Sakamoto Date: Wed, 1 Jun 2022 02:35:44 +0000 (+0900) Subject: seq: queue-timer-common: add common interface for queue timer X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=4a7adcd66f8de306d2338c7da882a65c8981de0a;p=alsa-gobject.git seq: queue-timer-common: add common interface for queue timer In UAPI of ALSA Sequencer, queue timer is expressed by union to support several types of backend timer. This commit adds common interface for the timer. It should implements two properties; the identifier of queue and the type of timer. Signed-off-by: Takashi Sakamoto --- diff --git a/src/seq/alsaseq.h b/src/seq/alsaseq.h index e70a768..148cbc3 100644 --- a/src/seq/alsaseq.h +++ b/src/seq/alsaseq.h @@ -19,6 +19,8 @@ #include #include +#include + #include #include #include diff --git a/src/seq/alsaseq.map b/src/seq/alsaseq.map index fbd02b0..3a1fd30 100644 --- a/src/seq/alsaseq.map +++ b/src/seq/alsaseq.map @@ -224,4 +224,6 @@ ALSA_GOBJECT_0_3_0 { "alsaseq_event_cntr_set_connect_data"; "alsaseq_event_cntr_get_result_data"; "alsaseq_event_cntr_set_result_data"; + + "alsaseq_queue_timer_common_get_type"; } ALSA_GOBJECT_0_2_0; diff --git a/src/seq/meson.build b/src/seq/meson.build index ee3b241..bec7739 100644 --- a/src/seq/meson.build +++ b/src/seq/meson.build @@ -30,6 +30,7 @@ sources = files( 'queue-timer-data-alsa.c', 'remove-filter.c', 'event-cntr.c', + 'queue-timer-common.c', ) headers = files( @@ -54,6 +55,7 @@ headers = files( 'queue-timer-data-alsa.h', 'remove-filter.h', 'event-cntr.h', + 'queue-timer-common.h', ) privates = files( diff --git a/src/seq/privates.h b/src/seq/privates.h index 37b17af..37d3542 100644 --- a/src/seq/privates.h +++ b/src/seq/privates.h @@ -39,6 +39,9 @@ void seq_event_cntr_set_buf(ALSASeqEventCntr *self, guint8 *buf, void seq_event_cntr_get_buf(ALSASeqEventCntr *self, gsize count, const guint8 **buf, gsize *length); +#define QUEUE_ID_PROP_NAME "queue-id" +#define TIMER_TYPE_PROP_NAME "timer-type" + G_END_DECLS #endif diff --git a/src/seq/queue-timer-common.c b/src/seq/queue-timer-common.c new file mode 100644 index 0000000..cf13b19 --- /dev/null +++ b/src/seq/queue-timer-common.c @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +#include "privates.h" + +/** + * ALSASeqQueueTimerCommon: + * An interface to express common features of queue timer. + * + * A [iface@QueueTimerCommon] should be implemented by any type of queue timer. + * + * The object wraps `struct snd_seq_queue_timer` in UAPI of Linux sound subsystem. + * + * Since: 0.3. + */ + +static void alsaseq_queue_timer_common_default_init(ALSASeqQueueTimerCommonInterface *iface); + +G_DEFINE_INTERFACE(ALSASeqQueueTimerCommon, alsaseq_queue_timer_common, G_TYPE_OBJECT) + +static void alsaseq_queue_timer_common_default_init(ALSASeqQueueTimerCommonInterface *iface) +{ + /** + * ALSASeqQueueTimerCommon:queue-id: + * + * The numeric identifier of queue, including one of [enum@SpecificClientId]. + * + * Since: 0.3. + */ + g_object_interface_install_property(iface, + g_param_spec_uchar(QUEUE_ID_PROP_NAME, QUEUE_ID_PROP_NAME, + "The numeric identifier of queue including ALSASeqSpecificClientId.", + 0, G_MAXUINT8, 0, + G_PARAM_READABLE)); + + /** + * ALSASeqQueueTimerCommon:timer-type: + * + * The type of timer for the queue, one of [enum@QueueTimerType]. + * + * Since: 0.3. + */ + g_object_interface_install_property(iface, + g_param_spec_enum(TIMER_TYPE_PROP_NAME, TIMER_TYPE_PROP_NAME, + "The type of timer for the queue, one of ALSASeqQueueTimerType.", + ALSASEQ_TYPE_QUEUE_TIMER_TYPE, ALSASEQ_QUEUE_TIMER_TYPE_ALSA, + G_PARAM_READABLE)); +} diff --git a/src/seq/queue-timer-common.h b/src/seq/queue-timer-common.h new file mode 100644 index 0000000..47372ad --- /dev/null +++ b/src/seq/queue-timer-common.h @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +#ifndef __ALSA_GOBJECT_ALSASEQ_QUEUE_TIMER_COMMON_H__ +#define __ALSA_GOBJECT_ALSASEQ_QUEUE_TIMER_COMMON_H__ + +#include + +G_BEGIN_DECLS + +#define ALSASEQ_TYPE_QUEUE_TIMER_COMMON (alsaseq_queue_timer_common_get_type()) + +G_DECLARE_INTERFACE(ALSASeqQueueTimerCommon, alsaseq_queue_timer_common, ALSASEQ, + QUEUE_TIMER_COMMON, GObject) + +struct _ALSASeqQueueTimerCommonInterface { + GTypeInterface parent_iface; +}; + +G_END_DECLS + +#endif