aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2022-05-05 11:37:24 +0900
committer坂本 貴史 <o-takashi@sakamocchi.jp>2022-05-05 16:09:50 +0900
commit35c31ee8db09e5103721ba22e5dc7ec50156e2f9 (patch)
tree73908740bffde3ea0c8071aaa914992e805a50f6
parent66c10a4bcc74d06973685cb9a28a2612ee1f71e8 (diff)
downloadlibhinoko-35c31ee8db09e5103721ba22e5dc7ec50156e2f9.tar.gz
fw_iso_ctx: code refactoring to split stop function
It's planned to make Hinoko.FwIsoCtx as interface. It's convenient for derived object to use private helper function instead of instance method. This commit splits current implementaion of Hinoko.FwIsoCtx.stop() into internal API part and private implementation. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rw-r--r--src/fw_iso_ctx.c19
-rw-r--r--src/fw_iso_ctx_private.c22
-rw-r--r--src/fw_iso_ctx_private.h1
3 files changed, 24 insertions, 18 deletions
diff --git a/src/fw_iso_ctx.c b/src/fw_iso_ctx.c
index 5283499..f85c918 100644
--- a/src/fw_iso_ctx.c
+++ b/src/fw_iso_ctx.c
@@ -342,23 +342,6 @@ void hinoko_fw_iso_ctx_register_chunk(HinokoFwIsoCtx *self, gboolean skip,
payload_length, schedule_interrupt, 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);
-
- if (!priv->running)
- return;
-
- arg.handle = priv->handle;
- ioctl(priv->fd, FW_CDEV_IOC_STOP_ISO, &arg);
-
- priv->running = FALSE;
- priv->registered_chunk_count = 0;
- priv->data_length = 0;
- priv->curr_offset = 0;
-}
-
static gboolean check_src(GSource *source)
{
FwIsoCtxSource *src = (FwIsoCtxSource *)source;
@@ -523,7 +506,7 @@ void hinoko_fw_iso_ctx_stop(HinokoFwIsoCtx *self)
running = priv->running;
- fw_iso_ctx_stop(self);
+ fw_iso_ctx_state_stop(priv);
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_private.c b/src/fw_iso_ctx_private.c
index d157184..bc6b6bd 100644
--- a/src/fw_iso_ctx_private.c
+++ b/src/fw_iso_ctx_private.c
@@ -448,3 +448,25 @@ gboolean fw_iso_ctx_state_start(struct fw_iso_ctx_state *state, const guint16 *c
return TRUE;
}
+
+/**
+ * fw_iso_ctx_state_stop:
+ * @state: A [struct@FwIsoCtxState].
+ *
+ * Stop isochronous context.
+ */
+void fw_iso_ctx_state_stop(struct fw_iso_ctx_state *state)
+{
+ struct fw_cdev_stop_iso arg = {0};
+
+ if (!state->running)
+ return;
+
+ arg.handle = state->handle;
+ ioctl(state->fd, FW_CDEV_IOC_STOP_ISO, &arg);
+
+ state->running = FALSE;
+ state->registered_chunk_count = 0;
+ state->data_length = 0;
+ state->curr_offset = 0;
+}
diff --git a/src/fw_iso_ctx_private.h b/src/fw_iso_ctx_private.h
index 8790297..eb6a9e9 100644
--- a/src/fw_iso_ctx_private.h
+++ b/src/fw_iso_ctx_private.h
@@ -61,6 +61,7 @@ gboolean fw_iso_ctx_state_queue_chunks(struct fw_iso_ctx_state *state, GError **
gboolean fw_iso_ctx_state_start(struct fw_iso_ctx_state *state, const guint16 *cycle_match,
guint32 sync, HinokoFwIsoCtxMatchFlag tags, GError **error);
+void fw_iso_ctx_state_stop(struct fw_iso_ctx_state *state);
void hinoko_fw_iso_ctx_allocate(HinokoFwIsoCtx *self, const char *path,
HinokoFwIsoCtxMode mode, HinokoFwScode scode,