int snd_pcm_plugin_params(snd_pcm_t *pcm, snd_pcm_channel_params_t *params)
{
- snd_pcm_channel_params_t hwparams;
+ snd_pcm_channel_params_t hwparams, newparams;
snd_pcm_channel_info_t hwinfo;
snd_pcm_plugin_t *plugin;
int err;
snd_pcm_plugin_clear(pcm, params->channel);
/* add necessary plugins */
- if ((err = snd_pcm_plugin_format(pcm, params, &hwparams, &hwinfo)) < 0)
+ if ((err = snd_pcm_plugin_format(pcm, params, &hwparams, &hwinfo, &newparams)) < 0)
return err;
/*
/* compute right sizes */
if (params->mode == SND_PCM_MODE_STREAM) {
- pdprintf("params queue_size = %i\n", hwparams.buf.stream.queue_size);
- hwparams.buf.stream.queue_size = snd_pcm_plugin_hardware_size(pcm, hwparams.channel, hwparams.buf.stream.queue_size);
- hwparams.buf.stream.max_fill = snd_pcm_plugin_hardware_size(pcm, hwparams.channel, hwparams.buf.stream.max_fill);
- pdprintf("params queue_size = %i\n", hwparams.buf.stream.queue_size);
+ pdprintf("params queue_size = %i\n", newparams.buf.stream.queue_size);
+ newparams.buf.stream.queue_size = snd_pcm_plugin_hardware_size(pcm, newparams.channel, newparams.buf.stream.queue_size);
+ newparams.buf.stream.max_fill = snd_pcm_plugin_hardware_size(pcm, newparams.channel, newparams.buf.stream.max_fill);
+ pdprintf("params queue_size = %i\n", newparams.buf.stream.queue_size);
} else if (params->mode == SND_PCM_MODE_BLOCK) {
- pdprintf("params frag_size = %i\n", hwparams.buf.block.frag_size);
- hwparams.buf.block.frag_size = snd_pcm_plugin_hardware_size(pcm, hwparams.channel, hwparams.buf.block.frag_size);
- pdprintf("params frag_size = %i\n", hwparams.buf.block.frag_size);
+ pdprintf("params frag_size = %i\n", newparams.buf.block.frag_size);
+ newparams.buf.block.frag_size = snd_pcm_plugin_hardware_size(pcm, newparams.channel, newparams.buf.block.frag_size);
+ pdprintf("params frag_size = %i\n", newparams.buf.block.frag_size);
} else {
return -EINVAL;
}
- pdprintf("params requested params: format = %i, rate = %i, voices = %i\n", hwparams.format.format, hwparams.format.rate, hwparams.format.voices);
- err = snd_pcm_channel_params(pcm, &hwparams);
+ pdprintf("params requested params: format = %i, rate = %i, voices = %i\n", newparams.format.format, newparams.format.rate, newparams.format.voices);
+ err = snd_pcm_channel_params(pcm, &newparams);
if (err < 0)
return err;
- err = snd_pcm_plugin_action(pcm, hwparams.channel, INIT);
+ err = snd_pcm_plugin_action(pcm, newparams.channel, INIT);
if (err < 0)
return err;
return 0;
unsigned int snd_pcm_plugin_formats(unsigned int formats)
{
- formats |= SND_PCM_FMT_MU_LAW | SND_PCM_FMT_A_LAW | SND_PCM_FMT_IMA_ADPCM;
+ formats |= SND_PCM_FMT_MU_LAW;
+#ifndef __KERNEL__
+ formats |= SND_PCM_FMT_A_LAW | SND_PCM_FMT_IMA_ADPCM;
+#endif
if (formats & (SND_PCM_FMT_U8|SND_PCM_FMT_S8|
SND_PCM_FMT_U16_LE|SND_PCM_FMT_S16_LE))
formats |= SND_PCM_FMT_U8|SND_PCM_FMT_S8|
int snd_pcm_plugin_format(PLUGIN_BASE *pb,
snd_pcm_channel_params_t *params,
snd_pcm_channel_params_t *hwparams,
- snd_pcm_channel_info_t *hwinfo)
+ snd_pcm_channel_info_t *hwinfo,
+ snd_pcm_channel_params_t *newparams)
{
- snd_pcm_channel_params_t srcparams, tmpparams;
+ snd_pcm_channel_params_t tmpparams;
snd_pcm_channel_params_t *dstparams;
snd_pcm_plugin_t *plugin;
int err;
if (params->channel == SND_PCM_CHANNEL_PLAYBACK) {
- memcpy(&srcparams, params, sizeof(srcparams));
- memcpy(&tmpparams, params, sizeof(tmpparams));
+ memcpy(newparams, params, sizeof(*params));
+ memcpy(&tmpparams, params, sizeof(*params));
dstparams = hwparams;
} else {
- memcpy(&srcparams, &hwparams, sizeof(srcparams));
- memcpy(&tmpparams, &hwparams, sizeof(tmpparams));
+ memcpy(newparams, hwparams, sizeof(*hwparams));
+ memcpy(&tmpparams, hwparams, sizeof(*hwparams));
dstparams = params;
}
- pdprintf("srcparams: interleave=%i, format=%i, rate=%i, voices=%i\n",
- srcparams.format.interleave,
- srcparams.format.format,
- srcparams.format.rate,
- srcparams.format.voices);
+ pdprintf("newparams: interleave=%i, format=%i, rate=%i, voices=%i\n",
+ newparams->format.interleave,
+ newparams->format.format,
+ newparams->format.rate,
+ newparams->format.voices);
pdprintf("dstparams: interleave=%i, format=%i, rate=%i, voices=%i\n",
dstparams->format.interleave,
dstparams->format.format,
dstparams->format.rate,
dstparams->format.voices);
/* Convert to interleaved format if needed */
- if (!srcparams.format.interleave &&
- (srcparams.format.voices != dstparams->format.voices ||
- (srcparams.format.rate != dstparams->format.rate &&
- srcparams.format.voices > 1))) {
+ if (!newparams->format.interleave &&
+ (newparams->format.voices != dstparams->format.voices ||
+ (newparams->format.rate != dstparams->format.rate &&
+ newparams->format.voices > 1))) {
tmpparams.format.interleave = 1;
- err = snd_pcm_plugin_build_interleave(&srcparams.format,
+ err = snd_pcm_plugin_build_interleave(&newparams->format,
&tmpparams.format,
&plugin);
- pdprintf("params interleave change: src=%i, dst=%i returns %i\n", srcparams.format.interleave, tmpparams.format.interleave, err);
+ pdprintf("params interleave change: src=%i, dst=%i returns %i\n", newparams->format.interleave, tmpparams.format.interleave, err);
if (err < 0) {
snd_pcm_plugin_free(plugin);
return err;
snd_pcm_plugin_free(plugin);
return err;
}
- srcparams.format.interleave = 1;
+ newparams->format.interleave = 1;
/* Avoid useless interleave revert */
if (params->channel == SND_PCM_CHANNEL_PLAYBACK &&
(hwinfo->flags & SND_PCM_CHNINFO_INTERLEAVE))
}
/* voices reduction */
- if (srcparams.format.voices > dstparams->format.voices) {
+ if (newparams->format.voices > dstparams->format.voices) {
tmpparams.format.voices = dstparams->format.voices;
- err = snd_pcm_plugin_build_voices(&srcparams.format,
+ err = snd_pcm_plugin_build_voices(&newparams->format,
&tmpparams.format,
&plugin);
- pdprintf("params voices reduction: src=%i, dst=%i returns %i\n", srcparams.format.voices, tmpparams.format.voices, err);
+ pdprintf("params voices reduction: src=%i, dst=%i returns %i\n", newparams->format.voices, tmpparams.format.voices, err);
if (err < 0) {
snd_pcm_plugin_free(plugin);
return err;
snd_pcm_plugin_free(plugin);
return err;
}
- srcparams.format.voices = dstparams->format.voices;
+ newparams->format.voices = dstparams->format.voices;
}
/* rate down resampling */
- if (srcparams.format.rate > dstparams->format.rate &&
- snd_pcm_format_linear(srcparams.format.format) &&
- snd_pcm_format_width(srcparams.format.format) <= 16 &&
- snd_pcm_format_width(srcparams.format.format) >= snd_pcm_format_width(srcparams.format.format)) {
+ if (newparams->format.rate > dstparams->format.rate &&
+ snd_pcm_format_linear(newparams->format.format) &&
+ snd_pcm_format_width(newparams->format.format) <= 16 &&
+ snd_pcm_format_width(newparams->format.format) >= snd_pcm_format_width(newparams->format.format)) {
tmpparams.format.rate = dstparams->format.rate;
- err = snd_pcm_plugin_build_rate(&srcparams.format,
+ err = snd_pcm_plugin_build_rate(&newparams->format,
&tmpparams.format,
&plugin);
- pdprintf("params rate down resampling: src=%i, dst=%i\n returns %i", srcparams.format.rate, tmpparams.format.rate, err);
+ pdprintf("params rate down resampling: src=%i, dst=%i returns %i\n", newparams->format.rate, tmpparams.format.rate, err);
if (err < 0) {
snd_pcm_plugin_free(plugin);
return err;
snd_pcm_plugin_free(plugin);
return err;
}
- srcparams.format.rate = dstparams->format.rate;
+ newparams->format.rate = dstparams->format.rate;
}
/* format change */
- if (srcparams.format.format != dstparams->format.format) {
+ if (newparams->format.format != dstparams->format.format) {
tmpparams.format.format = dstparams->format.format;
- switch (srcparams.format.format) {
+ switch (newparams->format.format) {
case SND_PCM_SFMT_MU_LAW:
- err = snd_pcm_plugin_build_mulaw(&srcparams.format,
+ err = snd_pcm_plugin_build_mulaw(&newparams->format,
&tmpparams.format,
&plugin);
break;
#ifndef __KERNEL__
case SND_PCM_SFMT_A_LAW:
- err = snd_pcm_plugin_build_alaw(&srcparams.format,
+ err = snd_pcm_plugin_build_alaw(&newparams->format,
&tmpparams.format,
&plugin);
break;
case SND_PCM_SFMT_IMA_ADPCM:
- err = snd_pcm_plugin_build_adpcm(&srcparams.format,
+ err = snd_pcm_plugin_build_adpcm(&newparams->format,
&tmpparams.format,
&plugin);
break;
#endif
default:
- err = snd_pcm_plugin_build_linear(&srcparams.format,
+ err = snd_pcm_plugin_build_linear(&newparams->format,
&tmpparams.format,
&plugin);
}
- pdprintf("params format change: src=%i, dst=%i returns %i\n", srcparams.format.format, tmpparams.format.format, err);
+ pdprintf("params format change: src=%i, dst=%i returns %i\n", newparams->format.format, tmpparams.format.format, err);
if (err < 0)
return err;
err = snd_pcm_plugin_append(pb, params->channel, plugin);
snd_pcm_plugin_free(plugin);
return err;
}
- srcparams.format.format = dstparams->format.format;
+ newparams->format.format = dstparams->format.format;
}
/* rate resampling */
- if (srcparams.format.rate != dstparams->format.rate) {
+ if (newparams->format.rate != dstparams->format.rate) {
tmpparams.format.rate = dstparams->format.rate;
- err = snd_pcm_plugin_build_rate(&srcparams.format,
+ err = snd_pcm_plugin_build_rate(&newparams->format,
&tmpparams.format,
&plugin);
- pdprintf("params rate resampling: src=%i, dst=%i return %i\n", srcparams.format.rate, tmpparams.format.rate, err);
+ pdprintf("params rate resampling: src=%i, dst=%i return %i\n", newparams->format.rate, tmpparams.format.rate, err);
if (err < 0) {
snd_pcm_plugin_free(plugin);
return err;
snd_pcm_plugin_free(plugin);
return err;
}
- srcparams.format.rate = dstparams->format.rate;
+ newparams->format.rate = dstparams->format.rate;
}
/* voices extension */
- if (srcparams.format.voices != dstparams->format.voices) {
+ if (newparams->format.voices != dstparams->format.voices) {
tmpparams.format.voices = dstparams->format.voices;
- err = snd_pcm_plugin_build_voices(&srcparams.format,
+ err = snd_pcm_plugin_build_voices(&newparams->format,
&tmpparams.format,
&plugin);
- pdprintf("params voices extension: src=%i, dst=%i returns %i\n", srcparams.format.voices, tmpparams.format.voices, err);
+ pdprintf("params voices extension: src=%i, dst=%i returns %i\n", newparams->format.voices, tmpparams.format.voices, err);
if (err < 0) {
snd_pcm_plugin_free(plugin);
return err;
snd_pcm_plugin_free(plugin);
return err;
}
- srcparams.format.voices = dstparams->format.voices;
+ newparams->format.voices = dstparams->format.voices;
}
/* interleave change */
if (dstparams->format.voices > 1 &&
hwinfo->mode == SND_PCM_MODE_BLOCK &&
- srcparams.format.interleave != dstparams->format.interleave) {
+ newparams->format.interleave != dstparams->format.interleave) {
tmpparams.format.interleave = dstparams->format.interleave;
- err = snd_pcm_plugin_build_interleave(&srcparams.format,
+ err = snd_pcm_plugin_build_interleave(&newparams->format,
&tmpparams.format,
&plugin);
- pdprintf("params interleave change: src=%i, dst=%i return %i\n", srcparams.format.interleave, tmpparams.format.interleave, err);
+ pdprintf("params interleave change: src=%i, dst=%i return %i\n", newparams->format.interleave, tmpparams.format.interleave, err);
if (err < 0) {
snd_pcm_plugin_free(plugin);
return err;
snd_pcm_plugin_free(plugin);
return err;
}
- srcparams.format.interleave = dstparams->format.interleave;
+ newparams->format.interleave = dstparams->format.interleave;
}
- if (srcparams.format.interleave != dstparams->format.interleave &&
- srcparams.format.voices > 1)
- return -EINVAL;
- if (srcparams.format.format != dstparams->format.format)
- return -EINVAL;
- if (srcparams.format.rate != dstparams->format.rate)
- return -EINVAL;
- if (srcparams.format.voices != dstparams->format.voices)
- return -EINVAL;
return 0;
}
+
+