mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-12-20 08:56:54 -05:00
Changed other static checks in assert
This commit is contained in:
parent
ef2a9bdd88
commit
a44c94959e
15 changed files with 258 additions and 473 deletions
|
|
@ -333,23 +333,20 @@ static ssize_t adpcm_transfer(snd_pcm_plugin_t *plugin,
|
|||
adpcm_t *data;
|
||||
unsigned int channel;
|
||||
|
||||
if (plugin == NULL || src_channels == NULL || dst_channels == NULL)
|
||||
return -EFAULT;
|
||||
assert(plugin && src_channels && dst_channels);
|
||||
if (frames == 0)
|
||||
return 0;
|
||||
for (channel = 0; channel < plugin->src_format.channels; channel++) {
|
||||
if (plugin->src_format.format == SND_PCM_SFMT_IMA_ADPCM) {
|
||||
if (src_channels[channel].area.first % 4 != 0 ||
|
||||
src_channels[channel].area.step % 4 != 0 ||
|
||||
dst_channels[channel].area.first % 8 != 0 ||
|
||||
dst_channels[channel].area.step % 8 != 0)
|
||||
return -EINVAL;
|
||||
assert(src_channels[channel].area.first % 4 == 0 &&
|
||||
src_channels[channel].area.step % 4 == 0 &&
|
||||
dst_channels[channel].area.first % 8 == 0 &&
|
||||
dst_channels[channel].area.step % 8 == 0);
|
||||
} else {
|
||||
if (src_channels[channel].area.first % 8 != 0 ||
|
||||
src_channels[channel].area.step % 8 != 0 ||
|
||||
dst_channels[channel].area.first % 4 != 0 ||
|
||||
dst_channels[channel].area.step % 4 != 0)
|
||||
return -EINVAL;
|
||||
assert(src_channels[channel].area.first % 8 == 0 &&
|
||||
src_channels[channel].area.step % 8 == 0 &&
|
||||
dst_channels[channel].area.first % 4 == 0 &&
|
||||
dst_channels[channel].area.step % 4 == 0);
|
||||
}
|
||||
}
|
||||
data = (adpcm_t *)plugin->extra_data;
|
||||
|
|
@ -361,8 +358,7 @@ static int adpcm_action(snd_pcm_plugin_t * plugin,
|
|||
snd_pcm_plugin_action_t action,
|
||||
unsigned long udata UNUSED)
|
||||
{
|
||||
if (plugin == NULL)
|
||||
return -EINVAL;
|
||||
assert(plugin);
|
||||
switch (action) {
|
||||
case INIT:
|
||||
case PREPARE:
|
||||
|
|
@ -388,14 +384,11 @@ int snd_pcm_plugin_build_adpcm(snd_pcm_plugin_handle_t *handle,
|
|||
snd_pcm_format_t *format;
|
||||
adpcm_f func;
|
||||
|
||||
if (r_plugin == NULL)
|
||||
return -EINVAL;
|
||||
assert(r_plugin);
|
||||
*r_plugin = NULL;
|
||||
|
||||
if (src_format->rate != dst_format->rate)
|
||||
return -EINVAL;
|
||||
if (src_format->channels != dst_format->channels)
|
||||
return -EINVAL;
|
||||
assert(src_format->rate == dst_format->rate);
|
||||
assert(src_format->channels == dst_format->channels);
|
||||
|
||||
if (dst_format->format == SND_PCM_SFMT_IMA_ADPCM) {
|
||||
format = src_format;
|
||||
|
|
@ -406,9 +399,8 @@ int snd_pcm_plugin_build_adpcm(snd_pcm_plugin_handle_t *handle,
|
|||
func = adpcm_decode;
|
||||
}
|
||||
else
|
||||
return -EINVAL;
|
||||
if (!snd_pcm_format_linear(format->format))
|
||||
return -EINVAL;
|
||||
assert(0);
|
||||
assert(snd_pcm_format_linear(format->format));
|
||||
|
||||
err = snd_pcm_plugin_build(handle, stream,
|
||||
"Ima-ADPCM<->linear conversion",
|
||||
|
|
|
|||
|
|
@ -234,17 +234,14 @@ static ssize_t alaw_transfer(snd_pcm_plugin_t *plugin,
|
|||
alaw_t *data;
|
||||
unsigned int channel;
|
||||
|
||||
if (plugin == NULL || src_channels == NULL || dst_channels == NULL)
|
||||
return -EFAULT;
|
||||
assert(plugin && src_channels && dst_channels);
|
||||
if (frames == 0)
|
||||
return 0;
|
||||
for (channel = 0; channel < plugin->src_format.channels; channel++) {
|
||||
if (src_channels[channel].area.first % 8 != 0 ||
|
||||
src_channels[channel].area.step % 8 != 0)
|
||||
return -EINVAL;
|
||||
if (dst_channels[channel].area.first % 8 != 0 ||
|
||||
dst_channels[channel].area.step % 8 != 0)
|
||||
return -EINVAL;
|
||||
assert(src_channels[channel].area.first % 8 == 0 &&
|
||||
src_channels[channel].area.step % 8 == 0);
|
||||
assert(dst_channels[channel].area.first % 8 == 0 &&
|
||||
dst_channels[channel].area.step % 8 == 0);
|
||||
}
|
||||
data = (alaw_t *)plugin->extra_data;
|
||||
data->func(plugin, src_channels, dst_channels, frames);
|
||||
|
|
@ -263,14 +260,11 @@ int snd_pcm_plugin_build_alaw(snd_pcm_plugin_handle_t *handle,
|
|||
snd_pcm_format_t *format;
|
||||
alaw_f func;
|
||||
|
||||
if (r_plugin == NULL)
|
||||
return -EINVAL;
|
||||
assert(r_plugin);
|
||||
*r_plugin = NULL;
|
||||
|
||||
if (src_format->rate != dst_format->rate)
|
||||
return -EINVAL;
|
||||
if (src_format->channels != dst_format->channels)
|
||||
return -EINVAL;
|
||||
assert(src_format->rate == dst_format->rate);
|
||||
assert(src_format->channels == dst_format->channels);
|
||||
|
||||
if (dst_format->format == SND_PCM_SFMT_A_LAW) {
|
||||
format = src_format;
|
||||
|
|
@ -281,9 +275,8 @@ int snd_pcm_plugin_build_alaw(snd_pcm_plugin_handle_t *handle,
|
|||
func = alaw_decode;
|
||||
}
|
||||
else
|
||||
return -EINVAL;
|
||||
if (!snd_pcm_format_linear(format->format))
|
||||
return -EINVAL;
|
||||
assert(0);
|
||||
assert(snd_pcm_format_linear(format->format));
|
||||
|
||||
err = snd_pcm_plugin_build(handle, stream,
|
||||
"A-Law<->linear conversion",
|
||||
|
|
|
|||
|
|
@ -42,18 +42,15 @@ static ssize_t copy_transfer(snd_pcm_plugin_t *plugin,
|
|||
unsigned int channel;
|
||||
unsigned int nchannels;
|
||||
|
||||
if (plugin == NULL || src_channels == NULL || dst_channels == NULL)
|
||||
return -EFAULT;
|
||||
assert(plugin && src_channels && dst_channels);
|
||||
if (frames == 0)
|
||||
return 0;
|
||||
nchannels = plugin->src_format.channels;
|
||||
for (channel = 0; channel < nchannels; channel++) {
|
||||
if (src_channels->area.first % 8 != 0 ||
|
||||
src_channels->area.step % 8 != 0)
|
||||
return -EINVAL;
|
||||
if (dst_channels->area.first % 8 != 0 ||
|
||||
dst_channels->area.step % 8 != 0)
|
||||
return -EINVAL;
|
||||
assert(src_channels->area.first % 8 == 0 &&
|
||||
src_channels->area.step % 8 == 0);
|
||||
assert(dst_channels->area.first % 8 == 0 &&
|
||||
dst_channels->area.step % 8 == 0);
|
||||
if (!src_channels->enabled) {
|
||||
if (dst_channels->wanted)
|
||||
snd_pcm_area_silence(&dst_channels->area, 0, frames, plugin->dst_format.format);
|
||||
|
|
@ -78,20 +75,15 @@ int snd_pcm_plugin_build_copy(snd_pcm_plugin_handle_t *handle,
|
|||
snd_pcm_plugin_t *plugin;
|
||||
int width;
|
||||
|
||||
if (r_plugin == NULL)
|
||||
return -EFAULT;
|
||||
assert(r_plugin);
|
||||
*r_plugin = NULL;
|
||||
|
||||
if (src_format->format != dst_format->format)
|
||||
return -EINVAL;
|
||||
if (src_format->rate != dst_format->rate)
|
||||
return -EINVAL;
|
||||
if (src_format->channels != dst_format->channels)
|
||||
return -EINVAL;
|
||||
assert(src_format->format == dst_format->format);
|
||||
assert(src_format->rate == dst_format->rate);
|
||||
assert(src_format->channels == dst_format->channels);
|
||||
|
||||
width = snd_pcm_format_physical_width(src_format->format);
|
||||
if (width < 0)
|
||||
return -EINVAL;
|
||||
assert(width > 0);
|
||||
|
||||
err = snd_pcm_plugin_build(handle, stream,
|
||||
"copy",
|
||||
|
|
|
|||
|
|
@ -55,15 +55,12 @@ static ssize_t io_transfer(snd_pcm_plugin_t *plugin,
|
|||
struct iovec *vec;
|
||||
int count, channel;
|
||||
|
||||
if (plugin == NULL)
|
||||
return -EINVAL;
|
||||
assert(plugin);
|
||||
data = (io_t *)plugin->extra_data;
|
||||
if (data == NULL)
|
||||
return -EINVAL;
|
||||
assert(data);
|
||||
vec = (struct iovec *)((char *)data + sizeof(*data));
|
||||
if (plugin->stream == SND_PCM_STREAM_PLAYBACK) {
|
||||
if (src_channels == NULL)
|
||||
return -EINVAL;
|
||||
assert(src_channels);
|
||||
if ((result = snd_pcm_plugin_src_frames_to_size(plugin, frames)) < 0)
|
||||
return result;
|
||||
count = plugin->src_format.channels;
|
||||
|
|
@ -84,8 +81,7 @@ static ssize_t io_transfer(snd_pcm_plugin_t *plugin,
|
|||
return result;
|
||||
return snd_pcm_plugin_src_size_to_frames(plugin, result);
|
||||
} else if (plugin->stream == SND_PCM_STREAM_CAPTURE) {
|
||||
if (dst_channels == NULL)
|
||||
return -EINVAL;
|
||||
assert(dst_channels);
|
||||
if ((result = snd_pcm_plugin_dst_frames_to_size(plugin, frames)) < 0)
|
||||
return result;
|
||||
count = plugin->dst_format.channels;
|
||||
|
|
@ -110,8 +106,9 @@ static ssize_t io_transfer(snd_pcm_plugin_t *plugin,
|
|||
return result;
|
||||
return snd_pcm_plugin_dst_size_to_frames(plugin, result);
|
||||
} else {
|
||||
return -EINVAL;
|
||||
assert(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t io_src_channels(snd_pcm_plugin_t *plugin,
|
||||
|
|
@ -140,11 +137,9 @@ int snd_pcm_plugin_build_io(snd_pcm_plugin_handle_t *pcm,
|
|||
io_t *data;
|
||||
snd_pcm_plugin_t *plugin;
|
||||
|
||||
if (r_plugin == NULL)
|
||||
return -EINVAL;
|
||||
assert(r_plugin);
|
||||
*r_plugin = NULL;
|
||||
if (pcm == NULL || format == NULL)
|
||||
return -EINVAL;
|
||||
assert(pcm && format);
|
||||
err = snd_pcm_plugin_build(pcm, stream,
|
||||
"I/O io",
|
||||
format, format,
|
||||
|
|
|
|||
|
|
@ -92,18 +92,15 @@ static ssize_t linear_transfer(snd_pcm_plugin_t *plugin,
|
|||
linear_t *data;
|
||||
unsigned int channel;
|
||||
|
||||
if (plugin == NULL || src_channels == NULL || dst_channels == NULL)
|
||||
return -EFAULT;
|
||||
assert(plugin && src_channels && dst_channels);
|
||||
data = (linear_t *)plugin->extra_data;
|
||||
if (frames == 0)
|
||||
return 0;
|
||||
for (channel = 0; channel < plugin->src_format.channels; channel++) {
|
||||
if (src_channels[channel].area.first % 8 != 0 ||
|
||||
src_channels[channel].area.step % 8 != 0)
|
||||
return -EINVAL;
|
||||
if (dst_channels[channel].area.first % 8 != 0 ||
|
||||
dst_channels[channel].area.step % 8 != 0)
|
||||
return -EINVAL;
|
||||
assert(src_channels[channel].area.first % 8 == 0 &&
|
||||
src_channels[channel].area.step % 8 == 0);
|
||||
assert(dst_channels[channel].area.first % 8 == 0 &&
|
||||
dst_channels[channel].area.step % 8 == 0);
|
||||
}
|
||||
convert(plugin, src_channels, dst_channels, frames);
|
||||
return frames;
|
||||
|
|
@ -144,17 +141,13 @@ int snd_pcm_plugin_build_linear(snd_pcm_plugin_handle_t *handle,
|
|||
struct linear_private_data *data;
|
||||
snd_pcm_plugin_t *plugin;
|
||||
|
||||
if (r_plugin == NULL)
|
||||
return -EFAULT;
|
||||
assert(r_plugin);
|
||||
*r_plugin = NULL;
|
||||
|
||||
if (src_format->rate != dst_format->rate)
|
||||
return -EINVAL;
|
||||
if (src_format->channels != dst_format->channels)
|
||||
return -EINVAL;
|
||||
if (!(snd_pcm_format_linear(src_format->format) &&
|
||||
snd_pcm_format_linear(dst_format->format)))
|
||||
return -EINVAL;
|
||||
assert(src_format->rate == dst_format->rate);
|
||||
assert(src_format->channels == dst_format->channels);
|
||||
assert(snd_pcm_format_linear(src_format->format) &&
|
||||
snd_pcm_format_linear(dst_format->format));
|
||||
|
||||
err = snd_pcm_plugin_build(handle, stream,
|
||||
"linear format conversion",
|
||||
|
|
|
|||
|
|
@ -57,8 +57,7 @@ static ssize_t mmap_src_channels(snd_pcm_plugin_t *plugin,
|
|||
int ready;
|
||||
unsigned int channel;
|
||||
|
||||
if (plugin == NULL || channels == NULL)
|
||||
return -EINVAL;
|
||||
assert(plugin && channels);
|
||||
data = (mmap_t *)plugin->extra_data;
|
||||
ctrl = data->control;
|
||||
stream = &data->slave->stream[plugin->stream];
|
||||
|
|
@ -86,8 +85,7 @@ static ssize_t mmap_src_channels(snd_pcm_plugin_t *plugin,
|
|||
assert(snd_pcm_mmap_ready(data->slave, plugin->stream));
|
||||
}
|
||||
pos = ctrl->byte_data % setup->buffer_size;
|
||||
if ((pos * 8) % stream->bits_per_frame != 0)
|
||||
return -EINVAL;
|
||||
assert((pos * 8) % stream->bits_per_frame == 0);
|
||||
pos = (pos * 8) / stream->bits_per_frame;
|
||||
|
||||
sv = plugin->src_channels;
|
||||
|
|
@ -125,8 +123,7 @@ static ssize_t mmap_dst_channels(snd_pcm_plugin_t *plugin,
|
|||
size_t pos;
|
||||
int ready;
|
||||
|
||||
if (plugin == NULL || channels == NULL)
|
||||
return -EINVAL;
|
||||
assert(plugin && channels);
|
||||
data = (mmap_t *)plugin->extra_data;
|
||||
stream = &data->slave->stream[plugin->stream];
|
||||
|
||||
|
|
@ -159,8 +156,7 @@ static ssize_t mmap_dst_channels(snd_pcm_plugin_t *plugin,
|
|||
assert(snd_pcm_mmap_ready(data->slave, plugin->stream));
|
||||
}
|
||||
pos = ctrl->byte_data % setup->buffer_size;
|
||||
if ((pos * 8) % stream->bits_per_frame != 0)
|
||||
return -EINVAL;
|
||||
assert((pos * 8) % stream->bits_per_frame == 0);
|
||||
pos = (pos * 8) / stream->bits_per_frame;
|
||||
|
||||
sv = stream->channels;
|
||||
|
|
@ -190,16 +186,11 @@ static ssize_t mmap_playback_transfer(snd_pcm_plugin_t *plugin,
|
|||
snd_pcm_stream_t *str;
|
||||
int err;
|
||||
|
||||
if (plugin == NULL)
|
||||
return -EINVAL;
|
||||
assert(plugin && plugin->prev);
|
||||
assert(src_channels);
|
||||
data = (mmap_t *)plugin->extra_data;
|
||||
if (src_channels == NULL)
|
||||
return -EINVAL;
|
||||
if (plugin->prev == NULL)
|
||||
return -EINVAL;
|
||||
ctrl = data->control;
|
||||
if (ctrl == NULL)
|
||||
return -EINVAL;
|
||||
assert(ctrl);
|
||||
str = &data->slave->stream[SND_PCM_STREAM_PLAYBACK];
|
||||
setup = &str->setup;
|
||||
|
||||
|
|
@ -231,15 +222,10 @@ static ssize_t mmap_capture_transfer(snd_pcm_plugin_t *plugin,
|
|||
snd_pcm_mmap_control_t *ctrl;
|
||||
snd_pcm_stream_t *str;
|
||||
|
||||
if (plugin == NULL)
|
||||
return -EINVAL;
|
||||
assert(plugin && plugin->next);
|
||||
data = (mmap_t *)plugin->extra_data;
|
||||
if (plugin->next == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
ctrl = data->control;
|
||||
if (ctrl == NULL)
|
||||
return -EINVAL;
|
||||
assert(ctrl);
|
||||
str = &data->slave->stream[SND_PCM_STREAM_CAPTURE];
|
||||
|
||||
/* FIXME: not here the increment */
|
||||
|
|
@ -254,8 +240,7 @@ static int mmap_action(snd_pcm_plugin_t *plugin,
|
|||
{
|
||||
struct mmap_private_data *data;
|
||||
|
||||
if (plugin == NULL)
|
||||
return -EINVAL;
|
||||
assert(plugin);
|
||||
data = (mmap_t *)plugin->extra_data;
|
||||
if (action == INIT) {
|
||||
snd_pcm_stream_setup_t *setup;
|
||||
|
|
@ -305,11 +290,9 @@ int snd_pcm_plugin_build_mmap(snd_pcm_plugin_handle_t *pcm,
|
|||
mmap_t *data;
|
||||
snd_pcm_plugin_t *plugin;
|
||||
|
||||
if (r_plugin == NULL)
|
||||
return -EINVAL;
|
||||
assert(r_plugin);
|
||||
*r_plugin = NULL;
|
||||
if (!pcm)
|
||||
return -EINVAL;
|
||||
assert(pcm);
|
||||
err = snd_pcm_plugin_build(pcm, stream,
|
||||
"I/O mmap",
|
||||
format, format,
|
||||
|
|
|
|||
|
|
@ -250,17 +250,14 @@ static ssize_t mulaw_transfer(snd_pcm_plugin_t *plugin,
|
|||
mulaw_t *data;
|
||||
unsigned int channel;
|
||||
|
||||
if (plugin == NULL || src_channels == NULL || dst_channels == NULL)
|
||||
return -EFAULT;
|
||||
assert(plugin && src_channels && dst_channels);
|
||||
if (frames == 0)
|
||||
return 0;
|
||||
for (channel = 0; channel < plugin->src_format.channels; channel++) {
|
||||
if (src_channels[channel].area.first % 8 != 0 ||
|
||||
src_channels[channel].area.step % 8 != 0)
|
||||
return -EINVAL;
|
||||
if (dst_channels[channel].area.first % 8 != 0 ||
|
||||
dst_channels[channel].area.step % 8 != 0)
|
||||
return -EINVAL;
|
||||
assert(src_channels[channel].area.first % 8 == 0 &&
|
||||
src_channels[channel].area.step % 8 == 0);
|
||||
assert(dst_channels[channel].area.first % 8 == 0 &&
|
||||
dst_channels[channel].area.step % 8 == 0);
|
||||
}
|
||||
data = (mulaw_t *)plugin->extra_data;
|
||||
data->func(plugin, src_channels, dst_channels, frames);
|
||||
|
|
@ -279,14 +276,11 @@ int snd_pcm_plugin_build_mulaw(snd_pcm_plugin_handle_t *handle,
|
|||
snd_pcm_format_t *format;
|
||||
mulaw_f func;
|
||||
|
||||
if (r_plugin == NULL)
|
||||
return -EINVAL;
|
||||
assert(r_plugin);
|
||||
*r_plugin = NULL;
|
||||
|
||||
if (src_format->rate != dst_format->rate)
|
||||
return -EINVAL;
|
||||
if (src_format->channels != dst_format->channels)
|
||||
return -EINVAL;
|
||||
assert(src_format->rate == dst_format->rate);
|
||||
assert(src_format->channels == dst_format->channels);
|
||||
|
||||
if (dst_format->format == SND_PCM_SFMT_MU_LAW) {
|
||||
format = src_format;
|
||||
|
|
@ -296,10 +290,11 @@ int snd_pcm_plugin_build_mulaw(snd_pcm_plugin_handle_t *handle,
|
|||
format = dst_format;
|
||||
func = mulaw_decode;
|
||||
}
|
||||
else
|
||||
return -EINVAL;
|
||||
if (!snd_pcm_format_linear(format->format))
|
||||
else {
|
||||
assert(0);
|
||||
return -EINVAL;
|
||||
}
|
||||
assert(snd_pcm_format_linear(format->format));
|
||||
|
||||
err = snd_pcm_plugin_build(handle, stream,
|
||||
"Mu-Law<->linear conversion",
|
||||
|
|
|
|||
|
|
@ -241,8 +241,9 @@ static ssize_t rate_src_frames(snd_pcm_plugin_t *plugin, size_t frames)
|
|||
rate_t *data;
|
||||
ssize_t res;
|
||||
|
||||
if (plugin == NULL || frames <= 0)
|
||||
return -EINVAL;
|
||||
assert(plugin);
|
||||
if (frames == 0)
|
||||
return 0;
|
||||
data = (rate_t *)plugin->extra_data;
|
||||
if (plugin->src_format.rate < plugin->dst_format.rate) {
|
||||
res = (((frames * data->pitch) + (BITS/2)) >> SHIFT);
|
||||
|
|
@ -272,8 +273,9 @@ static ssize_t rate_dst_frames(snd_pcm_plugin_t *plugin, size_t frames)
|
|||
rate_t *data;
|
||||
ssize_t res;
|
||||
|
||||
if (plugin == NULL || frames <= 0)
|
||||
return -EINVAL;
|
||||
assert(plugin);
|
||||
if (frames == 0)
|
||||
return 0;
|
||||
data = (rate_t *)plugin->extra_data;
|
||||
if (plugin->src_format.rate < plugin->dst_format.rate) {
|
||||
res = (((frames << SHIFT) + (data->pitch / 2)) / data->pitch);
|
||||
|
|
@ -307,17 +309,14 @@ static ssize_t rate_transfer(snd_pcm_plugin_t *plugin,
|
|||
unsigned int channel;
|
||||
rate_t *data;
|
||||
|
||||
if (plugin == NULL || src_channels == NULL || dst_channels == NULL)
|
||||
return -EFAULT;
|
||||
assert(plugin && src_channels && dst_channels);
|
||||
if (frames == 0)
|
||||
return 0;
|
||||
for (channel = 0; channel < plugin->src_format.channels; channel++) {
|
||||
if (src_channels[channel].area.first % 8 != 0 ||
|
||||
src_channels[channel].area.step % 8 != 0)
|
||||
return -EINVAL;
|
||||
if (dst_channels[channel].area.first % 8 != 0 ||
|
||||
dst_channels[channel].area.step % 8 != 0)
|
||||
return -EINVAL;
|
||||
assert(src_channels[channel].area.first % 8 == 0 &&
|
||||
src_channels[channel].area.step % 8 == 0);
|
||||
assert(dst_channels[channel].area.first % 8 == 0 &&
|
||||
dst_channels[channel].area.step % 8 == 0);
|
||||
}
|
||||
|
||||
dst_frames = rate_dst_frames(plugin, frames);
|
||||
|
|
@ -330,8 +329,7 @@ static int rate_action(snd_pcm_plugin_t *plugin,
|
|||
snd_pcm_plugin_action_t action,
|
||||
unsigned long udata UNUSED)
|
||||
{
|
||||
if (plugin == NULL)
|
||||
return -EINVAL;
|
||||
assert(plugin);
|
||||
switch (action) {
|
||||
case INIT:
|
||||
case PREPARE:
|
||||
|
|
@ -355,20 +353,14 @@ int snd_pcm_plugin_build_rate(snd_pcm_plugin_handle_t *handle,
|
|||
rate_t *data;
|
||||
snd_pcm_plugin_t *plugin;
|
||||
|
||||
if (r_plugin == NULL)
|
||||
return -EINVAL;
|
||||
assert(r_plugin);
|
||||
*r_plugin = NULL;
|
||||
|
||||
if (src_format->channels != dst_format->channels)
|
||||
return -EINVAL;
|
||||
if (src_format->channels < 1)
|
||||
return -EINVAL;
|
||||
if (snd_pcm_format_linear(src_format->format) <= 0)
|
||||
return -EINVAL;
|
||||
if (snd_pcm_format_linear(dst_format->format) <= 0)
|
||||
return -EINVAL;
|
||||
if (src_format->rate == dst_format->rate)
|
||||
return -EINVAL;
|
||||
assert(src_format->channels == dst_format->channels);
|
||||
assert(src_format->channels > 0);
|
||||
assert(snd_pcm_format_linear(src_format->format) > 0);
|
||||
assert(snd_pcm_format_linear(dst_format->format) > 0);
|
||||
assert(src_format->rate != dst_format->rate);
|
||||
|
||||
err = snd_pcm_plugin_build(handle, stream,
|
||||
"rate conversion",
|
||||
|
|
|
|||
|
|
@ -438,8 +438,7 @@ static int route_load_ttable(snd_pcm_plugin_t *plugin,
|
|||
int nsrcs = 0;
|
||||
ttable_src_t srcs[plugin->src_format.channels];
|
||||
for (src_channel = 0; src_channel < plugin->src_format.channels; ++src_channel) {
|
||||
if (*sptr < 0 || *sptr > FULL)
|
||||
return -EINVAL;
|
||||
assert(*sptr >= 0 && *sptr <= FULL);
|
||||
if (*sptr != 0) {
|
||||
srcs[nsrcs].channel = src_channel;
|
||||
#if ROUTE_PLUGIN_USE_FLOAT
|
||||
|
|
@ -457,8 +456,7 @@ static int route_load_ttable(snd_pcm_plugin_t *plugin,
|
|||
sptr++;
|
||||
}
|
||||
#if 0
|
||||
if (t > FULL)
|
||||
return -EINVAL;
|
||||
assert(t <= FULL);
|
||||
#endif
|
||||
dptr->att = att;
|
||||
dptr->nsrcs = nsrcs;
|
||||
|
|
@ -494,24 +492,21 @@ static ssize_t route_transfer(snd_pcm_plugin_t *plugin,
|
|||
ttable_dst_t *ttp;
|
||||
snd_pcm_plugin_channel_t *dvp;
|
||||
|
||||
if (plugin == NULL || src_channels == NULL || dst_channels == NULL)
|
||||
return -EFAULT;
|
||||
assert(plugin && src_channels && dst_channels);
|
||||
if (frames == 0)
|
||||
return 0;
|
||||
data = (route_t *)plugin->extra_data;
|
||||
|
||||
src_nchannels = plugin->src_format.channels;
|
||||
for (src_channel = 0; src_channel < src_nchannels; ++src_channel) {
|
||||
if (src_channels[src_channel].area.first % 8 != 0 ||
|
||||
src_channels[src_channel].area.step % 8 != 0)
|
||||
return -EINVAL;
|
||||
assert(src_channels[src_channel].area.first % 8 == 0 &&
|
||||
src_channels[src_channel].area.step % 8 == 0);
|
||||
}
|
||||
|
||||
dst_nchannels = plugin->dst_format.channels;
|
||||
for (dst_channel = 0; dst_channel < dst_nchannels; ++dst_channel) {
|
||||
if (dst_channels[dst_channel].area.first % 8 != 0 ||
|
||||
dst_channels[dst_channel].area.step % 8 != 0)
|
||||
return -EINVAL;
|
||||
assert(dst_channels[dst_channel].area.first % 8 == 0 &&
|
||||
dst_channels[dst_channel].area.step % 8 == 0);
|
||||
}
|
||||
|
||||
ttp = data->ttable;
|
||||
|
|
@ -550,14 +545,11 @@ int snd_pcm_plugin_build_route(snd_pcm_plugin_handle_t *handle,
|
|||
snd_pcm_plugin_t *plugin;
|
||||
int err;
|
||||
|
||||
if (!r_plugin)
|
||||
return -EFAULT;
|
||||
assert(r_plugin);
|
||||
*r_plugin = NULL;
|
||||
if (src_format->rate != dst_format->rate)
|
||||
return -EINVAL;
|
||||
if (!(snd_pcm_format_linear(src_format->format) &&
|
||||
snd_pcm_format_linear(dst_format->format)))
|
||||
return -EINVAL;
|
||||
assert(src_format->rate == dst_format->rate);
|
||||
assert(snd_pcm_format_linear(src_format->format) &&
|
||||
snd_pcm_format_linear(dst_format->format));
|
||||
|
||||
err = snd_pcm_plugin_build(handle, stream,
|
||||
"attenuated route conversion",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue