Skip to content

Commit

Permalink
tools: plugin: Simplify the command line
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ranj063 authored and lgirdwood committed Oct 28, 2024
1 parent 71cb541 commit 5dfc2d5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
13 changes: 13 additions & 0 deletions tools/plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ The command line is parsed as follows:
- "default": The second default is the device name
- "48k2c16b" is the config name for 48K, stereo, 16bit

Config name is optional in the command line. When it is not provided, hw_params will be used to
configure the endpoint. In this case, the command line can be simplified to:

```
aplay -Dsof:plugin:1:default:default
```

When using the default device, the command line can be further simplified to:

```
aplay -Dsof:plugin:1
```

This renders audio to the sof-pipe daemon using the sof-plugin topology playback PCM ID 1.
The above example needs to be 48k as example pipe has no SRC/ASRC.

Expand Down
37 changes: 19 additions & 18 deletions tools/plugin/alsaplug/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,28 +270,29 @@ static int parse_client_cmdline(snd_sof_plug_t *plug, char *cmdline, bool just_t

cmd_item = &plug->cmdline[plug->num_cmdline];
card = strtok_r(next, ":", &next);
/* card/dev names and config are all optional */
if (!card) {
SNDERR("Invalid card name\n");
return -EINVAL;
}
dev = strtok_r(next, ":", &next);
if (!dev) {
SNDERR("Invalid dev name\n");
return -EINVAL;
}
config = strtok_r(next, ":", &next);

/* tuple needs all three, any missing ? */
if (!config) {
SNDERR("invalid cmdline, expected pcm(%s):card(%s):dev(%s):config(%s) from %s",
pcm, card, dev, config, tplg);
return -EINVAL;
strncpy(cmd_item->card_name, "default", sizeof(cmd_item->card_name));
strncpy(cmd_item->dev_name, "default", sizeof(cmd_item->dev_name));
fprintf(stdout, "no config name provided, will use hw_params\n");
} else {
strncpy(cmd_item->card_name, card, sizeof(cmd_item->card_name));
dev = strtok_r(next, ":", &next);
/* dev name must be provided along with card name */
if (!dev) {
SNDERR("Invalid dev name\n");
return -EINVAL;
}
strncpy(cmd_item->dev_name, dev, sizeof(cmd_item->dev_name));
config = strtok_r(next, ":", &next);
/* config name is optional */
if (!config)
fprintf(stdout, "no config name provided, will use hw_params\n");
else
strncpy(cmd_item->config_name, config, sizeof(cmd_item->config_name));
}

cmd_item->pcm = atoi(pcm);
strncpy(cmd_item->card_name, card, sizeof(cmd_item->card_name));
strncpy(cmd_item->dev_name, dev, sizeof(cmd_item->dev_name));
strncpy(cmd_item->config_name, config, sizeof(cmd_item->config_name));

/*
* dev name is special, we cant use "," in the command line
Expand Down

0 comments on commit 5dfc2d5

Please sign in to comment.