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
commit2d9cab0ff496306ca90939808dd7bc83aeb0b904 (patch)
tree4f3a02489d24896fd6f5a9cfa950763ea1414d3a
parent6855742cbadcf1172eb8093567f8398a351368fa (diff)
downloadlibhinoko-2d9cab0ff496306ca90939808dd7bc83aeb0b904.tar.gz
fw_iso_rx_single: 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.FwIsoRxSingle. 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_rx_single.c77
-rw-r--r--src/fw_iso_rx_single.h24
-rw-r--r--src/hinoko.map12
3 files changed, 60 insertions, 53 deletions
diff --git a/src/fw_iso_rx_single.c b/src/fw_iso_rx_single.c
index 841cc4f..0ddef68 100644
--- a/src/fw_iso_rx_single.c
+++ b/src/fw_iso_rx_single.c
@@ -246,24 +246,28 @@ HinokoFwIsoRxSingle *hinoko_fw_iso_rx_single_new(void)
* Allocate an IR context to 1394 OHCI controller for packet-per-buffer mode. 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 successfully, else FALSE.
+ *
+ * Since: 0.7.
*/
-void hinoko_fw_iso_rx_single_allocate(HinokoFwIsoRxSingle *self,
- const char *path,
- guint channel, guint header_size,
- GError **error)
+gboolean hinoko_fw_iso_rx_single_allocate(HinokoFwIsoRxSingle *self, const char *path,
+ guint channel, guint header_size, GError **error)
{
HinokoFwIsoRxSinglePrivate *priv;
- g_return_if_fail(HINOKO_IS_FW_ISO_RX_SINGLE(self));
- g_return_if_fail(error == NULL || *error == NULL);
+ g_return_val_if_fail(HINOKO_IS_FW_ISO_RX_SINGLE(self), FALSE);
+ g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
priv = hinoko_fw_iso_rx_single_get_instance_private(self);
if (!fw_iso_ctx_state_allocate(&priv->state, path, HINOKO_FW_ISO_CTX_MODE_RX_SINGLE, 0,
channel, header_size, error))
- return;
+ return FALSE;
priv->header_size = header_size;
+
+ return TRUE;
}
/*
@@ -274,21 +278,24 @@ void hinoko_fw_iso_rx_single_allocate(HinokoFwIsoRxSingle *self,
* @error: A [struct@GLib.Error].
*
* Map intermediate buffer to share payload of IR context with 1394 OHCI controller.
+ *
+ * Returns: TRUE if the overall operation finishes successfully, else FALSE.
+ *
+ * Since: 0.7.
*/
-void hinoko_fw_iso_rx_single_map_buffer(HinokoFwIsoRxSingle *self,
- guint maximum_bytes_per_payload,
- guint payloads_per_buffer,
- GError **error)
+gboolean hinoko_fw_iso_rx_single_map_buffer(HinokoFwIsoRxSingle *self,
+ guint maximum_bytes_per_payload,
+ guint payloads_per_buffer, GError **error)
{
HinokoFwIsoRxSinglePrivate *priv;
- g_return_if_fail(HINOKO_IS_FW_ISO_RX_SINGLE(self));
- g_return_if_fail(error == NULL || *error == NULL);
+ g_return_val_if_fail(HINOKO_IS_FW_ISO_RX_SINGLE(self), FALSE);
+ g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
priv = hinoko_fw_iso_rx_single_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);
}
/**
@@ -301,18 +308,20 @@ void hinoko_fw_iso_rx_single_map_buffer(HinokoFwIsoRxSingle *self,
* hardware interrupt to generate interrupt event. In detail, please refer to documentation about
* [signal@FwIsoRxSingle::interrupted] signal.
*
- * Since: 0.6.
+ * Returns: TRUE if the overall operation finishes successfully, else FALSE.
+ *
+ * Since: 0.7.
*/
-void hinoko_fw_iso_rx_single_register_packet(HinokoFwIsoRxSingle *self, gboolean schedule_interrupt,
- GError **error)
+gboolean hinoko_fw_iso_rx_single_register_packet(HinokoFwIsoRxSingle *self,
+ gboolean schedule_interrupt, GError **error)
{
HinokoFwIsoRxSinglePrivate *priv;
- g_return_if_fail(HINOKO_IS_FW_ISO_RX_SINGLE(self));
+ g_return_val_if_fail(HINOKO_IS_FW_ISO_RX_SINGLE(self), FALSE);
priv = hinoko_fw_iso_rx_single_get_instance_private(self);
- (void)fw_iso_ctx_state_register_chunk(&priv->state, FALSE, 0, 0, NULL, 0, 0,
- schedule_interrupt, error);
+ return fw_iso_ctx_state_register_chunk(&priv->state, FALSE, 0, 0, NULL, 0, 0,
+ schedule_interrupt, error);
}
/**
@@ -328,37 +337,40 @@ void hinoko_fw_iso_rx_single_register_packet(HinokoFwIsoRxSingle *self, gboolean
*
* Start IR context.
*
- * Since: 0.6.
+ * Returns: TRUE if the overall operation finishes successfully, else FALSE.
+ *
+ * Since: 0.7.
*/
-void hinoko_fw_iso_rx_single_start(HinokoFwIsoRxSingle *self, const guint16 *cycle_match,
- guint32 sync, HinokoFwIsoCtxMatchFlag tags, GError **error)
+gboolean hinoko_fw_iso_rx_single_start(HinokoFwIsoRxSingle *self, const guint16 *cycle_match,
+ guint32 sync, HinokoFwIsoCtxMatchFlag tags, GError **error)
{
HinokoFwIsoRxSinglePrivate *priv;
- g_return_if_fail(HINOKO_IS_FW_ISO_RX_SINGLE(self));
- g_return_if_fail(error == NULL || *error == NULL);
+ g_return_val_if_fail(HINOKO_IS_FW_ISO_RX_SINGLE(self), FALSE);
+ g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
priv = hinoko_fw_iso_rx_single_get_instance_private(self);
priv->chunk_cursor = 0;
- (void)fw_iso_ctx_state_start(&priv->state, cycle_match, sync, tags, error);
+ return fw_iso_ctx_state_start(&priv->state, cycle_match, sync, tags, error);
}
/**
* hinoko_fw_iso_rx_single_get_payload:
* @self: A [class@FwIsoRxSingle].
- * @index: the index inner available packets.
+ * @index: the index inner available packets at the event of interrupt.
* @payload: (element-type guint8)(array length=length)(out)(transfer none): The array with data
* frame for payload of IR context.
* @length: The number of bytes in the above payload.
- * @error: A [struct@GLib.Error].
*
- * Retrieve payload of IR context for a handled packet corresponding to index.
+ * Retrieve payload of IR context for a handled packet corresponding to index at the event of
+ * interrupt.
+ *
+ * Since: 0.7.
*/
void hinoko_fw_iso_rx_single_get_payload(HinokoFwIsoRxSingle *self, guint index,
- const guint8 **payload, guint *length,
- GError **error)
+ const guint8 **payload, guint *length)
{
HinokoFwIsoRxSinglePrivate *priv;
unsigned int bytes_per_chunk;
@@ -369,7 +381,6 @@ void hinoko_fw_iso_rx_single_get_payload(HinokoFwIsoRxSingle *self, guint index,
guint frame_size;
g_return_if_fail(HINOKO_IS_FW_ISO_RX_SINGLE(self));
- g_return_if_fail(error == NULL || *error == NULL);
priv = hinoko_fw_iso_rx_single_get_instance_private(self);
diff --git a/src/fw_iso_rx_single.h b/src/fw_iso_rx_single.h
index f04e880..5bbd121 100644
--- a/src/fw_iso_rx_single.h
+++ b/src/fw_iso_rx_single.h
@@ -33,25 +33,21 @@ struct _HinokoFwIsoRxSingleClass {
HinokoFwIsoRxSingle *hinoko_fw_iso_rx_single_new(void);
-void hinoko_fw_iso_rx_single_allocate(HinokoFwIsoRxSingle *self,
- const char *path,
- guint channel, guint header_size,
- GError **error);
+gboolean hinoko_fw_iso_rx_single_allocate(HinokoFwIsoRxSingle *self, const char *path,
+ guint channel, guint header_size, GError **error);
-void hinoko_fw_iso_rx_single_map_buffer(HinokoFwIsoRxSingle *self,
- guint maximum_bytes_per_payload,
- guint payloads_per_buffer,
- GError **error);
+gboolean hinoko_fw_iso_rx_single_map_buffer(HinokoFwIsoRxSingle *self,
+ guint maximum_bytes_per_payload,
+ guint payloads_per_buffer, GError **error);
-void hinoko_fw_iso_rx_single_register_packet(HinokoFwIsoRxSingle *self, gboolean schedule_interrupt,
- GError **error);
+gboolean hinoko_fw_iso_rx_single_register_packet(HinokoFwIsoRxSingle *self,
+ gboolean schedule_interrupt, GError **error);
-void hinoko_fw_iso_rx_single_start(HinokoFwIsoRxSingle *self, const guint16 *cycle_match,
- guint32 sync, HinokoFwIsoCtxMatchFlag tags, GError **error);
+gboolean hinoko_fw_iso_rx_single_start(HinokoFwIsoRxSingle *self, const guint16 *cycle_match,
+ guint32 sync, HinokoFwIsoCtxMatchFlag tags, GError **error);
void hinoko_fw_iso_rx_single_get_payload(HinokoFwIsoRxSingle *self, guint index,
- const guint8 **payload, guint *length,
- GError **error);
+ const guint8 **payload, guint *length);
G_END_DECLS
diff --git a/src/hinoko.map b/src/hinoko.map
index b4241f0..bf365ec 100644
--- a/src/hinoko.map
+++ b/src/hinoko.map
@@ -5,9 +5,6 @@ HINOKO_0_1_0 {
"hinoko_fw_iso_ctx_match_flag_get_type";
"hinoko_fw_iso_rx_single_new";
- "hinoko_fw_iso_rx_single_allocate";
- "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";
@@ -56,9 +53,6 @@ HINOKO_0_6_0 {
global:
"hinoko_fw_iso_tx_register_packet";
"hinoko_fw_iso_tx_start";
-
- "hinoko_fw_iso_rx_single_register_packet";
- "hinoko_fw_iso_rx_single_start";
} HINOKO_0_5_0;
HINOKO_0_7_0 {
@@ -72,6 +66,12 @@ HINOKO_0_7_0 {
"hinoko_fw_iso_ctx_flush_completions";
"hinoko_fw_iso_rx_single_get_type";
+ "hinoko_fw_iso_rx_single_allocate";
+ "hinoko_fw_iso_rx_single_map_buffer";
+ "hinoko_fw_iso_rx_single_register_packet";
+ "hinoko_fw_iso_rx_single_start";
+ "hinoko_fw_iso_rx_single_get_payload";
+
"hinoko_fw_iso_rx_multiple_get_type";
"hinoko_fw_iso_tx_get_type";