mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-02 09:01:48 -05:00
pcm: route: Allow chmap syntax for slave channels in ttable
Instead of writing e g "0" and "1", one can now write "FL" and "FR" instead. E g: ttable.0.FL 1 ttable.1.FR 1 ttable.2.LFE 1 Signed-off-by: David Henningsson <david.henningsson@canonical.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
2da7b0c2c1
commit
8ad8d22216
1 changed files with 20 additions and 2 deletions
|
|
@ -789,6 +789,24 @@ static void snd_pcm_route_dump(snd_pcm_t *pcm, snd_output_t *out)
|
|||
snd_pcm_dump(route->plug.gen.slave, out);
|
||||
}
|
||||
|
||||
static int strtochannel(const char *id, long *channel)
|
||||
{
|
||||
int err;
|
||||
int ch;
|
||||
err = safe_strtol(id, channel);
|
||||
if (err >= 0)
|
||||
return err;
|
||||
|
||||
ch = (int) snd_pcm_chmap_from_string(id);
|
||||
if (ch == -1)
|
||||
return -EINVAL;
|
||||
|
||||
/* For now, assume standard channel mapping */
|
||||
*channel = ch - SND_CHMAP_FL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static const snd_pcm_ops_t snd_pcm_route_ops = {
|
||||
.close = snd_pcm_route_close,
|
||||
.info = snd_pcm_generic_info,
|
||||
|
|
@ -983,7 +1001,7 @@ int snd_pcm_route_determine_ttable(snd_config_t *tt,
|
|||
const char *id;
|
||||
if (snd_config_get_id(jnode, &id) < 0)
|
||||
continue;
|
||||
err = safe_strtol(id, &schannel);
|
||||
err = strtochannel(id, &schannel);
|
||||
if (err < 0) {
|
||||
SNDERR("Invalid slave channel: %s", id);
|
||||
return -EINVAL;
|
||||
|
|
@ -1046,7 +1064,7 @@ int snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_entry_t *tt
|
|||
const char *id;
|
||||
if (snd_config_get_id(jnode, &id) < 0)
|
||||
continue;
|
||||
err = safe_strtol(id, &schannel);
|
||||
err = strtochannel(id, &schannel);
|
||||
if (err < 0 ||
|
||||
schannel < 0 || (unsigned int) schannel > tt_ssize ||
|
||||
(schannels > 0 && schannel >= schannels)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue