]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
ctl: card: report error due to existent control element
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)
The operation to add user-defined control elements returns EBUSY when
sound card has any control element which has the same identifier.

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 01a8c90e029a4b792ae0e52f1805f557027b024c..794bd746ec9cebb72f36cd10a319b23be8479a26 100644 (file)
@@ -116,6 +116,7 @@ typedef enum /*< flags >*/
  * @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.
  * @ALSACTL_CARD_ERROR_ELEM_OWNED:          The control element is owned by the other process.
+ * @ALSACTL_CARD_ERROR_ELEM_EXIST:          The control element already exists.
  *
  * A set of error code for GError with domain which equals to #alsactl_card_error_quark()
  */
@@ -125,6 +126,7 @@ typedef enum {
     ALSACTL_CARD_ERROR_ELEM_NOT_FOUND,
     ALSACTL_CARD_ERROR_ELEM_NOT_SUPPORTED,
     ALSACTL_CARD_ERROR_ELEM_OWNED,
+    ALSACTL_CARD_ERROR_ELEM_EXIST,
 } ALSACtlCardError;
 
 #endif
index a325800f9d9022628a785f852c73937a8ebdf2cd..183af20aec1667e653bb879029dd4b83262974dc 100644 (file)
@@ -44,6 +44,7 @@ static const char *const err_msgs[] = {
     [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.",
     [ALSACTL_CARD_ERROR_ELEM_OWNED] = "The control element is owned by the other process.",
+    [ALSACTL_CARD_ERROR_ELEM_EXIST] = "The control element already exists.",
 };
 
 #define generate_local_error(exception, code) \
@@ -809,6 +810,8 @@ static void add_or_replace_elems(int fd, const ALSACtlElemId *elem_id,
         } else if (errno == EBUSY) {
             if (replace)
                 generate_local_error(error, ALSACTL_CARD_ERROR_ELEM_OWNED);
+            else
+                generate_local_error(error, ALSACTL_CARD_ERROR_ELEM_EXIST);
         } else {
             generate_syscall_error(error, errno, "ioctl(%s)", req_name);
         }
index 7524b1e038c37d997d12f8dfe6abe483c4b99a1c..01cf41c0d57b604549248d312b4efda16c7de667 100644 (file)
@@ -57,6 +57,7 @@ card_error_types = (
     'ELEM_NOT_FOUND',
     'ELEM_NOT_SUPPORTED',
     'ELEM_OWNED',
+    'ELEM_EXIST',
 )
 
 types = {