mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-31 22:25:35 -04:00
Fixed bug: added limit for source channels.
This commit is contained in:
parent
e09736109e
commit
47ba6cef55
1 changed files with 39 additions and 11 deletions
|
|
@ -74,6 +74,7 @@ typedef void (*route_f)(const snd_pcm_channel_area_t *dst_area,
|
||||||
snd_pcm_uframes_t dst_offset,
|
snd_pcm_uframes_t dst_offset,
|
||||||
const snd_pcm_channel_area_t *src_areas,
|
const snd_pcm_channel_area_t *src_areas,
|
||||||
snd_pcm_uframes_t src_offset,
|
snd_pcm_uframes_t src_offset,
|
||||||
|
unsigned int src_channels,
|
||||||
snd_pcm_uframes_t frames,
|
snd_pcm_uframes_t frames,
|
||||||
const snd_pcm_route_ttable_dst_t *ttable,
|
const snd_pcm_route_ttable_dst_t *ttable,
|
||||||
const snd_pcm_route_params_t *params);
|
const snd_pcm_route_params_t *params);
|
||||||
|
|
@ -107,6 +108,7 @@ static void snd_pcm_route_convert1_zero(const snd_pcm_channel_area_t *dst_area,
|
||||||
snd_pcm_uframes_t dst_offset,
|
snd_pcm_uframes_t dst_offset,
|
||||||
const snd_pcm_channel_area_t *src_areas ATTRIBUTE_UNUSED,
|
const snd_pcm_channel_area_t *src_areas ATTRIBUTE_UNUSED,
|
||||||
snd_pcm_uframes_t src_offset ATTRIBUTE_UNUSED,
|
snd_pcm_uframes_t src_offset ATTRIBUTE_UNUSED,
|
||||||
|
unsigned int src_channels ATTRIBUTE_UNUSED,
|
||||||
snd_pcm_uframes_t frames,
|
snd_pcm_uframes_t frames,
|
||||||
const snd_pcm_route_ttable_dst_t* ttable ATTRIBUTE_UNUSED,
|
const snd_pcm_route_ttable_dst_t* ttable ATTRIBUTE_UNUSED,
|
||||||
const snd_pcm_route_params_t *params)
|
const snd_pcm_route_params_t *params)
|
||||||
|
|
@ -120,6 +122,7 @@ static void snd_pcm_route_convert1_one(const snd_pcm_channel_area_t *dst_area,
|
||||||
snd_pcm_uframes_t dst_offset,
|
snd_pcm_uframes_t dst_offset,
|
||||||
const snd_pcm_channel_area_t *src_areas,
|
const snd_pcm_channel_area_t *src_areas,
|
||||||
snd_pcm_uframes_t src_offset,
|
snd_pcm_uframes_t src_offset,
|
||||||
|
unsigned int src_channels,
|
||||||
snd_pcm_uframes_t frames,
|
snd_pcm_uframes_t frames,
|
||||||
const snd_pcm_route_ttable_dst_t* ttable,
|
const snd_pcm_route_ttable_dst_t* ttable,
|
||||||
const snd_pcm_route_params_t *params)
|
const snd_pcm_route_params_t *params)
|
||||||
|
|
@ -133,14 +136,18 @@ static void snd_pcm_route_convert1_one(const snd_pcm_channel_area_t *dst_area,
|
||||||
const char *src;
|
const char *src;
|
||||||
char *dst;
|
char *dst;
|
||||||
int src_step, dst_step;
|
int src_step, dst_step;
|
||||||
for (srcidx = 0; srcidx < ttable->nsrcs; ++srcidx) {
|
for (srcidx = 0; srcidx < ttable->nsrcs && srcidx < src_channels; ++srcidx) {
|
||||||
src_area = &src_areas[ttable->srcs[srcidx].channel];
|
unsigned int channel = ttable->srcs[srcidx].channel;
|
||||||
|
if (channel >= src_channels)
|
||||||
|
continue;
|
||||||
|
src_area = &src_areas[channel];
|
||||||
if (src_area->addr != NULL)
|
if (src_area->addr != NULL)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (srcidx == ttable->nsrcs) {
|
if (srcidx == ttable->nsrcs || srcidx == src_channels) {
|
||||||
snd_pcm_route_convert1_zero(dst_area, dst_offset,
|
snd_pcm_route_convert1_zero(dst_area, dst_offset,
|
||||||
src_areas, src_offset,
|
src_areas, src_offset,
|
||||||
|
src_channels,
|
||||||
frames, ttable, params);
|
frames, ttable, params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -165,6 +172,7 @@ static void snd_pcm_route_convert1_one_getput(const snd_pcm_channel_area_t *dst_
|
||||||
snd_pcm_uframes_t dst_offset,
|
snd_pcm_uframes_t dst_offset,
|
||||||
const snd_pcm_channel_area_t *src_areas,
|
const snd_pcm_channel_area_t *src_areas,
|
||||||
snd_pcm_uframes_t src_offset,
|
snd_pcm_uframes_t src_offset,
|
||||||
|
unsigned int src_channels,
|
||||||
snd_pcm_uframes_t frames,
|
snd_pcm_uframes_t frames,
|
||||||
const snd_pcm_route_ttable_dst_t* ttable,
|
const snd_pcm_route_ttable_dst_t* ttable,
|
||||||
const snd_pcm_route_params_t *params)
|
const snd_pcm_route_params_t *params)
|
||||||
|
|
@ -179,14 +187,18 @@ static void snd_pcm_route_convert1_one_getput(const snd_pcm_channel_area_t *dst_
|
||||||
char *dst;
|
char *dst;
|
||||||
int src_step, dst_step;
|
int src_step, dst_step;
|
||||||
u_int32_t sample = 0;
|
u_int32_t sample = 0;
|
||||||
for (srcidx = 0; srcidx < ttable->nsrcs; ++srcidx) {
|
for (srcidx = 0; srcidx < ttable->nsrcs && srcidx < src_channels; ++srcidx) {
|
||||||
src_area = &src_areas[ttable->srcs[srcidx].channel];
|
unsigned int channel = ttable->srcs[srcidx].channel;
|
||||||
|
if (channel >= src_channels)
|
||||||
|
continue;
|
||||||
|
src_area = &src_areas[channel];
|
||||||
if (src_area->addr != NULL)
|
if (src_area->addr != NULL)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (srcidx == ttable->nsrcs) {
|
if (srcidx == ttable->nsrcs || srcidx == src_channels) {
|
||||||
snd_pcm_route_convert1_zero(dst_area, dst_offset,
|
snd_pcm_route_convert1_zero(dst_area, dst_offset,
|
||||||
src_areas, src_offset,
|
src_areas, src_offset,
|
||||||
|
src_channels,
|
||||||
frames, ttable, params);
|
frames, ttable, params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -212,6 +224,7 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area,
|
||||||
snd_pcm_uframes_t dst_offset,
|
snd_pcm_uframes_t dst_offset,
|
||||||
const snd_pcm_channel_area_t *src_areas,
|
const snd_pcm_channel_area_t *src_areas,
|
||||||
snd_pcm_uframes_t src_offset,
|
snd_pcm_uframes_t src_offset,
|
||||||
|
unsigned int src_channels,
|
||||||
snd_pcm_uframes_t frames,
|
snd_pcm_uframes_t frames,
|
||||||
const snd_pcm_route_ttable_dst_t* ttable,
|
const snd_pcm_route_ttable_dst_t* ttable,
|
||||||
const snd_pcm_route_params_t *params)
|
const snd_pcm_route_params_t *params)
|
||||||
|
|
@ -273,8 +286,12 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area,
|
||||||
snd_pcm_route_ttable_src_t src_tt[nsrcs];
|
snd_pcm_route_ttable_src_t src_tt[nsrcs];
|
||||||
int32_t sample = 0;
|
int32_t sample = 0;
|
||||||
int srcidx, srcidx1 = 0;
|
int srcidx, srcidx1 = 0;
|
||||||
for (srcidx = 0; srcidx < nsrcs; ++srcidx) {
|
for (srcidx = 0; srcidx < nsrcs && (unsigned)srcidx < src_channels; ++srcidx) {
|
||||||
const snd_pcm_channel_area_t *src_area = &src_areas[ttable->srcs[srcidx].channel];
|
const snd_pcm_channel_area_t *src_area;
|
||||||
|
unsigned int channel = ttable->srcs[srcidx].channel;
|
||||||
|
if (channel >= src_channels)
|
||||||
|
continue;
|
||||||
|
src_area = &src_areas[channel];
|
||||||
srcs[srcidx1] = snd_pcm_channel_area_addr(src_area, src_offset);
|
srcs[srcidx1] = snd_pcm_channel_area_addr(src_area, src_offset);
|
||||||
src_steps[srcidx1] = snd_pcm_channel_area_step(src_area);
|
src_steps[srcidx1] = snd_pcm_channel_area_step(src_area);
|
||||||
src_tt[srcidx1] = ttable->srcs[srcidx];
|
src_tt[srcidx1] = ttable->srcs[srcidx];
|
||||||
|
|
@ -284,16 +301,19 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area,
|
||||||
if (nsrcs == 0) {
|
if (nsrcs == 0) {
|
||||||
snd_pcm_route_convert1_zero(dst_area, dst_offset,
|
snd_pcm_route_convert1_zero(dst_area, dst_offset,
|
||||||
src_areas, src_offset,
|
src_areas, src_offset,
|
||||||
|
src_channels,
|
||||||
frames, ttable, params);
|
frames, ttable, params);
|
||||||
return;
|
return;
|
||||||
} else if (nsrcs == 1 && src_tt[0].as_int == SND_PCM_PLUGIN_ROUTE_RESOLUTION) {
|
} else if (nsrcs == 1 && src_tt[0].as_int == SND_PCM_PLUGIN_ROUTE_RESOLUTION) {
|
||||||
if (params->use_getput)
|
if (params->use_getput)
|
||||||
snd_pcm_route_convert1_one_getput(dst_area, dst_offset,
|
snd_pcm_route_convert1_one_getput(dst_area, dst_offset,
|
||||||
src_areas, src_offset,
|
src_areas, src_offset,
|
||||||
|
src_channels,
|
||||||
frames, ttable, params);
|
frames, ttable, params);
|
||||||
else
|
else
|
||||||
snd_pcm_route_convert1_one(dst_area, dst_offset,
|
snd_pcm_route_convert1_one(dst_area, dst_offset,
|
||||||
src_areas, src_offset,
|
src_areas, src_offset,
|
||||||
|
src_channels,
|
||||||
frames, ttable, params);
|
frames, ttable, params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -456,7 +476,8 @@ static void snd_pcm_route_convert(const snd_pcm_channel_area_t *dst_areas,
|
||||||
snd_pcm_uframes_t dst_offset,
|
snd_pcm_uframes_t dst_offset,
|
||||||
const snd_pcm_channel_area_t *src_areas,
|
const snd_pcm_channel_area_t *src_areas,
|
||||||
snd_pcm_uframes_t src_offset,
|
snd_pcm_uframes_t src_offset,
|
||||||
snd_pcm_uframes_t dst_channels,
|
unsigned int src_channels,
|
||||||
|
unsigned int dst_channels,
|
||||||
snd_pcm_uframes_t frames,
|
snd_pcm_uframes_t frames,
|
||||||
snd_pcm_route_params_t *params)
|
snd_pcm_route_params_t *params)
|
||||||
{
|
{
|
||||||
|
|
@ -470,10 +491,12 @@ static void snd_pcm_route_convert(const snd_pcm_channel_area_t *dst_areas,
|
||||||
if (dst_channel >= params->ndsts)
|
if (dst_channel >= params->ndsts)
|
||||||
snd_pcm_route_convert1_zero(dst_area, dst_offset,
|
snd_pcm_route_convert1_zero(dst_area, dst_offset,
|
||||||
src_areas, src_offset,
|
src_areas, src_offset,
|
||||||
|
src_channels,
|
||||||
frames, dstp, params);
|
frames, dstp, params);
|
||||||
else
|
else
|
||||||
dstp->func(dst_area, dst_offset,
|
dstp->func(dst_area, dst_offset,
|
||||||
src_areas, src_offset,
|
src_areas, src_offset,
|
||||||
|
src_channels,
|
||||||
frames, dstp, params);
|
frames, dstp, params);
|
||||||
dstp++;
|
dstp++;
|
||||||
dst_area++;
|
dst_area++;
|
||||||
|
|
@ -653,7 +676,9 @@ snd_pcm_route_write_areas(snd_pcm_t *pcm,
|
||||||
size = *slave_sizep;
|
size = *slave_sizep;
|
||||||
snd_pcm_route_convert(slave_areas, slave_offset,
|
snd_pcm_route_convert(slave_areas, slave_offset,
|
||||||
areas, offset,
|
areas, offset,
|
||||||
slave->channels, size, &route->params);
|
pcm->channels,
|
||||||
|
slave->channels,
|
||||||
|
size, &route->params);
|
||||||
*slave_sizep = size;
|
*slave_sizep = size;
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
@ -668,11 +693,14 @@ snd_pcm_route_read_areas(snd_pcm_t *pcm,
|
||||||
snd_pcm_uframes_t *slave_sizep)
|
snd_pcm_uframes_t *slave_sizep)
|
||||||
{
|
{
|
||||||
snd_pcm_route_t *route = pcm->private_data;
|
snd_pcm_route_t *route = pcm->private_data;
|
||||||
|
snd_pcm_t *slave = route->plug.slave;
|
||||||
if (size > *slave_sizep)
|
if (size > *slave_sizep)
|
||||||
size = *slave_sizep;
|
size = *slave_sizep;
|
||||||
snd_pcm_route_convert(areas, offset,
|
snd_pcm_route_convert(areas, offset,
|
||||||
slave_areas, slave_offset,
|
slave_areas, slave_offset,
|
||||||
pcm->channels, size, &route->params);
|
slave->channels,
|
||||||
|
pcm->channels,
|
||||||
|
size, &route->params);
|
||||||
*slave_sizep = size;
|
*slave_sizep = size;
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue