mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-10 13:30:01 -05:00
Merged pcm2 branch.
This commit is contained in:
parent
986c1500d2
commit
1cd6778173
40 changed files with 5053 additions and 3045 deletions
|
|
@ -78,7 +78,7 @@ typedef struct {
|
|||
|
||||
typedef void (*adpcm_f)(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);
|
||||
|
||||
typedef struct adpcm_private_data {
|
||||
|
|
@ -90,7 +90,7 @@ typedef struct adpcm_private_data {
|
|||
|
||||
static void adpcm_init(snd_pcm_plugin_t *plugin)
|
||||
{
|
||||
int voice;
|
||||
unsigned int voice;
|
||||
adpcm_t *data = (adpcm_t *)plugin->extra_data;
|
||||
for (voice = 0; voice < plugin->src_format.voices; voice++) {
|
||||
adpcm_voice_t *v = &data->voices[voice];
|
||||
|
|
@ -212,7 +212,7 @@ static int adpcm_decoder(unsigned char code, adpcm_voice_t * state)
|
|||
|
||||
static void adpcm_decode(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 PUT16_LABELS
|
||||
|
|
@ -229,13 +229,13 @@ static void adpcm_decode(snd_pcm_plugin_t *plugin,
|
|||
int src_step, srcbit_step, dst_step;
|
||||
size_t samples1;
|
||||
adpcm_voice_t *state;
|
||||
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;
|
||||
srcbit = src_voices[voice].first % 8;
|
||||
dst = dst_voices[voice].addr + dst_voices[voice].first / 8;
|
||||
|
|
@ -270,7 +270,7 @@ static void adpcm_decode(snd_pcm_plugin_t *plugin,
|
|||
|
||||
static void adpcm_encode(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 GET16_LABELS
|
||||
|
|
@ -288,13 +288,13 @@ static void adpcm_encode(snd_pcm_plugin_t *plugin,
|
|||
int src_step, dst_step, dstbit_step;
|
||||
size_t samples1;
|
||||
adpcm_voice_t *state;
|
||||
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;
|
||||
dstbit = dst_voices[voice].first % 8;
|
||||
|
|
@ -328,22 +328,17 @@ static void adpcm_encode(snd_pcm_plugin_t *plugin,
|
|||
|
||||
static ssize_t adpcm_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)
|
||||
{
|
||||
adpcm_t *data;
|
||||
int voice;
|
||||
unsigned int voice;
|
||||
|
||||
if (plugin == NULL || src_voices == NULL || dst_voices == NULL)
|
||||
return -EFAULT;
|
||||
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 (plugin->src_format.format == SND_PCM_SFMT_IMA_ADPCM) {
|
||||
if (src_voices[voice].first % 4 != 0 ||
|
||||
src_voices[voice].step % 4 != 0 ||
|
||||
|
|
@ -365,7 +360,7 @@ static ssize_t adpcm_transfer(snd_pcm_plugin_t *plugin,
|
|||
|
||||
static int adpcm_action(snd_pcm_plugin_t * plugin,
|
||||
snd_pcm_plugin_action_t action,
|
||||
unsigned long udata)
|
||||
unsigned long udata UNUSED)
|
||||
{
|
||||
if (plugin == NULL)
|
||||
return -EINVAL;
|
||||
|
|
@ -376,15 +371,19 @@ static int adpcm_action(snd_pcm_plugin_t * plugin,
|
|||
case FLUSH:
|
||||
adpcm_init(plugin);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0; /* silenty ignore other actions */
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_build_adpcm(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 adpcm_private_data *data;
|
||||
snd_pcm_plugin_t *plugin;
|
||||
snd_pcm_format_t *format;
|
||||
|
|
@ -412,13 +411,14 @@ int snd_pcm_plugin_build_adpcm(snd_pcm_plugin_handle_t *handle,
|
|||
if (!snd_pcm_format_linear(format->format))
|
||||
return -EINVAL;
|
||||
|
||||
plugin = snd_pcm_plugin_build(handle,
|
||||
"Ima-ADPCM<->linear conversion",
|
||||
src_format,
|
||||
dst_format,
|
||||
sizeof(adpcm_t) + src_format->voices * sizeof(adpcm_voice_t));
|
||||
if (plugin == NULL)
|
||||
return -ENOMEM;
|
||||
err = snd_pcm_plugin_build(handle, channel,
|
||||
"Ima-ADPCM<->linear conversion",
|
||||
src_format,
|
||||
dst_format,
|
||||
sizeof(adpcm_t) + src_format->voices * sizeof(adpcm_voice_t),
|
||||
&plugin);
|
||||
if (err < 0)
|
||||
return err;
|
||||
data = (adpcm_t *)plugin->extra_data;
|
||||
data->func = func;
|
||||
data->conv = getput_index(format->format);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue