Skip to content

Commit 5dfc2d5

Browse files
ranj063lgirdwood
authored andcommitted
tools: plugin: Simplify the command line
Make the card/dev names and config names optional in the command line. This will simplify the command line to just pass the PCM ID to start playback using the default device as follows: aplay -Dsof:plugin:1 Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent 71cb541 commit 5dfc2d5

2 files changed

Lines changed: 32 additions & 18 deletions

File tree

tools/plugin/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,19 @@ The command line is parsed as follows:
6060
- "default": The second default is the device name
6161
- "48k2c16b" is the config name for 48K, stereo, 16bit
6262

63+
Config name is optional in the command line. When it is not provided, hw_params will be used to
64+
configure the endpoint. In this case, the command line can be simplified to:
65+
66+
```
67+
aplay -Dsof:plugin:1:default:default
68+
```
69+
70+
When using the default device, the command line can be further simplified to:
71+
72+
```
73+
aplay -Dsof:plugin:1
74+
```
75+
6376
This renders audio to the sof-pipe daemon using the sof-plugin topology playback PCM ID 1.
6477
The above example needs to be 48k as example pipe has no SRC/ASRC.
6578

tools/plugin/alsaplug/plugin.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -270,28 +270,29 @@ static int parse_client_cmdline(snd_sof_plug_t *plug, char *cmdline, bool just_t
270270

271271
cmd_item = &plug->cmdline[plug->num_cmdline];
272272
card = strtok_r(next, ":", &next);
273+
/* card/dev names and config are all optional */
273274
if (!card) {
274-
SNDERR("Invalid card name\n");
275-
return -EINVAL;
276-
}
277-
dev = strtok_r(next, ":", &next);
278-
if (!dev) {
279-
SNDERR("Invalid dev name\n");
280-
return -EINVAL;
281-
}
282-
config = strtok_r(next, ":", &next);
283-
284-
/* tuple needs all three, any missing ? */
285-
if (!config) {
286-
SNDERR("invalid cmdline, expected pcm(%s):card(%s):dev(%s):config(%s) from %s",
287-
pcm, card, dev, config, tplg);
288-
return -EINVAL;
275+
strncpy(cmd_item->card_name, "default", sizeof(cmd_item->card_name));
276+
strncpy(cmd_item->dev_name, "default", sizeof(cmd_item->dev_name));
277+
fprintf(stdout, "no config name provided, will use hw_params\n");
278+
} else {
279+
strncpy(cmd_item->card_name, card, sizeof(cmd_item->card_name));
280+
dev = strtok_r(next, ":", &next);
281+
/* dev name must be provided along with card name */
282+
if (!dev) {
283+
SNDERR("Invalid dev name\n");
284+
return -EINVAL;
285+
}
286+
strncpy(cmd_item->dev_name, dev, sizeof(cmd_item->dev_name));
287+
config = strtok_r(next, ":", &next);
288+
/* config name is optional */
289+
if (!config)
290+
fprintf(stdout, "no config name provided, will use hw_params\n");
291+
else
292+
strncpy(cmd_item->config_name, config, sizeof(cmd_item->config_name));
289293
}
290294

291295
cmd_item->pcm = atoi(pcm);
292-
strncpy(cmd_item->card_name, card, sizeof(cmd_item->card_name));
293-
strncpy(cmd_item->dev_name, dev, sizeof(cmd_item->dev_name));
294-
strncpy(cmd_item->config_name, config, sizeof(cmd_item->config_name));
295296

296297
/*
297298
* dev name is special, we cant use "," in the command line

0 commit comments

Comments
 (0)