]> git.alsa-project.org Git - alsa-lib.git/commitdiff
ucm: Add command 'get _file' to get the config file name of the opened card
authorMengdong Lin <mengdong.lin@linux.intel.com>
Wed, 18 Jan 2017 03:53:42 +0000 (11:53 +0800)
committerTakashi Iwai <tiwai@suse.de>
Wed, 18 Jan 2017 10:55:25 +0000 (11:55 +0100)
After opening a card, this command can show the name of the actually
loaded configuration file, either matches the card name or card long name.
So developers can check if there is a device-sepcific configuration file
available for a given card.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/use-case.h
src/ucm/main.c

index 8911645b5c4d3cb543f0685dde8214d69f37a17d..ae22bdec4b024e733a5ec5e88d81d8c14ab2b9f7 100644 (file)
@@ -230,6 +230,7 @@ int snd_use_case_get_list(snd_use_case_mgr_t *uc_mgr,
  * Known identifiers:
  *   - NULL            - return current card
  *   - _verb           - return current verb
+ *   - _file           - return configuration file loaded for current card
  *
  *   - [=]{NAME}[/[{modifier}|{/device}][/{verb}]]
  *                      - value identifier {NAME}
index 38a5e81e90dee5df533dd818d7a00ef218c69b01..2d33886e87316d852900a4bc89b23b989744f2b7 100644 (file)
@@ -1528,6 +1528,20 @@ int snd_use_case_get(snd_use_case_mgr_t *uc_mgr,
                         goto __end;
                 }
                err = 0;
+       } else if (strcmp(identifier, "_file") == 0) {
+               /* get the conf file name of the opened card */
+               if ((uc_mgr->card_name == NULL)
+                   || (uc_mgr->conf_file_name[0] == '\0')) {
+                       err = -ENOENT;
+                       goto __end;
+               }
+               *value = strndup(uc_mgr->conf_file_name, MAX_FILE);
+               if (*value == NULL) {
+                       err = -ENOMEM;
+                       goto __end;
+               }
+               err = 0;
+
        } else if (identifier[0] == '_') {
                err = -ENOENT;
                goto __end;