[PATCH 04/25] efw-downloader: efw-proto: add responded signal

Takashi Sakamoto o-takashi at sakamocchi.jp
Fri Aug 21 09:30:50 CEST 2020


GObject has a feature of 'signal'. It's emitted in event dispatcher
asynchronously to application which register own callback function in
advance.

This commit adds 'responded' GObject signal to handle data in response
frame. In future commit, the signal is emitted actually.

Signed-off-by: Takashi Sakamoto <o-takashi at sakamocchi.jp>
---
 .../src/efw-proto-sigs-marshal.list           |  1 +
 efw-downloader/src/efw-proto.c                | 32 +++++++++++++++++++
 efw-downloader/src/efw-proto.h                |  1 +
 efw-downloader/src/meson.build                |  8 +++++
 4 files changed, 42 insertions(+)
 create mode 100644 efw-downloader/src/efw-proto-sigs-marshal.list

diff --git a/efw-downloader/src/efw-proto-sigs-marshal.list b/efw-downloader/src/efw-proto-sigs-marshal.list
new file mode 100644
index 0000000..c489d58
--- /dev/null
+++ b/efw-downloader/src/efw-proto-sigs-marshal.list
@@ -0,0 +1 @@
+VOID:ENUM,UINT,UINT,UINT,POINTER,UINT
diff --git a/efw-downloader/src/efw-proto.c b/efw-downloader/src/efw-proto.c
index a6a6055..6502957 100644
--- a/efw-downloader/src/efw-proto.c
+++ b/efw-downloader/src/efw-proto.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-3.0-or-later
 // Copyright (c) 2020 Takashi Sakamoto
 #include "efw-proto.h"
+#include "efw-proto-sigs-marshal.h"
 
 /**
  * SECTION:efw_proto
@@ -19,6 +20,12 @@ G_DEFINE_TYPE(EfwProto, efw_proto, HINAWA_TYPE_FW_RESP)
 #define EFW_RESP_ADDR           0xecc080000000ull
 #define EFW_MAX_FRAME_SIZE      0x200u
 
+enum efw_proto_sig_type {
+    EFW_PROTO_SIG_TYPE_RESPONDED = 1,
+    EFW_PROTO_SIG_COUNT,
+};
+static guint efw_proto_sigs[EFW_PROTO_SIG_COUNT] = { 0 };
+
 static void proto_finalize(GObject *obj)
 {
     EfwProto *self = EFW_PROTO(obj);
@@ -33,6 +40,31 @@ static void efw_proto_class_init(EfwProtoClass *klass)
     GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
 
     gobject_class->finalize = proto_finalize;
+
+    /**
+     * EfwProto::responded:
+     * @self: A #EfwProto.
+     * @status: One of #HinawaSndEfwStatus.
+     * @seqnum: The sequence number of response.
+     * @category: The value of category field in the response.
+     * @command: The value of command field in the response.
+     * @frame: (array length=frame_size)(element-type guint32): The array with elements for
+     *         quadlet data of response for Echo Fireworks protocol.
+     * @frame_size: The number of elements of the array.
+     *
+     * When the unit transfers asynchronous packet as response for Fireworks protocol, and the
+     * process successfully reads the content of response from ALSA Fireworks driver, the
+     * #EfwProto::responded signal handler is called with parameters of the response.
+     */
+    efw_proto_sigs[EFW_PROTO_SIG_TYPE_RESPONDED] =
+        g_signal_new("responded",
+            G_OBJECT_CLASS_TYPE(klass),
+            G_SIGNAL_RUN_LAST,
+            0,
+            NULL, NULL,
+            efw_proto_sigs_marshal_VOID__ENUM_UINT_UINT_UINT_POINTER_UINT,
+            G_TYPE_NONE,
+            6, HINAWA_TYPE_SND_EFW_STATUS, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_POINTER, G_TYPE_UINT);
 }
 
 static void efw_proto_init(EfwProto *self)
diff --git a/efw-downloader/src/efw-proto.h b/efw-downloader/src/efw-proto.h
index b0e519d..fbd4366 100644
--- a/efw-downloader/src/efw-proto.h
+++ b/efw-downloader/src/efw-proto.h
@@ -7,6 +7,7 @@
 #include <glib-object.h>
 
 #include <libhinawa/fw_resp.h>
+#include <libhinawa/hinawa_enum_types.h>
 
 G_BEGIN_DECLS
 
diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build
index b7992a2..ca894d9 100644
--- a/efw-downloader/src/meson.build
+++ b/efw-downloader/src/meson.build
@@ -20,6 +20,14 @@ headers = [
   'efw-proto.h',
 ]
 
+gnome = import('gnome')
+marshallers = gnome.genmarshal('efw-proto-sigs-marshal',
+  prefix: 'efw_proto_sigs_marshal',
+  sources: 'efw-proto-sigs-marshal.list',
+  stdinc: true,
+)
+sources += marshallers
+
 executable('efw-downloader',
   sources: sources + headers,
   dependencies: [
-- 
2.25.1



More information about the Alsa-devel mailing list