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
commit6855742cbadcf1172eb8093567f8398a351368fa (patch)
treecdbb83bd09171b73dc491183b4401ad93abea525
parent7e27ea5841227910b26e9239a88b08a7338ae323 (diff)
downloadlibhinoko-6855742cbadcf1172eb8093567f8398a351368fa.tar.gz
fw_iso_ctx: rewrite public API to return gboolean
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.FwIsoCtx. This commit rewrite such public APIs with loss of backward compatibility. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rwxr-xr-xsamples/iso-rx-multiple2
-rwxr-xr-xsamples/iso-rx-single4
-rwxr-xr-xsamples/iso-tx4
-rw-r--r--src/fw_iso_ctx.c43
-rw-r--r--src/fw_iso_ctx.h9
-rw-r--r--src/fw_iso_ctx_private.c6
-rw-r--r--src/hinoko.map8
7 files changed, 44 insertions, 32 deletions
diff --git a/samples/iso-rx-multiple b/samples/iso-rx-multiple
index a9514c5..73af703 100755
--- a/samples/iso-rx-multiple
+++ b/samples/iso-rx-multiple
@@ -24,7 +24,7 @@ class IsoRxMultiple(Hinoko.FwIsoRxMultiple):
self.release()
def begin(self, dispatcher, duration):
- self.__src = self.create_source()
+ _, self.__src = self.create_source()
self.__src.attach(dispatcher.get_context())
self.__dispatcher = dispatcher
diff --git a/samples/iso-rx-single b/samples/iso-rx-single
index c37a2e7..fb9d041 100755
--- a/samples/iso-rx-single
+++ b/samples/iso-rx-single
@@ -30,7 +30,7 @@ class IsoRxSingle(Hinoko.FwIsoRxSingle):
self.register_packet(schedule_interrupt)
def begin(self, dispatcher, duration):
- self.__src = self.create_source()
+ _, self.__src = self.create_source()
self.__src.attach(dispatcher.get_context())
self.__dispatcher = dispatcher
@@ -46,7 +46,7 @@ class IsoRxSingle(Hinoko.FwIsoRxSingle):
# Start one half of second later. Scheduling is available with lower 2 bits of second field.
cycle_timer = Hinoko.CycleTimer.new()
clock_id = 4 #CLOCK_MONOTONIC_RAW
- cycle_timer = self.get_cycle_timer(clock_id, cycle_timer)
+ _, cycle_timer = self.get_cycle_timer(clock_id, cycle_timer)
(sec, cycle, tick) = cycle_timer.get_cycle_timer()
sec, cycle = self.__increment_cycle(sec, cycle, 4000)
cycle_match = (sec & 0x3, cycle)
diff --git a/samples/iso-tx b/samples/iso-tx
index cf0e906..d8f2458 100755
--- a/samples/iso-tx
+++ b/samples/iso-tx
@@ -35,7 +35,7 @@ class IsoTx(Hinoko.FwIsoTx):
self.register_packet(self.tag, self.sy, cip_header, cip_payload, schedule_interrupt)
def begin(self, dispatcher, packets_per_interrupt, duration):
- self.__src = self.create_source()
+ _, self.__src = self.create_source()
self.__src.attach(dispatcher.get_context())
self.__dispatcher = dispatcher
@@ -49,7 +49,7 @@ class IsoTx(Hinoko.FwIsoTx):
# Start 100 msec later. Scheduling is available with lower 2 bits of second field.
cycle_timer = Hinoko.CycleTimer.new()
clock_id = 4 # CLOCK_MONOTONIC_RAW
- cycle_timer = self.get_cycle_timer(clock_id, cycle_timer)
+ _, cycle_timer = self.get_cycle_timer(clock_id, cycle_timer)
(sec, cycle, tick) = cycle_timer.get_cycle_timer()
sec, cycle = self.__increment_cycle(sec, cycle, 800)
cycle_match = (sec & 0x3, cycle)
diff --git a/src/fw_iso_ctx.c b/src/fw_iso_ctx.c
index d240bce..9e04d5b 100644
--- a/src/fw_iso_ctx.c
+++ b/src/fw_iso_ctx.c
@@ -63,16 +63,19 @@ static void hinoko_fw_iso_ctx_default_init(HinokoFwIsoCtxInterface *iface)
*
* Retrieve the value of cycle timer register. This method call is available
* once any isochronous context is created.
+ *
+ * Returns: TRUE if the overall operation finishes successfully, else FALSE.
+ *
+ * Since: 0.7.
*/
-void hinoko_fw_iso_ctx_get_cycle_timer(HinokoFwIsoCtx *self, gint clock_id,
- HinokoCycleTimer *const *cycle_timer,
- GError **error)
+gboolean hinoko_fw_iso_ctx_get_cycle_timer(HinokoFwIsoCtx *self, gint clock_id,
+ HinokoCycleTimer *const *cycle_timer, GError **error)
{
- g_return_if_fail(HINOKO_IS_FW_ISO_CTX(self));
- g_return_if_fail(cycle_timer != NULL);
- g_return_if_fail(error == NULL || *error == NULL);
+ g_return_val_if_fail(HINOKO_IS_FW_ISO_CTX(self), FALSE);
+ g_return_val_if_fail(cycle_timer != NULL, FALSE);
+ g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
- HINOKO_FW_ISO_CTX_GET_IFACE(self)->get_cycle_timer(self, clock_id, cycle_timer, error);
+ return HINOKO_FW_ISO_CTX_GET_IFACE(self)->get_cycle_timer(self, clock_id, cycle_timer, error);
}
/**
@@ -83,14 +86,18 @@ void hinoko_fw_iso_ctx_get_cycle_timer(HinokoFwIsoCtx *self, gint clock_id,
*
* Create [struct@GLib.Source] for [struct@GLib.MainContext] to dispatch events for isochronous
* context.
+ *
+ * Returns: TRUE if the overall operation finishes successfully, else FALSE.
+ *
+ * Since: 0.7.
*/
-void hinoko_fw_iso_ctx_create_source(HinokoFwIsoCtx *self, GSource **source, GError **error)
+gboolean hinoko_fw_iso_ctx_create_source(HinokoFwIsoCtx *self, GSource **source, GError **error)
{
- g_return_if_fail(HINOKO_IS_FW_ISO_CTX(self));
- g_return_if_fail(source != NULL);
- g_return_if_fail(error == NULL || *error == NULL);
+ g_return_val_if_fail(HINOKO_IS_FW_ISO_CTX(self), FALSE);
+ g_return_val_if_fail(source != NULL, FALSE);
+ g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
- (void)HINOKO_FW_ISO_CTX_GET_IFACE(self)->create_source(self, source, error);
+ return HINOKO_FW_ISO_CTX_GET_IFACE(self)->create_source(self, source, error);
}
/**
@@ -149,12 +156,14 @@ void hinoko_fw_iso_ctx_release(HinokoFwIsoCtx *self)
* context to queue any type of interrupt event for the recent isochronous cycle. Application can
* process the content of isochronous packet without waiting for actual hardware interrupt.
*
- * Since: 0.6.
+ * Returns: TRUE if the overall operation finishes successfully, else FALSE.
+ *
+ * Since: 0.7.
*/
-void hinoko_fw_iso_ctx_flush_completions(HinokoFwIsoCtx *self, GError **error)
+gboolean hinoko_fw_iso_ctx_flush_completions(HinokoFwIsoCtx *self, GError **error)
{
- g_return_if_fail(HINOKO_IS_FW_ISO_CTX(self));
- g_return_if_fail(error == NULL || *error == NULL);
+ g_return_val_if_fail(HINOKO_IS_FW_ISO_CTX(self), FALSE);
+ g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
- (void)HINOKO_FW_ISO_CTX_GET_IFACE(self)->flush_completions(self, error);
+ return HINOKO_FW_ISO_CTX_GET_IFACE(self)->flush_completions(self, error);
}
diff --git a/src/fw_iso_ctx.h b/src/fw_iso_ctx.h
index dc49db9..448640a 100644
--- a/src/fw_iso_ctx.h
+++ b/src/fw_iso_ctx.h
@@ -46,13 +46,12 @@ 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);
+gboolean hinoko_fw_iso_ctx_get_cycle_timer(HinokoFwIsoCtx *self, gint clock_id,
+ HinokoCycleTimer *const *cycle_timer, GError **error);
-void hinoko_fw_iso_ctx_create_source(HinokoFwIsoCtx *self, GSource **source, GError **error);
+gboolean hinoko_fw_iso_ctx_create_source(HinokoFwIsoCtx *self, GSource **source, GError **error);
-void hinoko_fw_iso_ctx_flush_completions(HinokoFwIsoCtx *self, GError **error);
+gboolean hinoko_fw_iso_ctx_flush_completions(HinokoFwIsoCtx *self, GError **error);
G_END_DECLS
diff --git a/src/fw_iso_ctx_private.c b/src/fw_iso_ctx_private.c
index 96ebb51..5bd1473 100644
--- a/src/fw_iso_ctx_private.c
+++ b/src/fw_iso_ctx_private.c
@@ -570,6 +570,8 @@ void fw_iso_ctx_state_read_frame(struct fw_iso_ctx_state *state, guint offset, g
* Flush isochronous context until recent isochronous cycle. The call of function forces the
* context to queue any type of interrupt event for the recent isochronous cycle. Application can
* process the content of isochronous packet without waiting for actual hardware interrupt.
+ *
+ * Returns: TRUE if the overall operation finishes successfully, else FALSE.
*/
gboolean fw_iso_ctx_state_flush_completions(struct fw_iso_ctx_state *state, GError **error)
{
@@ -591,6 +593,8 @@ gboolean fw_iso_ctx_state_flush_completions(struct fw_iso_ctx_state *state, GErr
*
* Retrieve the value of cycle timer register. This method call is available
* once any isochronous context is created.
+ *
+ * Returns: TRUE if the overall operation finishes successfully, else FALSE.
*/
gboolean fw_iso_ctx_state_get_cycle_timer(struct fw_iso_ctx_state *state, gint clock_id,
HinokoCycleTimer *const *cycle_timer, GError **error)
@@ -674,6 +678,8 @@ static void finalize_src(GSource *source)
*
* Create [struct@GLib.Source] for [struct@GLib.MainContext] to dispatch events for isochronous
* context.
+ *
+ * Returns: TRUE if the overall operation finishes successfully, else FALSE.
*/
gboolean fw_iso_ctx_state_create_source(struct fw_iso_ctx_state *state, HinokoFwIsoCtx *inst,
gboolean (*handle_event)(HinokoFwIsoCtx *inst,
diff --git a/src/hinoko.map b/src/hinoko.map
index 6be5888..b4241f0 100644
--- a/src/hinoko.map
+++ b/src/hinoko.map
@@ -4,9 +4,6 @@ HINOKO_0_1_0 {
"hinoko_fw_scode_get_type";
"hinoko_fw_iso_ctx_match_flag_get_type";
- "hinoko_fw_iso_ctx_get_cycle_timer";
- "hinoko_fw_iso_ctx_create_source";
-
"hinoko_fw_iso_rx_single_new";
"hinoko_fw_iso_rx_single_allocate";
"hinoko_fw_iso_rx_single_map_buffer";
@@ -57,8 +54,6 @@ HINOKO_0_5_0 {
HINOKO_0_6_0 {
global:
- "hinoko_fw_iso_ctx_flush_completions";
-
"hinoko_fw_iso_tx_register_packet";
"hinoko_fw_iso_tx_start";
@@ -72,6 +67,9 @@ HINOKO_0_7_0 {
"hinoko_fw_iso_ctx_stop";
"hinoko_fw_iso_ctx_unmap_buffer";
"hinoko_fw_iso_ctx_release";
+ "hinoko_fw_iso_ctx_get_cycle_timer";
+ "hinoko_fw_iso_ctx_create_source";
+ "hinoko_fw_iso_ctx_flush_completions";
"hinoko_fw_iso_rx_single_get_type";
"hinoko_fw_iso_rx_multiple_get_type";