aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2022-05-05 21:15:33 +0900
committer坂本 貴史 <o-takashi@sakamocchi.jp>2022-05-06 08:31:24 +0900
commit7a6eb8fd2ffc4834f792dd5fcf9f901580f77170 (patch)
tree0ff614db015c3d516a1d7ad0aa727ca861fbba9d
parent020fa61b35f9831d330ca26ccf87a5570b7a00ba (diff)
downloadlibhinoko-7a6eb8fd2ffc4834f792dd5fcf9f901580f77170.tar.gz
fw_iso_tx: rewrite public API to return gboolean according to GNOME convention
In GNOME convention, the throw function to report error at GError argument should return gboolean value to report the overall operation finishes successfully or not. On the other hand, it's implemented to return void in Hinoko.FwIsoTx. This commit rewrite such public APIs with loss of backward compatibility. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rw-r--r--src/fw_iso_tx.c77
-rw-r--r--src/fw_iso_tx.h29
-rw-r--r--src/hinoko.map12
3 files changed, 61 insertions, 57 deletions
diff --git a/src/fw_iso_tx.c b/src/fw_iso_tx.c
index 9d8b407..c64b6d6 100644
--- a/src/fw_iso_tx.c
+++ b/src/fw_iso_tx.c
@@ -232,19 +232,22 @@ HinokoFwIsoTx *hinoko_fw_iso_tx_new(void)
* Allocate an IT context to 1394 OHCI controller. A local node of the node corresponding to the
* given path is used as the controller, thus any path is accepted as long as process has enough
* permission for the path.
+ *
+ * Returns: TRUE if the overall operation finishes successful, else FALSE.
+ *
+ * Since: 0.7.
*/
-void hinoko_fw_iso_tx_allocate(HinokoFwIsoTx *self, const char *path,
- HinokoFwScode scode, guint channel,
- guint header_size, GError **error)
+gboolean hinoko_fw_iso_tx_allocate(HinokoFwIsoTx *self, const char *path, HinokoFwScode scode,
+ guint channel, guint header_size, GError **error)
{
HinokoFwIsoTxPrivate *priv;
- g_return_if_fail(HINOKO_IS_FW_ISO_TX(self));
- g_return_if_fail(error == NULL || *error == NULL);
+ g_return_val_if_fail(HINOKO_IS_FW_ISO_TX(self), FALSE);
+ g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
priv = hinoko_fw_iso_tx_get_instance_private(self);
- (void)fw_iso_ctx_state_allocate(&priv->state, path, HINOKO_FW_ISO_CTX_MODE_TX, scode,
- channel, header_size, error);
+ return fw_iso_ctx_state_allocate(&priv->state, path, HINOKO_FW_ISO_CTX_MODE_TX, scode,
+ channel, header_size, error);
}
/**
@@ -255,20 +258,22 @@ void hinoko_fw_iso_tx_allocate(HinokoFwIsoTx *self, const char *path,
* @error: A [struct@GLib.Error].
*
* Map intermediate buffer to share payload of IT context with 1394 OHCI controller.
+ *
+ * Returns: TRUE if the overall operation finishes successful, else FALSE.
+ *
+ * Since: 0.7.
*/
-void hinoko_fw_iso_tx_map_buffer(HinokoFwIsoTx *self,
- guint maximum_bytes_per_payload,
- guint payloads_per_buffer,
- GError **error)
+gboolean hinoko_fw_iso_tx_map_buffer(HinokoFwIsoTx *self, guint maximum_bytes_per_payload,
+ guint payloads_per_buffer, GError **error)
{
HinokoFwIsoTxPrivate *priv;
- g_return_if_fail(HINOKO_IS_FW_ISO_TX(self));
- g_return_if_fail(error == NULL || *error == NULL);
+ g_return_val_if_fail(HINOKO_IS_FW_ISO_TX(self), FALSE);
+ g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
priv = hinoko_fw_iso_tx_get_instance_private(self);
- (void)fw_iso_ctx_state_map_buffer(&priv->state, maximum_bytes_per_payload,
- payloads_per_buffer, error);
+ return fw_iso_ctx_state_map_buffer(&priv->state, maximum_bytes_per_payload,
+ payloads_per_buffer, error);
}
/**
@@ -282,17 +287,19 @@ void hinoko_fw_iso_tx_map_buffer(HinokoFwIsoTx *self,
*
* Start IT context.
*
- * Since: 0.6.
+ * Returns: TRUE if the overall operation finishes successful, else FALSE.
+ *
+ * Since: 0.7.
*/
-void hinoko_fw_iso_tx_start(HinokoFwIsoTx *self, const guint16 *cycle_match, GError **error)
+gboolean hinoko_fw_iso_tx_start(HinokoFwIsoTx *self, const guint16 *cycle_match, GError **error)
{
HinokoFwIsoTxPrivate *priv;
- g_return_if_fail(HINOKO_IS_FW_ISO_TX(self));
- g_return_if_fail(error == NULL || *error == NULL);
+ g_return_val_if_fail(HINOKO_IS_FW_ISO_TX(self), FALSE);
+ g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
priv = hinoko_fw_iso_tx_get_instance_private(self);
- (void)fw_iso_ctx_state_start(&priv->state, cycle_match, 0, 0, error);
+ return fw_iso_ctx_state_start(&priv->state, cycle_match, 0, 0, error);
}
/**
@@ -312,25 +319,27 @@ void hinoko_fw_iso_tx_start(HinokoFwIsoTx *self, const guint16 *cycle_match, GEr
* interrupt to generate interrupt event. In detail, please refer to documentation about
* [signal@FwIsoTx::interrupted].
*
- * Since: 0.6.
+ * Returns: TRUE if the overall operation finishes successful, else FALSE.
+ *
+ * Since: 0.7.
*/
-void hinoko_fw_iso_tx_register_packet(HinokoFwIsoTx *self,
- HinokoFwIsoCtxMatchFlag tags, guint sy,
- const guint8 *header, guint header_length,
- const guint8 *payload, guint payload_length,
- gboolean schedule_interrupt, GError **error)
+gboolean hinoko_fw_iso_tx_register_packet(HinokoFwIsoTx *self, HinokoFwIsoCtxMatchFlag tags,
+ guint sy,
+ const guint8 *header, guint header_length,
+ const guint8 *payload, guint payload_length,
+ gboolean schedule_interrupt, GError **error)
{
HinokoFwIsoTxPrivate *priv;
const guint8 *frames;
guint frame_size;
gboolean skip;
- g_return_if_fail(HINOKO_IS_FW_ISO_TX(self));
- g_return_if_fail((header != NULL && header_length > 0) ||
- (header == NULL && header_length == 0));
- g_return_if_fail((payload != NULL && payload_length > 0) ||
- (payload == NULL && payload_length == 0));
- g_return_if_fail(error == NULL || *error == NULL);
+ g_return_val_if_fail(HINOKO_IS_FW_ISO_TX(self), FALSE);
+ g_return_val_if_fail((header != NULL && header_length > 0) ||
+ (header == NULL && header_length == 0), FALSE);
+ g_return_val_if_fail((payload != NULL && payload_length > 0) ||
+ (payload == NULL && payload_length == 0), FALSE);
+ g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
priv = hinoko_fw_iso_tx_get_instance_private(self);
@@ -340,7 +349,7 @@ void hinoko_fw_iso_tx_register_packet(HinokoFwIsoTx *self,
if (!fw_iso_ctx_state_register_chunk(&priv->state, skip, tags, sy, header, header_length,
payload_length, schedule_interrupt, error))
- return;
+ return FALSE;
fw_iso_ctx_state_read_frame(&priv->state, priv->offset, payload_length, &frames,
&frame_size);
@@ -356,4 +365,6 @@ void hinoko_fw_iso_tx_register_packet(HinokoFwIsoTx *self,
priv->offset = frame_size;
}
+
+ return TRUE;
}
diff --git a/src/fw_iso_tx.h b/src/fw_iso_tx.h
index e37dd1d..b8efb6f 100644
--- a/src/fw_iso_tx.h
+++ b/src/fw_iso_tx.h
@@ -32,22 +32,19 @@ struct _HinokoFwIsoTxClass {
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_map_buffer(HinokoFwIsoTx *self,
- guint maximum_bytes_per_payload,
- guint payloads_per_buffer,
- GError **error);
-
-void hinoko_fw_iso_tx_start(HinokoFwIsoTx *self, const guint16 *cycle_match, GError **error);
-
-void hinoko_fw_iso_tx_register_packet(HinokoFwIsoTx *self,
- HinokoFwIsoCtxMatchFlag tags, guint sy,
- const guint8 *header, guint header_length,
- const guint8 *payload, guint payload_length,
- gboolean schedule_interrupt, GError **error);
+gboolean hinoko_fw_iso_tx_allocate(HinokoFwIsoTx *self, const char *path, HinokoFwScode scode,
+ guint channel, guint header_size, GError **error);
+
+gboolean hinoko_fw_iso_tx_map_buffer(HinokoFwIsoTx *self, guint maximum_bytes_per_payload,
+ guint payloads_per_buffer, GError **error);
+
+gboolean hinoko_fw_iso_tx_start(HinokoFwIsoTx *self, const guint16 *cycle_match, GError **error);
+
+gboolean hinoko_fw_iso_tx_register_packet(HinokoFwIsoTx *self, HinokoFwIsoCtxMatchFlag tags,
+ guint sy,
+ const guint8 *header, guint header_length,
+ const guint8 *payload, guint payload_length,
+ gboolean schedule_interrupt, GError **error);
G_END_DECLS
diff --git a/src/hinoko.map b/src/hinoko.map
index 628e4cc..882ee88 100644
--- a/src/hinoko.map
+++ b/src/hinoko.map
@@ -9,8 +9,6 @@ HINOKO_0_1_0 {
"hinoko_fw_iso_rx_multiple_new";
"hinoko_fw_iso_tx_new";
- "hinoko_fw_iso_tx_allocate";
- "hinoko_fw_iso_tx_map_buffer";
local:
*;
};
@@ -45,12 +43,6 @@ HINOKO_0_5_0 {
"hinoko_fw_iso_ctx_error_quark";
} HINOKO_0_4_0;
-HINOKO_0_6_0 {
- global:
- "hinoko_fw_iso_tx_register_packet";
- "hinoko_fw_iso_tx_start";
-} HINOKO_0_5_0;
-
HINOKO_0_7_0 {
global:
"hinoko_fw_iso_ctx_get_type";
@@ -75,6 +67,10 @@ HINOKO_0_7_0 {
"hinoko_fw_iso_rx_multiple_get_payload";
"hinoko_fw_iso_tx_get_type";
+ "hinoko_fw_iso_tx_allocate";
+ "hinoko_fw_iso_tx_map_buffer";
+ "hinoko_fw_iso_tx_register_packet";
+ "hinoko_fw_iso_tx_start";
"hinoko_fw_iso_resource_get_type";
"hinoko_fw_iso_resource_open";