alsa/0018-PCM-Add-the-missing-query_chmaps-for-route-plugin.patch
Takashi Iwai 8a90d87ca6 Accepting request 138456 from home:tiwai:branches:multimedia:libs
- backport from upstream tree:
  * lots of patches to support the new chmap API
  * fix segfault in rate plugin error path
  * add a couple of test programs
  * fix inifinte loop in htimestamp of dmix & co

OBS-URL: https://build.opensuse.org/request/show/138456
OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa?expand=0&rev=113
2012-10-17 08:17:46 +00:00

86 lines
2.5 KiB
Diff

From a102028a5a747ecdf1d6fcd16aef0994477a951b Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Wed, 12 Sep 2012 15:09:57 +0200
Subject: [PATCH 18/30] 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 <tiwai@suse.de>
---
src/pcm/pcm_route.c | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
--- 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_ge
{
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_ge
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
.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_rou
dmul = tt_ssize;
}
params->ndsts = dused;
+ params->nsrcs = sused;
dptr = calloc(dused, sizeof(*params->dsts));
if (!dptr)
return -ENOMEM;