diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2022-05-05 11:37:24 +0900 |
---|---|---|
committer | 坂本 貴史 <o-takashi@sakamocchi.jp> | 2022-05-05 16:09:50 +0900 |
commit | f8e9c6eb17a786c8ab871075ddbc5b09ddf94ef9 (patch) | |
tree | 74528b49d1a62ffdc68ebb9e03aab94772a8a148 | |
parent | 8b81fc53002805815f0872dc2f35789196b06443 (diff) | |
download | libhinoko-f8e9c6eb17a786c8ab871075ddbc5b09ddf94ef9.tar.gz |
fw_iso_resource_private: code refactoring for coded error
For my convenience.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rw-r--r-- | src/fw_iso_ctx.c | 12 | ||||
-rw-r--r-- | src/fw_iso_ctx_private.c | 13 | ||||
-rw-r--r-- | src/fw_iso_rx_multiple.c | 11 |
3 files changed, 14 insertions, 22 deletions
diff --git a/src/fw_iso_ctx.c b/src/fw_iso_ctx.c index 7eacbbf..d240bce 100644 --- a/src/fw_iso_ctx.c +++ b/src/fw_iso_ctx.c @@ -23,18 +23,6 @@ G_DEFINE_INTERFACE(HinokoFwIsoCtx, hinoko_fw_iso_ctx, G_TYPE_OBJECT) */ G_DEFINE_QUARK(hinoko-fw-iso-ctx-error-quark, hinoko_fw_iso_ctx_error) -const char *const fw_iso_ctx_err_msgs[7] = { - [HINOKO_FW_ISO_CTX_ERROR_ALLOCATED] = - "The instance is already associated to any firewire character device", - [HINOKO_FW_ISO_CTX_ERROR_NOT_ALLOCATED] = - "The instance is not associated to any firewire character device", - [HINOKO_FW_ISO_CTX_ERROR_MAPPED] = - "The intermediate buffer is already mapped to the process", - [HINOKO_FW_ISO_CTX_ERROR_NOT_MAPPED] = - "The intermediate buffer is not mapped to the process", - [HINOKO_FW_ISO_CTX_ERROR_CHUNK_UNREGISTERED] = "No chunk registered before starting", -}; - static void hinoko_fw_iso_ctx_default_init(HinokoFwIsoCtxInterface *iface) { g_object_interface_install_property(iface, diff --git a/src/fw_iso_ctx_private.c b/src/fw_iso_ctx_private.c index 0840c83..96ebb51 100644 --- a/src/fw_iso_ctx_private.c +++ b/src/fw_iso_ctx_private.c @@ -6,6 +6,19 @@ #include <fcntl.h> #include <sys/mman.h> +const char *const fw_iso_ctx_err_msgs[7] = { + [HINOKO_FW_ISO_CTX_ERROR_ALLOCATED] = + "The instance is already associated to any firewire character device", + [HINOKO_FW_ISO_CTX_ERROR_NOT_ALLOCATED] = + "The instance is not associated to any firewire character device", + [HINOKO_FW_ISO_CTX_ERROR_MAPPED] = + "The intermediate buffer is already mapped to the process", + [HINOKO_FW_ISO_CTX_ERROR_NOT_MAPPED] = + "The intermediate buffer is not mapped to the process", + [HINOKO_FW_ISO_CTX_ERROR_CHUNK_UNREGISTERED] = "No chunk registered before starting", + [HINOKO_FW_ISO_CTX_ERROR_NO_ISOC_CHANNEL] = "No isochronous channel available", +}; + typedef struct { GSource src; gpointer tag; diff --git a/src/fw_iso_rx_multiple.c b/src/fw_iso_rx_multiple.c index 91e1a4e..905396a 100644 --- a/src/fw_iso_rx_multiple.c +++ b/src/fw_iso_rx_multiple.c @@ -382,9 +382,7 @@ void hinoko_fw_iso_rx_multiple_allocate(HinokoFwIsoRxMultiple *self, hinoko_fw_iso_ctx_release(HINOKO_FW_ISO_CTX(self)); return; } else if (set.channels == 0) { - g_set_error_literal(error, HINOKO_FW_ISO_CTX_ERROR, - HINOKO_FW_ISO_CTX_ERROR_NO_ISOC_CHANNEL, - "No isochronous channel is available"); + generate_local_error(error, HINOKO_FW_ISO_CTX_ERROR_NO_ISOC_CHANNEL); hinoko_fw_iso_ctx_release(HINOKO_FW_ISO_CTX(self)); return; } @@ -419,13 +417,6 @@ void hinoko_fw_iso_rx_multiple_map_buffer(HinokoFwIsoRxMultiple *self, priv = hinoko_fw_iso_rx_multiple_get_instance_private(self); - if (priv->channels == NULL) { - g_set_error_literal(error, HINOKO_FW_ISO_CTX_ERROR, - HINOKO_FW_ISO_CTX_ERROR_NO_ISOC_CHANNEL, - "No isochronous channel is available"); - return; - } - // The size of each chunk should be aligned to quadlet. bytes_per_chunk = (bytes_per_chunk + 3) / 4; bytes_per_chunk *= 4; |