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
commit677906b75b3dac3480058209909873789787201e (patch)
tree3402a0ea1a1ba74a7c477d10b213785244d52c77
parentd0680011baf0b56e6a5068de1e0229bc78c80746 (diff)
downloadlibhinoko-677906b75b3dac3480058209909873789787201e.tar.gz
fw_iso_ctx: add public API to release isochronous context
The signature of functions to release isochronous context is the same between GObject-derived object classes implementing Hinoko.FwIsoCtx. This commit adds public API for the porpose in the interface. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rw-r--r--src/fw_iso_ctx.c16
-rw-r--r--src/fw_iso_ctx.h4
-rw-r--r--src/fw_iso_rx_multiple.c46
-rw-r--r--src/fw_iso_rx_multiple.h1
-rw-r--r--src/fw_iso_rx_single.c34
-rw-r--r--src/fw_iso_rx_single.h1
-rw-r--r--src/fw_iso_tx.c34
-rw-r--r--src/fw_iso_tx.h1
-rw-r--r--src/hinoko.map4
9 files changed, 69 insertions, 72 deletions
diff --git a/src/fw_iso_ctx.c b/src/fw_iso_ctx.c
index 3591c82..7eacbbf 100644
--- a/src/fw_iso_ctx.c
+++ b/src/fw_iso_ctx.c
@@ -137,6 +137,22 @@ void hinoko_fw_iso_ctx_unmap_buffer(HinokoFwIsoCtx *self)
}
/**
+ * hinoko_fw_iso_ctx_release:
+ * @self: A [iface@FwIsoCtx].
+ *
+ * Release the contest from 1394 OHCI controller.
+ *
+ * Since: 0.7.
+ */
+void hinoko_fw_iso_ctx_release(HinokoFwIsoCtx *self)
+{
+ g_return_if_fail(HINOKO_IS_FW_ISO_CTX(self));
+
+ hinoko_fw_iso_ctx_unmap_buffer(self);
+ HINOKO_FW_ISO_CTX_GET_IFACE(self)->release(self);
+}
+
+/**
* hinoko_fw_iso_ctx_flush_completions:
* @self: A [iface@FwIsoCtx].
* @error: A [struct@GLib.Error].
diff --git a/src/fw_iso_ctx.h b/src/fw_iso_ctx.h
index 7144506..dc49db9 100644
--- a/src/fw_iso_ctx.h
+++ b/src/fw_iso_ctx.h
@@ -21,6 +21,8 @@ struct _HinokoFwIsoCtxInterface {
void (*unmap_buffer)(HinokoFwIsoCtx *self);
+ void (*release)(HinokoFwIsoCtx *self);
+
gboolean (*get_cycle_timer)(HinokoFwIsoCtx *self, gint clock_id,
HinokoCycleTimer *const *cycle_timer, GError **error);
@@ -42,6 +44,8 @@ void hinoko_fw_iso_ctx_stop(HinokoFwIsoCtx *self);
void hinoko_fw_iso_ctx_unmap_buffer(HinokoFwIsoCtx *self);
+void hinoko_fw_iso_ctx_release(HinokoFwIsoCtx *self);
+
void hinoko_fw_iso_ctx_get_cycle_timer(HinokoFwIsoCtx *self, gint clock_id,
HinokoCycleTimer *const *cycle_timer,
GError **error);
diff --git a/src/fw_iso_rx_multiple.c b/src/fw_iso_rx_multiple.c
index 650ebb1..8c10d1c 100644
--- a/src/fw_iso_rx_multiple.c
+++ b/src/fw_iso_rx_multiple.c
@@ -62,9 +62,7 @@ static void fw_iso_rx_multiple_get_property(GObject *obj, guint id, GValue *val,
static void fw_iso_rx_multiple_finalize(GObject *obj)
{
- HinokoFwIsoRxMultiple *self = HINOKO_FW_ISO_RX_MULTIPLE(obj);
-
- hinoko_fw_iso_rx_multiple_release(self);
+ hinoko_fw_iso_ctx_release(HINOKO_FW_ISO_CTX(obj));
G_OBJECT_CLASS(hinoko_fw_iso_rx_multiple_parent_class)->finalize(obj);
}
@@ -153,6 +151,22 @@ static void fw_iso_rx_multiple_unmap_buffer(HinokoFwIsoCtx *inst)
priv->concat_frames = NULL;
}
+static void fw_iso_rx_multiple_release(HinokoFwIsoCtx *inst)
+{
+ HinokoFwIsoRxMultiple *self;
+ HinokoFwIsoRxMultiplePrivate *priv;
+
+ g_return_if_fail(HINOKO_IS_FW_ISO_RX_MULTIPLE(inst));
+ self = HINOKO_FW_ISO_RX_MULTIPLE(inst);
+ priv = hinoko_fw_iso_rx_multiple_get_instance_private(self);
+
+ fw_iso_ctx_state_release(&priv->state);
+
+ if (priv->channels != NULL)
+ g_byte_array_unref(priv->channels);
+ priv->channels = NULL;
+}
+
static gboolean fw_iso_rx_multiple_get_cycle_timer(HinokoFwIsoCtx *inst, gint clock_id,
HinokoCycleTimer *const *cycle_timer,
GError **error)
@@ -303,6 +317,7 @@ static void fw_iso_ctx_iface_init(HinokoFwIsoCtxInterface *iface)
{
iface->stop = fw_iso_rx_multiple_stop;
iface->unmap_buffer = fw_iso_rx_multiple_unmap_buffer;
+ iface->release = fw_iso_rx_multiple_release;
iface->get_cycle_timer = fw_iso_rx_multiple_get_cycle_timer;
iface->flush_completions = fw_iso_rx_multiple_flush_completions;
iface->create_source = fw_iso_rx_multiple_create_source;
@@ -364,13 +379,13 @@ void hinoko_fw_iso_rx_multiple_allocate(HinokoFwIsoRxMultiple *self,
set.handle = priv->state.handle;
if (ioctl(priv->state.fd, FW_CDEV_IOC_SET_ISO_CHANNELS, &set) < 0) {
generate_syscall_error(error, errno, "ioctl(%s)", "FW_CDEV_IOC_SET_ISO_CHANNELS");
- hinoko_fw_iso_rx_multiple_release(self);
+ hinoko_fw_iso_ctx_release(HINOKO_FW_ISO_CTX(self));
return;
} else if (set.channels == 0) {
g_set_error_literal(error, HINOKO_FW_ISO_CTX_ERROR,
HINOKO_FW_ISO_CTX_ERROR_NO_ISOC_CHANNEL,
"No isochronous channel is available");
- hinoko_fw_iso_rx_multiple_release(self);
+ hinoko_fw_iso_ctx_release(HINOKO_FW_ISO_CTX(self));
return;
}
@@ -382,27 +397,6 @@ void hinoko_fw_iso_rx_multiple_allocate(HinokoFwIsoRxMultiple *self,
}
/**
- * hinoko_fw_iso_rx_multiple_release:
- * @self: A [class@FwIsoRxMultiple].
- *
- * Release allocated IR context from 1394 OHCI controller.
- */
-void hinoko_fw_iso_rx_multiple_release(HinokoFwIsoRxMultiple *self)
-{
- HinokoFwIsoRxMultiplePrivate *priv;
-
- g_return_if_fail(HINOKO_IS_FW_ISO_RX_MULTIPLE(self));
- priv = hinoko_fw_iso_rx_multiple_get_instance_private(self);
-
- fw_iso_ctx_state_unmap_buffer(&priv->state);
- fw_iso_ctx_state_release(&priv->state);
-
- if (priv->channels != NULL)
- g_byte_array_unref(priv->channels);
- priv->channels = NULL;
-}
-
-/**
* hinoko_fw_iso_rx_multiple_map_buffer:
* @self: A [class@FwIsoRxMultiple].
* @bytes_per_chunk: The maximum number of bytes for payload of isochronous packet (not payload for
diff --git a/src/fw_iso_rx_multiple.h b/src/fw_iso_rx_multiple.h
index 060eeaf..6dcbec1 100644
--- a/src/fw_iso_rx_multiple.h
+++ b/src/fw_iso_rx_multiple.h
@@ -31,7 +31,6 @@ void hinoko_fw_iso_rx_multiple_allocate(HinokoFwIsoRxMultiple *self,
const guint8 *channels,
guint channels_length,
GError **error);
-void hinoko_fw_iso_rx_multiple_release(HinokoFwIsoRxMultiple *self);
void hinoko_fw_iso_rx_multiple_map_buffer(HinokoFwIsoRxMultiple *self,
guint bytes_per_chunk,
diff --git a/src/fw_iso_rx_single.c b/src/fw_iso_rx_single.c
index e39e49d..841cc4f 100644
--- a/src/fw_iso_rx_single.c
+++ b/src/fw_iso_rx_single.c
@@ -42,9 +42,7 @@ static void fw_iso_rx_single_get_property(GObject *obj, guint id, GValue *val, G
static void fw_iso_rx_single_finalize(GObject *obj)
{
- HinokoFwIsoRxSingle *self = HINOKO_FW_ISO_RX_SINGLE(obj);
-
- hinoko_fw_iso_rx_single_release(self);
+ hinoko_fw_iso_ctx_release(HINOKO_FW_ISO_CTX(obj));
G_OBJECT_CLASS(hinoko_fw_iso_rx_single_parent_class)->finalize(obj);
}
@@ -129,6 +127,18 @@ static void fw_iso_rx_single_unmap_buffer(HinokoFwIsoCtx *inst)
fw_iso_ctx_state_unmap_buffer(&priv->state);
}
+static void fw_iso_rx_single_release(HinokoFwIsoCtx *inst)
+{
+ HinokoFwIsoRxSingle *self;
+ HinokoFwIsoRxSinglePrivate *priv;
+
+ g_return_if_fail(HINOKO_IS_FW_ISO_RX_SINGLE(inst));
+ self = HINOKO_FW_ISO_RX_SINGLE(inst);
+ priv = hinoko_fw_iso_rx_single_get_instance_private(self);
+
+ fw_iso_ctx_state_release(&priv->state);
+}
+
static gboolean fw_iso_rx_single_get_cycle_timer(HinokoFwIsoCtx *inst, gint clock_id,
HinokoCycleTimer *const *cycle_timer,
GError **error)
@@ -207,6 +217,7 @@ static void fw_iso_ctx_iface_init(HinokoFwIsoCtxInterface *iface)
{
iface->stop = fw_iso_rx_single_stop;
iface->unmap_buffer = fw_iso_rx_single_unmap_buffer;
+ iface->release = fw_iso_rx_single_release;
iface->get_cycle_timer = fw_iso_rx_single_get_cycle_timer;
iface->flush_completions = fw_iso_rx_single_flush_completions;
iface->create_source = fw_iso_rx_single_create_source;
@@ -255,23 +266,6 @@ void hinoko_fw_iso_rx_single_allocate(HinokoFwIsoRxSingle *self,
priv->header_size = header_size;
}
-/**
- * hinoko_fw_iso_rx_single_release:
- * @self: A [class@FwIsoRxSingle].
- *
- * Release allocated IR context from 1394 OHCI controller.
- */
-void hinoko_fw_iso_rx_single_release(HinokoFwIsoRxSingle *self)
-{
- HinokoFwIsoRxSinglePrivate *priv;
-
- g_return_if_fail(HINOKO_IS_FW_ISO_RX_SINGLE(self));
- priv = hinoko_fw_iso_rx_single_get_instance_private(self);
-
- fw_iso_ctx_state_unmap_buffer(&priv->state);
- fw_iso_ctx_state_release(&priv->state);
-}
-
/*
* hinoko_fw_iso_rx_single_map_buffer:
* @self: A [class@FwIsoRxSingle].
diff --git a/src/fw_iso_rx_single.h b/src/fw_iso_rx_single.h
index 45c9649..f04e880 100644
--- a/src/fw_iso_rx_single.h
+++ b/src/fw_iso_rx_single.h
@@ -37,7 +37,6 @@ void hinoko_fw_iso_rx_single_allocate(HinokoFwIsoRxSingle *self,
const char *path,
guint channel, guint header_size,
GError **error);
-void hinoko_fw_iso_rx_single_release(HinokoFwIsoRxSingle *self);
void hinoko_fw_iso_rx_single_map_buffer(HinokoFwIsoRxSingle *self,
guint maximum_bytes_per_payload,
diff --git a/src/fw_iso_tx.c b/src/fw_iso_tx.c
index 6cb74de..ed91a71 100644
--- a/src/fw_iso_tx.c
+++ b/src/fw_iso_tx.c
@@ -36,9 +36,7 @@ static void fw_iso_tx_get_property(GObject *obj, guint id, GValue *val, GParamSp
static void fw_iso_tx_finalize(GObject *obj)
{
- HinokoFwIsoTx *self = HINOKO_FW_ISO_TX(obj);
-
- hinoko_fw_iso_tx_release(self);
+ hinoko_fw_iso_ctx_release(HINOKO_FW_ISO_CTX(obj));
G_OBJECT_CLASS(hinoko_fw_iso_tx_parent_class)->finalize(obj);
}
@@ -120,6 +118,18 @@ void fw_iso_tx_unmap_buffer(HinokoFwIsoCtx *inst)
fw_iso_ctx_state_unmap_buffer(&priv->state);
}
+static void fw_iso_tx_release(HinokoFwIsoCtx *inst)
+{
+ HinokoFwIsoTx *self;
+ HinokoFwIsoTxPrivate *priv;
+
+ g_return_if_fail(HINOKO_IS_FW_ISO_TX(inst));
+ self = HINOKO_FW_ISO_TX(inst);
+ priv = hinoko_fw_iso_tx_get_instance_private(self);
+
+ fw_iso_ctx_state_release(&priv->state);
+}
+
static gboolean fw_iso_tx_get_cycle_timer(HinokoFwIsoCtx *inst, gint clock_id,
HinokoCycleTimer *const *cycle_timer,
GError **error)
@@ -189,6 +199,7 @@ static void fw_iso_ctx_iface_init(HinokoFwIsoCtxInterface *iface)
{
iface->stop = fw_iso_tx_stop;
iface->unmap_buffer = fw_iso_tx_unmap_buffer;
+ iface->release = fw_iso_tx_release;
iface->get_cycle_timer = fw_iso_tx_get_cycle_timer;
iface->flush_completions = fw_iso_tx_flush_completions;
iface->create_source = fw_iso_tx_create_source;
@@ -234,23 +245,6 @@ void hinoko_fw_iso_tx_allocate(HinokoFwIsoTx *self, const char *path,
}
/**
- * hinoko_fw_iso_tx_release:
- * @self: A [class@FwIsoTx].
- *
- * Release allocated IT context from 1394 OHCI controller.
- */
-void hinoko_fw_iso_tx_release(HinokoFwIsoTx *self)
-{
- HinokoFwIsoTxPrivate *priv;
-
- g_return_if_fail(HINOKO_IS_FW_ISO_TX(self));
- priv = hinoko_fw_iso_tx_get_instance_private(self);
-
- fw_iso_ctx_state_unmap_buffer(&priv->state);
- fw_iso_ctx_state_release(&priv->state);
-}
-
-/**
* hinoko_fw_iso_tx_map_buffer:
* @self: A [class@FwIsoTx].
* @maximum_bytes_per_payload: The number of bytes for payload of IT context.
diff --git a/src/fw_iso_tx.h b/src/fw_iso_tx.h
index e47ccc7..e37dd1d 100644
--- a/src/fw_iso_tx.h
+++ b/src/fw_iso_tx.h
@@ -35,7 +35,6 @@ HinokoFwIsoTx *hinoko_fw_iso_tx_new(void);
void hinoko_fw_iso_tx_allocate(HinokoFwIsoTx *self, const char *path,
HinokoFwScode scode, guint channel,
guint header_size, GError **error);
-void hinoko_fw_iso_tx_release(HinokoFwIsoTx *self);
void hinoko_fw_iso_tx_map_buffer(HinokoFwIsoTx *self,
guint maximum_bytes_per_payload,
diff --git a/src/hinoko.map b/src/hinoko.map
index 7ef5421..6be5888 100644
--- a/src/hinoko.map
+++ b/src/hinoko.map
@@ -9,20 +9,17 @@ HINOKO_0_1_0 {
"hinoko_fw_iso_rx_single_new";
"hinoko_fw_iso_rx_single_allocate";
- "hinoko_fw_iso_rx_single_release";
"hinoko_fw_iso_rx_single_map_buffer";
"hinoko_fw_iso_rx_single_get_payload";
"hinoko_fw_iso_rx_multiple_new";
"hinoko_fw_iso_rx_multiple_allocate";
- "hinoko_fw_iso_rx_multiple_release";
"hinoko_fw_iso_rx_multiple_map_buffer";
"hinoko_fw_iso_rx_multiple_start";
"hinoko_fw_iso_rx_multiple_get_payload";
"hinoko_fw_iso_tx_new";
"hinoko_fw_iso_tx_allocate";
- "hinoko_fw_iso_tx_release";
"hinoko_fw_iso_tx_map_buffer";
local:
*;
@@ -74,6 +71,7 @@ HINOKO_0_7_0 {
"hinoko_fw_iso_ctx_get_type";
"hinoko_fw_iso_ctx_stop";
"hinoko_fw_iso_ctx_unmap_buffer";
+ "hinoko_fw_iso_ctx_release";
"hinoko_fw_iso_rx_single_get_type";
"hinoko_fw_iso_rx_multiple_get_type";