aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2022-05-04 17:18:29 +0900
committer坂本 貴史 <o-takashi@sakamocchi.jp>2022-05-05 08:10:07 +0900
commiteab1a247c221e2173b320b3481abb592bc70752d (patch)
treed2a4b187a783021a315b51daa982f52beac1b148
parent80f397e4fe3802ce5284f2c068cf409bb437e58e (diff)
downloadlibhinoko-eab1a247c221e2173b320b3481abb592bc70752d.tar.gz
fw_iso_ctx: code refactoring for stopped signal
This commit improves current implementation of stopped signal. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rw-r--r--src/fw_iso_ctx.c27
-rw-r--r--src/fw_iso_ctx.h2
-rw-r--r--src/fw_iso_ctx_private.h2
3 files changed, 20 insertions, 11 deletions
diff --git a/src/fw_iso_ctx.c b/src/fw_iso_ctx.c
index a6f6cfe..cdf8cbf 100644
--- a/src/fw_iso_ctx.c
+++ b/src/fw_iso_ctx.c
@@ -162,12 +162,12 @@ static void hinoko_fw_iso_ctx_class_init(HinokoFwIsoCtxClass *klass)
/**
* HinokoFwIsoCtx::stopped:
* @self: A [class@FwIsoCtx].
- * @error: (transfer none) (nullable): A [struct@GLib.Error].
+ * @error: (transfer none) (nullable) (in): A [struct@GLib.Error].
*
* Emitted when isochronous context is stopped.
*/
fw_iso_ctx_sigs[FW_ISO_CTX_SIG_TYPE_STOPPED] =
- g_signal_new("stopped",
+ g_signal_new(STOPPED_SIGNAL_NEME,
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(HinokoFwIsoCtxClass, stopped),
@@ -638,11 +638,10 @@ static void fw_iso_ctx_queue_chunks(HinokoFwIsoCtx *self, GError **error)
priv->registered_chunk_count = 0;
}
-static void fw_iso_ctx_stop(HinokoFwIsoCtx *self, GError *error)
+static void fw_iso_ctx_stop(HinokoFwIsoCtx *self)
{
struct fw_cdev_stop_iso arg = {0};
- HinokoFwIsoCtxPrivate *priv =
- hinoko_fw_iso_ctx_get_instance_private(self);
+ HinokoFwIsoCtxPrivate *priv = hinoko_fw_iso_ctx_get_instance_private(self);
if (!priv->running)
return;
@@ -654,9 +653,6 @@ static void fw_iso_ctx_stop(HinokoFwIsoCtx *self, GError *error)
priv->registered_chunk_count = 0;
priv->data_length = 0;
priv->curr_offset = 0;
-
- g_signal_emit(self, fw_iso_ctx_sigs[FW_ISO_CTX_SIG_TYPE_STOPPED], 0,
- error, NULL);
}
static gboolean check_src(GSource *gsrc)
@@ -757,7 +753,9 @@ static gboolean dispatch_src(GSource *gsrc, GSourceFunc cb, gpointer user_data)
// Just be sure to continue to process this source.
return G_SOURCE_CONTINUE;
error:
- fw_iso_ctx_stop(self, error);
+ hinoko_fw_iso_ctx_stop(self);
+ g_signal_emit(self, fw_iso_ctx_sigs[FW_ISO_CTX_SIG_TYPE_STOPPED], 0, error);
+ g_clear_error(&error);
return G_SOURCE_REMOVE;
}
@@ -907,9 +905,18 @@ void hinoko_fw_iso_ctx_start(HinokoFwIsoCtx *self, const guint16 *cycle_match, g
*/
void hinoko_fw_iso_ctx_stop(HinokoFwIsoCtx *self)
{
+ HinokoFwIsoCtxPrivate *priv;
+ gboolean running;
+
g_return_if_fail(HINOKO_IS_FW_ISO_CTX(self));
+ priv = hinoko_fw_iso_ctx_get_instance_private(self);
+
+ running = priv->running;
+
+ fw_iso_ctx_stop(self);
- fw_iso_ctx_stop(self, NULL);
+ if (priv->running != running)
+ g_signal_emit(self, fw_iso_ctx_sigs[FW_ISO_CTX_SIG_TYPE_STOPPED], 0, NULL);
}
/**
diff --git a/src/fw_iso_ctx.h b/src/fw_iso_ctx.h
index 08ec863..16330a4 100644
--- a/src/fw_iso_ctx.h
+++ b/src/fw_iso_ctx.h
@@ -20,7 +20,7 @@ struct _HinokoFwIsoCtxClass {
/**
* HinokoFwIsoCtxClass::stopped:
* @self: A [class@FwIsoCtx].
- * @error: (transfer none) (nullable): A [struct@GLib.Error].
+ * @error: (transfer none) (nullable) (in): A [struct@GLib.Error].
*
* Class closure for the [signal@FwIsoCtx::stopped] signal.
*/
diff --git a/src/fw_iso_ctx_private.h b/src/fw_iso_ctx_private.h
index 2286606..3797993 100644
--- a/src/fw_iso_ctx_private.h
+++ b/src/fw_iso_ctx_private.h
@@ -7,6 +7,8 @@
#include <unistd.h>
#include <errno.h>
+#define STOPPED_SIGNAL_NEME "stopped"
+
void hinoko_fw_iso_ctx_allocate(HinokoFwIsoCtx *self, const char *path,
HinokoFwIsoCtxMode mode, HinokoFwScode scode,
guint channel, guint header_size,