diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2022-05-05 11:37:24 +0900 |
---|---|---|
committer | 坂本 貴史 <o-takashi@sakamocchi.jp> | 2022-05-05 16:09:50 +0900 |
commit | c211df6e8197db800a5d470870a62669bcced7b8 (patch) | |
tree | d07e35447550dcf29c3f6b2cbc84a0fb794a95e1 | |
parent | 99934c517b6a98002bc55ac05ded03f2fd43236a (diff) | |
download | libhinoko-c211df6e8197db800a5d470870a62669bcced7b8.tar.gz |
fw_iso_ctx: code refactoring to split release 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.release()
into internal API part and private implementation.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rw-r--r-- | src/fw_iso_ctx.c | 5 | ||||
-rw-r--r-- | src/fw_iso_ctx_private.c | 20 | ||||
-rw-r--r-- | src/fw_iso_ctx_private.h | 1 |
3 files changed, 18 insertions, 8 deletions
diff --git a/src/fw_iso_ctx.c b/src/fw_iso_ctx.c index 39e47d1..b153d69 100644 --- a/src/fw_iso_ctx.c +++ b/src/fw_iso_ctx.c @@ -203,10 +203,7 @@ void hinoko_fw_iso_ctx_release(HinokoFwIsoCtx *self) hinoko_fw_iso_ctx_unmap_buffer(self); - if (priv->fd >= 0) - close(priv->fd); - - priv->fd = -1; + fw_iso_ctx_state_release(priv); } /** diff --git a/src/fw_iso_ctx_private.c b/src/fw_iso_ctx_private.c index 7c1fc9c..e622b00 100644 --- a/src/fw_iso_ctx_private.c +++ b/src/fw_iso_ctx_private.c @@ -77,8 +77,7 @@ gboolean fw_iso_ctx_state_allocate(struct fw_iso_ctx_state *state, const char *p info.version = 5; if (ioctl(state->fd, FW_CDEV_IOC_GET_INFO, &info) < 0) { generate_syscall_error(error, errno, "ioctl(%s)", "FW_CDEV_IOC_GET_INFO"); - close(state->fd); - state->fd = -1; + fw_iso_ctx_state_release(state); return FALSE; } @@ -89,8 +88,7 @@ gboolean fw_iso_ctx_state_allocate(struct fw_iso_ctx_state *state, const char *p if (ioctl(state->fd, FW_CDEV_IOC_CREATE_ISO_CONTEXT, &create) < 0) { generate_syscall_error(error, errno, "ioctl(%s)", "FW_CDEV_IOC_CREATE_ISO_CONTEXT"); - close(state->fd); - state->fd = -1; + fw_iso_ctx_state_release(state); return FALSE; } @@ -100,3 +98,17 @@ gboolean fw_iso_ctx_state_allocate(struct fw_iso_ctx_state *state, const char *p return TRUE; } + +/** + * fw_iso_ctx_state_release: + * @state: A [struct@FwIsoCtxState]. + * + * Release allocated isochronous context from 1394 OHCI controller. + */ +void fw_iso_ctx_state_release(struct fw_iso_ctx_state *state) +{ + if (state->fd >= 0) + close(state->fd); + + state->fd = -1; +} diff --git a/src/fw_iso_ctx_private.h b/src/fw_iso_ctx_private.h index 03135f2..f902ed3 100644 --- a/src/fw_iso_ctx_private.h +++ b/src/fw_iso_ctx_private.h @@ -45,6 +45,7 @@ struct fw_iso_ctx_state { gboolean fw_iso_ctx_state_allocate(struct fw_iso_ctx_state *state, const char *path, HinokoFwIsoCtxMode mode, HinokoFwScode scode, guint channel, guint header_size, GError **error); +void fw_iso_ctx_state_release(struct fw_iso_ctx_state *state); #define STOPPED_SIGNAL_NEME "stopped" |