From 2284d80ef02da336f0753d8017ec687f7b210178 Mon Sep 17 00:00:00 2001 From: Abramo Bagnara Date: Thu, 18 May 2000 14:38:10 +0000 Subject: [PATCH] Fixed one typo and one thinko --- include/pcm.h | 3 ++- src/pcm/pcm_common.c | 1 + src/pcm/plugin/copy.c | 28 +++++++++++++++++++--------- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/include/pcm.h b/include/pcm.h index 117c7e4d..89621af3 100644 --- a/include/pcm.h +++ b/include/pcm.h @@ -342,7 +342,8 @@ int snd_pcm_plugin_build_route(snd_pcm_plugin_handle_t *handle, snd_pcm_plugin_t **r_plugin); int snd_pcm_plugin_build_copy(snd_pcm_plugin_handle_t *handle, int channel, - snd_pcm_format_t *format, + snd_pcm_format_t *src_format, + snd_pcm_format_t *dst_format, snd_pcm_plugin_t **r_plugin); #ifdef __cplusplus diff --git a/src/pcm/pcm_common.c b/src/pcm/pcm_common.c index bb2217ba..941dc243 100644 --- a/src/pcm/pcm_common.c +++ b/src/pcm/pcm_common.c @@ -790,6 +790,7 @@ int snd_pcm_plug_format(snd_pcm_plugin_handle_t *handle, tmpparams.format.interleave = dstparams.format.interleave; err = snd_pcm_plugin_build_copy(handle, params->channel, + &srcparams->format, &tmpparams.format, &plugin); pdprintf("interleave change: src=%i, dst=%i returns %i\n", srcparams->format.interleave, tmpparams.format.interleave, err); diff --git a/src/pcm/plugin/copy.c b/src/pcm/plugin/copy.c index c9850713..f7d3c77c 100644 --- a/src/pcm/plugin/copy.c +++ b/src/pcm/plugin/copy.c @@ -49,11 +49,11 @@ static ssize_t copy_transfer(snd_pcm_plugin_t *plugin, return 0; nvoices = plugin->src_format.voices; for (voice = 0; voice < nvoices; voice++) { - if (src_voices[voice].area.first % 8 != 0 || - src_voices[voice].area.step % 8 != 0) + if (src_voices->area.first % 8 != 0 || + src_voices->area.step % 8 != 0) return -EINVAL; - if (dst_voices[voice].area.first % 8 != 0 || - dst_voices[voice].area.step % 8 != 0) + if (dst_voices->area.first % 8 != 0 || + dst_voices->area.step % 8 != 0) return -EINVAL; if (!src_voices->enabled) { if (dst_voices->wanted) @@ -61,15 +61,18 @@ static ssize_t copy_transfer(snd_pcm_plugin_t *plugin, dst_voices->enabled = 0; continue; } - dst_voices[voice].enabled = 1; + dst_voices->enabled = 1; snd_pcm_area_copy(&src_voices->area, 0, &dst_voices->area, 0, samples, plugin->src_format.format); + src_voices++; + dst_voices++; } return samples; } int snd_pcm_plugin_build_copy(snd_pcm_plugin_handle_t *handle, int channel, - snd_pcm_format_t *format, + snd_pcm_format_t *src_format, + snd_pcm_format_t *dst_format, snd_pcm_plugin_t **r_plugin) { int err; @@ -80,14 +83,21 @@ int snd_pcm_plugin_build_copy(snd_pcm_plugin_handle_t *handle, return -EFAULT; *r_plugin = NULL; - width = snd_pcm_format_physical_width(format->format); + if (src_format->format != dst_format->format) + return -EINVAL; + if (src_format->rate != dst_format->rate) + return -EINVAL; + if (src_format->voices != dst_format->voices) + return -EINVAL; + + width = snd_pcm_format_physical_width(src_format->format); if (width < 0) return -EINVAL; err = snd_pcm_plugin_build(handle, channel, "copy", - format, - format, + src_format, + dst_format, 0, &plugin); if (err < 0) -- 2.47.1