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
commit0462aff82cb5e5284e21bbdeb35d248e93956f5e (patch)
treef3d86004c37275da3398409fd9b257c0278eaae0
parent7a6eb8fd2ffc4834f792dd5fcf9f901580f77170 (diff)
downloadlibhinoko-0462aff82cb5e5284e21bbdeb35d248e93956f5e.tar.gz
fw_iso_resource: 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.FwIsoResource. This commit rewrite such public APIs with loss of backward compatibility. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rwxr-xr-xsamples/iso-resource4
-rw-r--r--src/fw_iso_resource.c28
-rw-r--r--src/fw_iso_resource.h8
3 files changed, 22 insertions, 18 deletions
diff --git a/samples/iso-resource b/samples/iso-resource
index 939f0f9..dde43fe 100755
--- a/samples/iso-resource
+++ b/samples/iso-resource
@@ -32,7 +32,7 @@ res.open('/dev/fw0', 0)
res.connect('allocated', handle_event, 'allocated')
res.connect('deallocated', handle_event, 'deallocated')
-src = res.create_source()
+_, src = res.create_source()
src.attach(ctx)
for i in range(2):
@@ -69,7 +69,7 @@ res.open('/dev/fw0', 0)
res.connect('allocated', handle_event, 'allocated')
res.connect('deallocated', handle_event, 'deallocated')
-src = res.create_source()
+_, src = res.create_source()
src.attach(ctx)
def print_props(res):
diff --git a/src/fw_iso_resource.c b/src/fw_iso_resource.c
index 0d2e2e8..2ddc631 100644
--- a/src/fw_iso_resource.c
+++ b/src/fw_iso_resource.c
@@ -92,16 +92,18 @@ static void hinoko_fw_iso_resource_default_init(HinokoFwIsoResourceInterface *if
* Open Linux FireWire character device to delegate any request for isochronous
* resource management to Linux FireWire subsystem.
*
+ * Returns: TRUE if the overall operation finished successfully, else FALSE.
+ *
* Since: 0.7.
*/
-void hinoko_fw_iso_resource_open(HinokoFwIsoResource *self, const gchar *path, gint open_flag,
- GError **error)
+gboolean hinoko_fw_iso_resource_open(HinokoFwIsoResource *self, const gchar *path, gint open_flag,
+ GError **error)
{
- g_return_if_fail(HINOKO_IS_FW_ISO_RESOURCE(self));
- g_return_if_fail(path != NULL && strlen(path) > 0);
- g_return_if_fail(error == NULL || *error == NULL);
+ g_return_val_if_fail(HINOKO_IS_FW_ISO_RESOURCE(self), FALSE);
+ g_return_val_if_fail(path != NULL && strlen(path) > 0, FALSE);
+ g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
- (void)HINOKO_FW_ISO_RESOURCE_GET_IFACE(self)->open(self, path, open_flag, error);
+ return HINOKO_FW_ISO_RESOURCE_GET_IFACE(self)->open(self, path, open_flag, error);
}
/**
@@ -113,16 +115,18 @@ void hinoko_fw_iso_resource_open(HinokoFwIsoResource *self, const gchar *path, g
* Create [struct@GLib.Source] for [struct@GLib.MainContext] to dispatch events for isochronous
* resource.
*
+ * Returns: TRUE if the overall operation finished successfully, else FALSE.
+ *
* Since: 0.7.
*/
-void hinoko_fw_iso_resource_create_source(HinokoFwIsoResource *self, GSource **source,
- GError **error)
+gboolean hinoko_fw_iso_resource_create_source(HinokoFwIsoResource *self, GSource **source,
+ GError **error)
{
- g_return_if_fail(HINOKO_IS_FW_ISO_RESOURCE(self));
- g_return_if_fail(source != NULL);
- g_return_if_fail(error == NULL || *error == NULL);
+ g_return_val_if_fail(HINOKO_IS_FW_ISO_RESOURCE(self), FALSE);
+ g_return_val_if_fail(source != NULL, FALSE);
+ g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
- (void)HINOKO_FW_ISO_RESOURCE_GET_IFACE(self)->create_source(self, source, error);
+ return HINOKO_FW_ISO_RESOURCE_GET_IFACE(self)->create_source(self, source, error);
}
/**
diff --git a/src/fw_iso_resource.h b/src/fw_iso_resource.h
index a19e8d6..9a89b24 100644
--- a/src/fw_iso_resource.h
+++ b/src/fw_iso_resource.h
@@ -53,11 +53,11 @@ struct _HinokoFwIsoResourceInterface {
guint bandwidth, const GError *error);
};
-void hinoko_fw_iso_resource_open(HinokoFwIsoResource *self, const gchar *path,
- gint open_flag, GError **error);
+gboolean hinoko_fw_iso_resource_open(HinokoFwIsoResource *self, const gchar *path, gint open_flag,
+ GError **error);
-void hinoko_fw_iso_resource_create_source(HinokoFwIsoResource *self,
- GSource **source, GError **error);
+gboolean hinoko_fw_iso_resource_create_source(HinokoFwIsoResource *self, GSource **source,
+ GError **error);
guint hinoko_fw_iso_resource_calculate_bandwidth(guint bytes_per_payload,
HinokoFwScode scode);