]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
seq: tstamp: add accessor methods
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/tstamp.c
src/seq/tstamp.h

index b10a425c25e9dc1d7d91a8ecd56fea31660b7497..80fd9d81aba75d20a7fb9fa810365223c74834ad 100644 (file)
@@ -54,6 +54,10 @@ ALSA_GOBJECT_0_0_0 {
     "alsaseq_client_pool_get_type";
 
     "alsaseq_tstamp_get_type";
+    "alsaseq_tstamp_get_tick_time";
+    "alsaseq_tstamp_set_tick_time";
+    "alsaseq_tstamp_get_real_time";
+    "alsaseq_tstamp_set_real_time";
   local:
     *;
 };
index bf0d1f6ec9213511d6e9528177a458996b1962e9..5c9077c0f707ee921d4737a8d67aed785fd210b1 100644 (file)
@@ -7,3 +7,58 @@ ALSASeqTstamp *seq_tstamp_copy(const ALSASeqTstamp *self)
 }
 
 G_DEFINE_BOXED_TYPE(ALSASeqTstamp, alsaseq_tstamp, seq_tstamp_copy, g_free)
+
+/**
+ * alsaseq_tstamp_get_tick_time:
+ * @self: A #ALSASeqTstamp.
+ * @tick_time: (out): The number of MIDI ticks.
+ *
+ * Get time as MIDI ticks.
+ */
+void alsaseq_tstamp_get_tick_time(ALSASeqTstamp *self, guint32 *tick_time)
+{
+    *tick_time = self->tick;
+}
+
+/**
+ * alsaseq_tstamp_set_tick_time:
+ * @self: A #ALSASeqTstamp.
+ * @tick_time: The number of MIDI ticks.
+ *
+ * Set time as MIDI ticks.
+ */
+void alsaseq_tstamp_set_tick_time(ALSASeqTstamp *self, const guint32 tick_time)
+{
+    self->tick = tick_time;
+}
+
+/**
+ * alsaseq_tstamp_get_real_time:
+ * @self: A #ALSASeqTstamp.
+ *
+ * Refer to the time as wall-clock time.
+ *
+ * Returns: (array fixed-size=2)(transfer none): The array with two elements
+ *          for sec part and nsec part of real time.
+ */
+const guint32 *alsaseq_tstamp_get_real_time(ALSASeqTstamp *self)
+{
+    // MEMO: I wish 32-bit storage size is aligned to 32 bit offset in all of
+    // supported ABIs.
+    return (guint32 *)&self->time;
+}
+
+
+/**
+ * alsaseq_tstamp_set_real_time:
+ * @self: A #ALSASeqTstamp.
+ * @tstamp: (array fixed-size=2)(transfer none): The array with two elements for
+ *          sec part and nsec part of real time.
+ *
+ * Copy the time as wall-clock time.
+ */
+void alsaseq_tstamp_set_real_time(ALSASeqTstamp *self, const guint32 tstamp[2])
+{
+    self->time.tv_sec = tstamp[0];
+    self->time.tv_nsec = tstamp[1];
+}
index 191ffd7938707b95ffc2d0331f8594c4d8a665f6..30e10e4f77e41a962dbb34636c29a55784f7adbd 100644 (file)
@@ -15,6 +15,12 @@ typedef union snd_seq_timestamp ALSASeqTstamp;
 
 GType alsaseq_tstamp_get_type() G_GNUC_CONST;
 
+void alsaseq_tstamp_get_tick_time(ALSASeqTstamp *self, guint32 *tick_time);
+void alsaseq_tstamp_set_tick_time(ALSASeqTstamp *self, const guint32 tick_time);
+
+const guint32 *alsaseq_tstamp_get_real_time(ALSASeqTstamp *self);
+void alsaseq_tstamp_set_real_time(ALSASeqTstamp *self, const guint32 tstamp[2]);
+
 G_END_DECLS
 
 #endif