]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
Revert "seq: tstamp: use wrapper structure instead of union"
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Wed, 22 Apr 2020 13:53:46 +0000 (22:53 +0900)
committer坂本 貴史 <o-takashi@sakamocchi.jp>
Wed, 22 Apr 2020 14:44:29 +0000 (23:44 +0900)
This reverts commit 20fdc2d893ccba609cc786ebac733bf6914f9874.

In the above commit, union type structure is wrapped with care of
language bindings in which union-compatible feature is not expected.
However, it's responsible for language bindings to parse gir and
the care is not necessarily required in shared library side. In first
place, ALSASeq.Tstamp is boxed type object.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
src/seq/event-data-queue.c
src/seq/event-fixed.c
src/seq/event.c
src/seq/tstamp.c
src/seq/tstamp.h

index 19e1164ad4d975d7cc4d5b9d060e459150cdc5fb..ebf5fb8f7eb3f2bb1fe9dcd6882aded42f1aa317 100644 (file)
@@ -70,9 +70,7 @@ void alsaseq_event_data_queue_set_value_param(ALSASeqEventDataQueue *self,
 void alsaseq_event_data_queue_get_tstamp_param(ALSASeqEventDataQueue *self,
                                                const ALSASeqTstamp **tstamp)
 {
-    // MEMO: I wish the structure has no padding in its head in all of supported
-    // ABIs.
-    *tstamp = (const ALSASeqTstamp *)&self->param.time;
+    *tstamp = &self->param.time;
 }
 
 /**
@@ -85,7 +83,7 @@ void alsaseq_event_data_queue_get_tstamp_param(ALSASeqEventDataQueue *self,
 void alsaseq_event_data_queue_set_tstamp_param(ALSASeqEventDataQueue *self,
                                                const ALSASeqTstamp *tstamp)
 {
-    self->param.time = tstamp->tstamp;
+    self->param.time = *tstamp;
 }
 
 /**
index 92c81c676ae1d7687fb7c48a344dc9ed22f90632..436a5d2ff1e53582b4562b2c8b61b8de71038cda 100644 (file)
@@ -72,7 +72,7 @@ static void seq_event_fixed_set_property(GObject *obj, guint id,
     {
         ALSASeqTstamp *data = g_value_get_boxed(val);
         if (data != NULL)
-            ev->data.time = data->tstamp;
+            ev->data.time = *data;
         break;
     }
     default:
@@ -108,9 +108,7 @@ static void seq_event_fixed_get_property(GObject *obj, guint id, GValue *val,
         g_value_set_static_boxed(val, &ev->data.connect);
         break;
     case SEQ_EVENT_FIXED_PROP_TSTAMP_DATA:
-        // MEMO: I wish the structure has no padding in its head in all of
-       // supported ABIs.
-        g_value_set_static_boxed(val, (ALSASeqTstamp *)&ev->data.time);
+        g_value_set_static_boxed(val, &ev->data.time);
         break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, id, spec);
index f4ea612f7df220ce4d30706bf0cfc051634568ef..dd4958405abd1c6359a2b6a9d40e91484296d2e8 100644 (file)
@@ -60,7 +60,7 @@ static void seq_event_set_property(GObject *obj, guint id, const GValue *val,
     {
         ALSASeqTstamp *tstamp = g_value_get_boxed(val);
         if (tstamp != NULL)
-            ev->time = tstamp->tstamp;
+            ev->time = *tstamp;
         break;
     }
     case SEQ_EVENT_PROP_SRC_ADDR:
@@ -129,9 +129,7 @@ static void seq_event_get_property(GObject *obj, guint id, GValue *val,
         g_value_set_uchar(val, ev->queue);
         break;
     case SEQ_EVENT_PROP_TSTAMP:
-        // MEMO: I wish the structure has no padding in its head in all of
-       // supported ABIs.
-        g_value_set_static_boxed(val, (ALSASeqTstamp *)&ev->time);
+        g_value_set_static_boxed(val, &ev->time);
         break;
     case SEQ_EVENT_PROP_SRC_ADDR:
         g_value_set_static_boxed(val, &ev->source);
index d25f0b585e9446315944309d14d005da738d2218..0066a67423deec4682aee1954275f05eef8f9e25 100644 (file)
@@ -17,7 +17,7 @@ G_DEFINE_BOXED_TYPE(ALSASeqTstamp, alsaseq_tstamp, seq_tstamp_copy, g_free)
  */
 void alsaseq_tstamp_get_tick_time(ALSASeqTstamp *self, guint32 *tick_time)
 {
-    *tick_time = self->tstamp.tick;
+    *tick_time = self->tick;
 }
 
 /**
@@ -29,7 +29,7 @@ void alsaseq_tstamp_get_tick_time(ALSASeqTstamp *self, guint32 *tick_time)
  */
 void alsaseq_tstamp_set_tick_time(ALSASeqTstamp *self, const guint32 tick_time)
 {
-    self->tstamp.tick = tick_time;
+    self->tick = tick_time;
 }
 
 /**
@@ -44,7 +44,7 @@ void alsaseq_tstamp_get_real_time(ALSASeqTstamp *self, const guint32 *real_time[
 {
     // MEMO: I wish 32-bit storage size is aligned to 32 bit offset in all of
     // supported ABIs.
-    *real_time = (guint32 *)&self->tstamp.time;
+    *real_time = (guint32 *)&self->time;
 }
 
 
@@ -58,6 +58,6 @@ void alsaseq_tstamp_get_real_time(ALSASeqTstamp *self, const guint32 *real_time[
  */
 void alsaseq_tstamp_set_real_time(ALSASeqTstamp *self, const guint32 real_time[2])
 {
-    self->tstamp.time.tv_sec = real_time[0];
-    self->tstamp.time.tv_nsec = real_time[1];
+    self->time.tv_sec = real_time[0];
+    self->time.tv_nsec = real_time[1];
 }
index cd7f9d97abf235cbcc84a0377750f9ed63c934a9..6c96d4aad1e21a1ef6b1555027a714e189be5750 100644 (file)
@@ -11,11 +11,7 @@ G_BEGIN_DECLS
 
 #define ALSASEQ_TYPE_TSTAMP   (alsaseq_tstamp_get_type())
 
-// The usage of union is inconvenient to some programming languages which has
-// no support to handle it. Let's use wrapper structure.
-typedef struct {
-    union snd_seq_timestamp tstamp;
-} ALSASeqTstamp;
+typedef union snd_seq_timestamp ALSASeqTstamp;
 
 GType alsaseq_tstamp_get_type() G_GNUC_CONST;