Merged pcm2 branch.

This commit is contained in:
Jaroslav Kysela 2000-05-08 18:53:38 +00:00
parent 986c1500d2
commit 1cd6778173
40 changed files with 5053 additions and 3045 deletions

View file

@ -41,19 +41,19 @@
*/
typedef struct linear_private_data {
int copy;
int conv;
} linear_t;
static void convert(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
const snd_pcm_plugin_voice_t *dst_voices,
snd_pcm_plugin_voice_t *dst_voices,
size_t samples)
{
#define COPY_LABELS
#define CONV_LABELS
#include "plugin_ops.h"
#undef COPY_LABELS
#undef CONV_LABELS
linear_t *data = (linear_t *)plugin->extra_data;
void *copy = copy_labels[data->copy];
void *conv = conv_labels[data->conv];
int voice;
int nvoices = plugin->src_format.voices;
for (voice = 0; voice < nvoices; ++voice) {
@ -61,23 +61,23 @@ static void convert(snd_pcm_plugin_t *plugin,
char *dst;
int src_step, dst_step;
size_t samples1;
if (src_voices[voice].addr == NULL) {
if (dst_voices[voice].addr != NULL) {
// null_voice(&dst_voices[voice]);
zero_voice(plugin, &dst_voices[voice], samples);
}
if (!src_voices[voice].enabled) {
if (dst_voices[voice].wanted)
snd_pcm_plugin_silence_voice(plugin, &dst_voices[voice], samples);
dst_voices[voice].enabled = 0;
continue;
}
dst_voices[voice].enabled = 1;
src = src_voices[voice].addr + src_voices[voice].first / 8;
dst = dst_voices[voice].addr + dst_voices[voice].first / 8;
src_step = src_voices[voice].step / 8;
dst_step = dst_voices[voice].step / 8;
samples1 = samples;
while (samples1-- > 0) {
goto *copy;
#define COPY_END after
goto *conv;
#define CONV_END after
#include "plugin_ops.h"
#undef COPY_END
#undef CONV_END
after:
src += src_step;
dst += dst_step;
@ -87,23 +87,18 @@ static void convert(snd_pcm_plugin_t *plugin,
static ssize_t linear_transfer(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
const snd_pcm_plugin_voice_t *dst_voices,
snd_pcm_plugin_voice_t *dst_voices,
size_t samples)
{
linear_t *data;
int voice;
unsigned int voice;
if (plugin == NULL || src_voices == NULL || dst_voices == NULL)
return -EFAULT;
data = (linear_t *)plugin->extra_data;
if (samples < 0)
return -EINVAL;
if (samples == 0)
return 0;
for (voice = 0; voice < plugin->src_format.voices; voice++) {
if (src_voices[voice].addr != NULL &&
dst_voices[voice].addr == NULL)
return -EFAULT;
if (src_voices[voice].first % 8 != 0 ||
src_voices[voice].step % 8 != 0)
return -EINVAL;
@ -115,7 +110,7 @@ static ssize_t linear_transfer(snd_pcm_plugin_t *plugin,
return samples;
}
int copy_index(int src_format, int dst_format)
int conv_index(int src_format, int dst_format)
{
int src_endian, dst_endian, sign, src_width, dst_width;
@ -143,10 +138,12 @@ int copy_index(int src_format, int dst_format)
}
int snd_pcm_plugin_build_linear(snd_pcm_plugin_handle_t *handle,
int channel,
snd_pcm_format_t *src_format,
snd_pcm_format_t *dst_format,
snd_pcm_plugin_t **r_plugin)
{
int err;
struct linear_private_data *data;
snd_pcm_plugin_t *plugin;
@ -162,15 +159,16 @@ int snd_pcm_plugin_build_linear(snd_pcm_plugin_handle_t *handle,
snd_pcm_format_linear(dst_format->format)))
return -EINVAL;
plugin = snd_pcm_plugin_build(handle,
"linear format conversion",
src_format,
dst_format,
sizeof(linear_t));
if (plugin == NULL)
return -ENOMEM;
err = snd_pcm_plugin_build(handle, channel,
"linear format conversion",
src_format,
dst_format,
sizeof(linear_t),
&plugin);
if (err < 0)
return err;
data = (linear_t *)plugin->extra_data;
data->copy = copy_index(src_format->format, dst_format->format);
data->conv = conv_index(src_format->format, dst_format->format);
plugin->transfer = linear_transfer;
*r_plugin = plugin;
return 0;