Fixed one typo and one thinko

This commit is contained in:
Abramo Bagnara 2000-05-18 14:38:10 +00:00
parent 937414d534
commit 2284d80ef0
3 changed files with 22 additions and 10 deletions

View file

@ -342,7 +342,8 @@ int snd_pcm_plugin_build_route(snd_pcm_plugin_handle_t *handle,
snd_pcm_plugin_t **r_plugin); snd_pcm_plugin_t **r_plugin);
int snd_pcm_plugin_build_copy(snd_pcm_plugin_handle_t *handle, int snd_pcm_plugin_build_copy(snd_pcm_plugin_handle_t *handle,
int channel, 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); snd_pcm_plugin_t **r_plugin);
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -790,6 +790,7 @@ int snd_pcm_plug_format(snd_pcm_plugin_handle_t *handle,
tmpparams.format.interleave = dstparams.format.interleave; tmpparams.format.interleave = dstparams.format.interleave;
err = snd_pcm_plugin_build_copy(handle, err = snd_pcm_plugin_build_copy(handle,
params->channel, params->channel,
&srcparams->format,
&tmpparams.format, &tmpparams.format,
&plugin); &plugin);
pdprintf("interleave change: src=%i, dst=%i returns %i\n", srcparams->format.interleave, tmpparams.format.interleave, err); pdprintf("interleave change: src=%i, dst=%i returns %i\n", srcparams->format.interleave, tmpparams.format.interleave, err);

View file

@ -49,11 +49,11 @@ static ssize_t copy_transfer(snd_pcm_plugin_t *plugin,
return 0; return 0;
nvoices = plugin->src_format.voices; nvoices = plugin->src_format.voices;
for (voice = 0; voice < nvoices; voice++) { for (voice = 0; voice < nvoices; voice++) {
if (src_voices[voice].area.first % 8 != 0 || if (src_voices->area.first % 8 != 0 ||
src_voices[voice].area.step % 8 != 0) src_voices->area.step % 8 != 0)
return -EINVAL; return -EINVAL;
if (dst_voices[voice].area.first % 8 != 0 || if (dst_voices->area.first % 8 != 0 ||
dst_voices[voice].area.step % 8 != 0) dst_voices->area.step % 8 != 0)
return -EINVAL; return -EINVAL;
if (!src_voices->enabled) { if (!src_voices->enabled) {
if (dst_voices->wanted) if (dst_voices->wanted)
@ -61,15 +61,18 @@ static ssize_t copy_transfer(snd_pcm_plugin_t *plugin,
dst_voices->enabled = 0; dst_voices->enabled = 0;
continue; 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); snd_pcm_area_copy(&src_voices->area, 0, &dst_voices->area, 0, samples, plugin->src_format.format);
src_voices++;
dst_voices++;
} }
return samples; return samples;
} }
int snd_pcm_plugin_build_copy(snd_pcm_plugin_handle_t *handle, int snd_pcm_plugin_build_copy(snd_pcm_plugin_handle_t *handle,
int channel, 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) snd_pcm_plugin_t **r_plugin)
{ {
int err; int err;
@ -80,14 +83,21 @@ int snd_pcm_plugin_build_copy(snd_pcm_plugin_handle_t *handle,
return -EFAULT; return -EFAULT;
*r_plugin = NULL; *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) if (width < 0)
return -EINVAL; return -EINVAL;
err = snd_pcm_plugin_build(handle, channel, err = snd_pcm_plugin_build(handle, channel,
"copy", "copy",
format, src_format,
format, dst_format,
0, 0,
&plugin); &plugin);
if (err < 0) if (err < 0)