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
commit76056ca42762fe9509fc30a510fa5d1cdc3ca657 (patch)
tree9c11b5aa880f52e6cb27e2964347206bd749b81c
parent2a0d205f9ff61fd6ab8d045ca3d5480fc5b1e83b (diff)
downloadlibhinoko-76056ca42762fe9509fc30a510fa5d1cdc3ca657.tar.gz
fw_iso_ctx: code refactoring to split unmap 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.unmap() into internal API part and private implementation. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rw-r--r--src/fw_iso_ctx.c11
-rw-r--r--src/fw_iso_ctx_private.c19
-rw-r--r--src/fw_iso_ctx_private.h1
3 files changed, 21 insertions, 10 deletions
diff --git a/src/fw_iso_ctx.c b/src/fw_iso_ctx.c
index a6d8e9f..8a8a86d 100644
--- a/src/fw_iso_ctx.c
+++ b/src/fw_iso_ctx.c
@@ -241,16 +241,7 @@ void hinoko_fw_iso_ctx_unmap_buffer(HinokoFwIsoCtx *self)
hinoko_fw_iso_ctx_stop(self);
- if (priv->addr != NULL) {
- munmap(priv->addr,
- priv->bytes_per_chunk * priv->chunks_per_buffer);
- }
-
- if (priv->data != NULL)
- free(priv->data);
-
- priv->addr = NULL;
- priv->data = NULL;
+ fw_iso_ctx_state_unmap_buffer(priv);
}
/**
diff --git a/src/fw_iso_ctx_private.c b/src/fw_iso_ctx_private.c
index c20b3e7..2923991 100644
--- a/src/fw_iso_ctx_private.c
+++ b/src/fw_iso_ctx_private.c
@@ -169,3 +169,22 @@ gboolean fw_iso_ctx_state_map_buffer(struct fw_iso_ctx_state *state, guint bytes
return TRUE;
}
+
+/**
+ * hinoko_fw_iso_ctx_unmap_buffer:
+ * @state: A [struct@FwIsoCtxState].
+ *
+ * Unmap intermediate buffer shard with 1394 OHCI controller for payload of isochronous context.
+ */
+void fw_iso_ctx_state_unmap_buffer(struct fw_iso_ctx_state *state)
+{
+ if (state->addr != NULL) {
+ munmap(state->addr, state->bytes_per_chunk * state->chunks_per_buffer);
+ }
+
+ if (state->data != NULL)
+ free(state->data);
+
+ state->addr = NULL;
+ state->data = NULL;
+}
diff --git a/src/fw_iso_ctx_private.h b/src/fw_iso_ctx_private.h
index 73622c8..b4530fa 100644
--- a/src/fw_iso_ctx_private.h
+++ b/src/fw_iso_ctx_private.h
@@ -50,6 +50,7 @@ void fw_iso_ctx_state_release(struct fw_iso_ctx_state *state);
gboolean fw_iso_ctx_state_map_buffer(struct fw_iso_ctx_state *state, guint bytes_per_chunk,
guint chunks_per_buffer, GError **error);
+void fw_iso_ctx_state_unmap_buffer(struct fw_iso_ctx_state *state);
void hinoko_fw_iso_ctx_allocate(HinokoFwIsoCtx *self, const char *path,
HinokoFwIsoCtxMode mode, HinokoFwScode scode,