From: Takashi Sakamoto Date: Fri, 13 Nov 2020 07:26:26 +0000 (+0900) Subject: ctl: card: report error about unsupported element operation X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=8b1fdd6c5b08de11dfd8a01dc4d66f1e22db0f03;p=alsa-gobject.git ctl: card: report error about unsupported element operation ANy operation to control element returns EPERM when the operation is not supported by the element. This commit handles the error in local error domain. Signed-off-by: Takashi Sakamoto --- diff --git a/src/ctl/alsactl-enum-types.h b/src/ctl/alsactl-enum-types.h index 65a792a..e39bdac 100644 --- a/src/ctl/alsactl-enum-types.h +++ b/src/ctl/alsactl-enum-types.h @@ -114,6 +114,7 @@ typedef enum /*< flags >*/ * @ALSACTL_CARD_ERROR_FAILED: The system call failed. * @ALSACTL_CARD_ERROR_DISCONNECTED: The card associated to the instance is in disconnect state. * @ALSACTL_CARD_ERROR_ELEM_NOT_FOUND: The control element not found in the card. + * @ALSACTL_CARD_ERROR_ELEM_NOT_SUPPORTED: The operation is not supported by the control element. * * A set of error code for GError with domain which equals to #alsactl_card_error_quark() */ @@ -121,6 +122,7 @@ typedef enum { ALSACTL_CARD_ERROR_FAILED, ALSACTL_CARD_ERROR_DISCONNECTED, ALSACTL_CARD_ERROR_ELEM_NOT_FOUND, + ALSACTL_CARD_ERROR_ELEM_NOT_SUPPORTED, } ALSACtlCardError; #endif diff --git a/src/ctl/card.c b/src/ctl/card.c index 43ea83a..e7c051b 100644 --- a/src/ctl/card.c +++ b/src/ctl/card.c @@ -42,6 +42,7 @@ G_DEFINE_QUARK(alsactl-card-error-quark, alsactl_card_error) static const char *const err_msgs[] = { [ALSACTL_CARD_ERROR_DISCONNECTED] = "The card associated to the instance is in disconnect state", [ALSACTL_CARD_ERROR_ELEM_NOT_FOUND] = "The control element not found in the card", + [ALSACTL_CARD_ERROR_ELEM_NOT_SUPPORTED] = "The operation is not supported by the control element.", }; #define generate_local_error(exception, code) \ @@ -945,6 +946,8 @@ void alsactl_card_write_elem_value(ALSACtlCard *self, generate_local_error(error, ALSACTL_CARD_ERROR_DISCONNECTED); else if (errno == ENOENT) generate_local_error(error, ALSACTL_CARD_ERROR_ELEM_NOT_FOUND); + else if (errno == EPERM) + generate_local_error(error, ALSACTL_CARD_ERROR_ELEM_NOT_SUPPORTED); else generate_syscall_error(error, errno, "ioctl(%s)", "ELEM_WRITE"); } @@ -985,6 +988,8 @@ void alsactl_card_read_elem_value(ALSACtlCard *self, generate_local_error(error, ALSACTL_CARD_ERROR_DISCONNECTED); else if (errno == ENOENT) generate_local_error(error, ALSACTL_CARD_ERROR_ELEM_NOT_FOUND); + else if (errno == EPERM) + generate_local_error(error, ALSACTL_CARD_ERROR_ELEM_NOT_SUPPORTED); else generate_syscall_error(error, errno, "ioctl(%s)", "ELEM_READ"); } diff --git a/tests/alsactl-enums b/tests/alsactl-enums index 9c8e944..80db406 100644 --- a/tests/alsactl-enums +++ b/tests/alsactl-enums @@ -55,6 +55,7 @@ card_error_types = ( 'FAILED', 'DISCONNECTED', 'ELEM_NOT_FOUND', + 'ELEM_NOT_SUPPORTED', ) types = {