From a102028a5a747ecdf1d6fcd16aef0994477a951b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 12 Sep 2012 15:09:57 +0200 Subject: [PATCH] PCM: Add the missing query_chmaps for route plugin Also fix the channel count in get_chmap for route plugin. Signed-off-by: Takashi Iwai --- src/pcm/pcm_route.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c index 3f68f328..a5c5b048 100644 --- a/src/pcm/pcm_route.c +++ b/src/pcm/pcm_route.c @@ -67,6 +67,7 @@ typedef struct { int use_getput; unsigned int src_size; snd_pcm_format_t dst_sfmt; + unsigned int nsrcs; unsigned int ndsts; snd_pcm_route_ttable_dst_t *dsts; } snd_pcm_route_params_t; @@ -707,22 +708,23 @@ static snd_pcm_chmap_t *snd_pcm_route_get_chmap(snd_pcm_t *pcm) { snd_pcm_route_t *route = pcm->private_data; snd_pcm_chmap_t *map, *slave_map; - unsigned int src, dst; + unsigned int src, dst, nsrcs; slave_map = snd_pcm_generic_get_chmap(pcm); if (!slave_map) return NULL; - map = calloc(4, route->schannels + 1); + nsrcs = route->params.nsrcs; + map = calloc(4, nsrcs + 1); if (!map) { free(slave_map); return NULL; } - map->channels = route->schannels; + map->channels = nsrcs; for (dst = 0; dst < route->params.ndsts; dst++) { snd_pcm_route_ttable_dst_t *d = &route->params.dsts[dst]; for (src = 0; src < d->nsrcs; src++) { int c = d->srcs[src].channel; - if (c < route->schannels && !map->pos[c]) + if (c < nsrcs && !map->pos[c]) map->pos[c] = slave_map->pos[dst]; } } @@ -730,6 +732,17 @@ static snd_pcm_chmap_t *snd_pcm_route_get_chmap(snd_pcm_t *pcm) return map; } +static snd_pcm_chmap_query_t **snd_pcm_route_query_chmaps(snd_pcm_t *pcm) +{ + snd_pcm_chmap_query_t **maps; + snd_pcm_chmap_t *map = snd_pcm_route_get_chmap(pcm); + if (!map) + return NULL; + maps = _snd_pcm_make_single_query_chmaps(map); + free(map); + return maps; +} + static void snd_pcm_route_dump(snd_pcm_t *pcm, snd_output_t *out) { snd_pcm_route_t *route = pcm->private_data; @@ -787,7 +800,7 @@ static const snd_pcm_ops_t snd_pcm_route_ops = { .async = snd_pcm_generic_async, .mmap = snd_pcm_generic_mmap, .munmap = snd_pcm_generic_munmap, - .query_chmaps = NULL, /* NYI */ + .query_chmaps = snd_pcm_route_query_chmaps, .get_chmap = snd_pcm_route_get_chmap, .set_chmap = NULL, /* NYI */ }; @@ -812,6 +825,7 @@ static int route_load_ttable(snd_pcm_route_params_t *params, snd_pcm_stream_t st dmul = tt_ssize; } params->ndsts = dused; + params->nsrcs = sused; dptr = calloc(dused, sizeof(*params->dsts)); if (!dptr) return -ENOMEM; -- 2.11.0