diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2022-04-18 07:22:29 +0900 |
---|---|---|
committer | 坂本 貴史 <o-takashi@sakamocchi.jp> | 2022-04-18 07:25:16 +0900 |
commit | a4c534692e56fdedf07227fa40f1e29d6ac364cf (patch) | |
tree | b3ac3689c701995bdc0dce484d1528e0f0c8dba1 | |
parent | 7db220b07f6083f0fca6a66dc2b6f3788a36c1bc (diff) | |
download | libhinoko-a4c534692e56fdedf07227fa40f1e29d6ac364cf.tar.gz |
fw_iso_resource_auto: change public API to have timeout argument
Current implementation of Hinoko.FwIsoResourceAuto has hard-coded 100
milli second for timeout to wait for event. This is slightly inconvenient
to applications since it's not flexible at all.
This commit changes public API to have an argument for the timeout
parameter.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rwxr-xr-x | samples/iso-resource | 4 | ||||
-rw-r--r-- | src/fw_iso_resource_auto.c | 14 | ||||
-rw-r--r-- | src/fw_iso_resource_auto.h | 4 | ||||
-rw-r--r-- | src/hinoko.map | 8 |
4 files changed, 20 insertions, 10 deletions
diff --git a/samples/iso-resource b/samples/iso-resource index 885ce04..f8720a3 100755 --- a/samples/iso-resource +++ b/samples/iso-resource @@ -80,7 +80,7 @@ for i in range(2): print_props(res) try: - res.allocate_sync([use_channel], use_bandwidth) + res.allocate_sync([use_channel], use_bandwidth, 100) except GLib.Error as e: if e.matches(Hinoko.fw_iso_resource_error_quark(), Hinoko.FwIsoResourceError.EVENT): print(e) @@ -91,7 +91,7 @@ for i in range(2): sleep(1) try: - res.deallocate_sync() + res.deallocate_sync(100) except GLib.Error as e: if e.matches(Hinoko.fw_iso_resource_error_quark(), Hinoko.FwIsoResourceError.EVENT): print(e) diff --git a/src/fw_iso_resource_auto.c b/src/fw_iso_resource_auto.c index b219589..6a8a586 100644 --- a/src/fw_iso_resource_auto.c +++ b/src/fw_iso_resource_auto.c @@ -223,17 +223,20 @@ end: * numerical number for isochronous channel to be allocated. * @channel_candidates_count: The number of channel candidates. * @bandwidth: The amount of bandwidth to be allocated. + * @timeout_ms: The timeout to wait for allocated event. * @error: A [struct@GLib.Error]. Error can be generated with domain of * Hinoko.FwIsoResourceError, and Hinoko.FwIsoResourceAutoError. * * Initiate allocation of isochronous resource and wait for [signal@FwIsoResource::allocated] * signal. When the call is successful, [property@FwIsoResourceAuto:channel] and * [property@FwIsoResourceAuto:bandwidth] properties are available. + * + * Since: 0.7. */ void hinoko_fw_iso_resource_auto_allocate_sync(HinokoFwIsoResourceAuto *self, guint8 *channel_candidates, gsize channel_candidates_count, - guint bandwidth, + guint bandwidth, guint timeout_ms, GError **error) { struct fw_iso_resource_waiter w; @@ -241,7 +244,7 @@ void hinoko_fw_iso_resource_auto_allocate_sync(HinokoFwIsoResourceAuto *self, g_return_if_fail(HINOKO_IS_FW_ISO_RESOURCE_AUTO(self)); g_return_if_fail(error != NULL && *error == NULL); - fw_iso_resource_waiter_init(HINOKO_FW_ISO_RESOURCE(self), &w, "allocated", 100); + fw_iso_resource_waiter_init(HINOKO_FW_ISO_RESOURCE(self), &w, "allocated", timeout_ms); hinoko_fw_iso_resource_auto_allocate_async(self, channel_candidates, channel_candidates_count, @@ -253,13 +256,16 @@ void hinoko_fw_iso_resource_auto_allocate_sync(HinokoFwIsoResourceAuto *self, /** * hinoko_fw_iso_resource_auto_deallocate_sync: * @self: A [class@FwIsoResourceAuto] + * @timeout_ms: The timeout to wait for allocated event by milli second unit. * @error: A [struct@GLib.Error]. Error can be generated with domain of * Hinoko.FwIsoResourceError, and Hinoko.FwIsoResourceAutoError. * * Initiate deallocation of isochronous resource. When the deallocation is done, * [signal@FwIsoResource::deallocated] signal is emit to notify the result, channel, and bandwidth. + * + * Since: 0.7. */ -void hinoko_fw_iso_resource_auto_deallocate_sync(HinokoFwIsoResourceAuto *self, +void hinoko_fw_iso_resource_auto_deallocate_sync(HinokoFwIsoResourceAuto *self, guint timeout_ms, GError **error) { struct fw_iso_resource_waiter w; @@ -267,7 +273,7 @@ void hinoko_fw_iso_resource_auto_deallocate_sync(HinokoFwIsoResourceAuto *self, g_return_if_fail(HINOKO_IS_FW_ISO_RESOURCE_AUTO(self)); g_return_if_fail(error != NULL && *error == NULL); - fw_iso_resource_waiter_init(HINOKO_FW_ISO_RESOURCE(self), &w, "deallocated", 100); + fw_iso_resource_waiter_init(HINOKO_FW_ISO_RESOURCE(self), &w, "deallocated", timeout_ms); hinoko_fw_iso_resource_auto_deallocate_async(self, error); diff --git a/src/fw_iso_resource_auto.h b/src/fw_iso_resource_auto.h index 7e3856b..aa08768 100644 --- a/src/fw_iso_resource_auto.h +++ b/src/fw_iso_resource_auto.h @@ -29,12 +29,12 @@ void hinoko_fw_iso_resource_auto_allocate_async(HinokoFwIsoResourceAuto *self, void hinoko_fw_iso_resource_auto_allocate_sync(HinokoFwIsoResourceAuto *self, guint8 *channel_candidates, gsize channel_candidates_count, - guint bandwidth, + guint bandwidth, guint timeout_ms, GError **error); void hinoko_fw_iso_resource_auto_deallocate_async(HinokoFwIsoResourceAuto *self, GError **error); -void hinoko_fw_iso_resource_auto_deallocate_sync(HinokoFwIsoResourceAuto *self, +void hinoko_fw_iso_resource_auto_deallocate_sync(HinokoFwIsoResourceAuto *self, guint timeout_ms, GError **error); G_END_DECLS diff --git a/src/hinoko.map b/src/hinoko.map index d3f6fda..07768bf 100644 --- a/src/hinoko.map +++ b/src/hinoko.map @@ -64,8 +64,6 @@ HINOKO_0_4_0 { "hinoko_fw_iso_resource_auto_new"; "hinoko_fw_iso_resource_auto_allocate_async"; "hinoko_fw_iso_resource_auto_deallocate_async"; - "hinoko_fw_iso_resource_auto_allocate_sync"; - "hinoko_fw_iso_resource_auto_deallocate_sync"; } HINOKO_0_3_0; HINOKO_0_5_0 { @@ -90,3 +88,9 @@ HINOKO_0_6_0 { "hinoko_fw_iso_rx_single_register_packet"; "hinoko_fw_iso_rx_single_start"; } HINOKO_0_5_0; + +HINOKO_0_7_0 { + global: + "hinoko_fw_iso_resource_auto_allocate_sync"; + "hinoko_fw_iso_resource_auto_deallocate_sync"; +} HINOKO_0_5_0; |