]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
ctl: card: report error about unsupported element operation
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Fri, 13 Nov 2020 07:26:26 +0000 (16:26 +0900)
committer坂本 貴史 <o-takashi@sakamocchi.jp>
Fri, 13 Nov 2020 23:30:49 +0000 (08:30 +0900)
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 <o-takashi@sakamocchi.jp>
src/ctl/alsactl-enum-types.h
src/ctl/card.c
tests/alsactl-enums

index 65a792a00ad6cf56790cd2a47ff8f865ea4100f5..e39bdacfefe9d60bce1ee6140782c3fca2758722 100644 (file)
@@ -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
index 43ea83af4d5f20bcb29443245bbd127422eb251c..e7c051b24b77e2f05b1bc4bce8f0cf3ca2b50031 100644 (file)
@@ -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");
     }
index 9c8e944c3c0e822dfa24220b2165c181400f43b6..80db406ba1ea8c049e1122c4638b846271c44df4 100644 (file)
@@ -55,6 +55,7 @@ card_error_types = (
     'FAILED',
     'DISCONNECTED',
     'ELEM_NOT_FOUND',
+    'ELEM_NOT_SUPPORTED',
 )
 
 types = {