aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorJaroslav Kysela <perex@suse.cz>2005-01-03 16:12:59 +0100
committerJaroslav Kysela <perex@suse.cz>2005-01-03 16:12:59 +0100
commitd6d4c514b69b215c2bc5820717382e3dc28ae4fe (patch)
treed336b908d0a1ed7a2fffd9b5d2bafb0ebaff256f /sound
parentf89e175a1c791fb5de21a36d191640e10d4a4656 (diff)
downloadhistory-d6d4c514b69b215c2bc5820717382e3dc28ae4fe.tar.gz
[ALSA] Clean up codes
ALSA<-OSS emulation Got rid of the unused float codes (the legacy code for sharing with ALSA library). Add assert to the invalid conversion indices which results in oops (just to be sure). Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/core/oss/mulaw.c1
-rw-r--r--sound/core/oss/pcm_plugin.c3
-rw-r--r--sound/core/oss/pcm_plugin.h1
-rw-r--r--sound/core/oss/rate.c2
-rw-r--r--sound/core/oss/route.c76
5 files changed, 10 insertions, 73 deletions
diff --git a/sound/core/oss/mulaw.c b/sound/core/oss/mulaw.c
index 0d16c620f64624..44ec4c66eb199e 100644
--- a/sound/core/oss/mulaw.c
+++ b/sound/core/oss/mulaw.c
@@ -301,6 +301,7 @@ int snd_pcm_plugin_build_mulaw(snd_pcm_plug_t *plug,
data = (mulaw_t*)plugin->extra_data;
data->func = func;
data->conv = getput_index(format->format);
+ snd_assert(data->conv >= 0 && data->conv < 4*2*2, return -EINVAL);
plugin->transfer = mulaw_transfer;
*r_plugin = plugin;
return 0;
diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c
index 397d9b6d0d2297..6bb31009f0b499 100644
--- a/sound/core/oss/pcm_plugin.c
+++ b/sound/core/oss/pcm_plugin.c
@@ -385,7 +385,7 @@ int snd_pcm_plug_format_plugins(snd_pcm_plug_t *plug,
snd_pcm_plugin_format_t srcformat;
int src_access, dst_access;
snd_pcm_plugin_t *plugin = NULL;
- int err, first;
+ int err;
int stream = snd_pcm_plug_stream(plug);
int slave_interleaved = (params_channels(slave_params) == 1 ||
params_access(slave_params) == SNDRV_PCM_ACCESS_RW_INTERLEAVED);
@@ -437,7 +437,6 @@ int snd_pcm_plug_format_plugins(snd_pcm_plug_t *plug,
tmpformat.format = dstformat.format;
else
tmpformat.format = SNDRV_PCM_FORMAT_S16;
- first = plugin == NULL;
switch (srcformat.format) {
case SNDRV_PCM_FORMAT_MU_LAW:
err = snd_pcm_plugin_build_mulaw(plug,
diff --git a/sound/core/oss/pcm_plugin.h b/sound/core/oss/pcm_plugin.h
index e21c136480ea72..0f86ce47749019 100644
--- a/sound/core/oss/pcm_plugin.h
+++ b/sound/core/oss/pcm_plugin.h
@@ -168,7 +168,6 @@ int snd_pcm_plug_alloc(snd_pcm_plug_t *plug, snd_pcm_uframes_t frames);
snd_pcm_sframes_t snd_pcm_plug_client_size(snd_pcm_plug_t *handle, snd_pcm_uframes_t drv_size);
snd_pcm_sframes_t snd_pcm_plug_slave_size(snd_pcm_plug_t *handle, snd_pcm_uframes_t clt_size);
-#define ROUTE_PLUGIN_USE_FLOAT 0
#define FULL ROUTE_PLUGIN_RESOLUTION
#define HALF ROUTE_PLUGIN_RESOLUTION / 2
typedef int route_ttable_entry_t;
diff --git a/sound/core/oss/rate.c b/sound/core/oss/rate.c
index 70a79d3e8c3d3e..1096ec18671406 100644
--- a/sound/core/oss/rate.c
+++ b/sound/core/oss/rate.c
@@ -355,7 +355,9 @@ int snd_pcm_plugin_build_rate(snd_pcm_plug_t *plug,
return err;
data = (rate_t *)plugin->extra_data;
data->get = getput_index(src_format->format);
+ snd_assert(data->get >= 0 && data->get < 4*2*2, return -EINVAL);
data->put = getput_index(dst_format->format);
+ snd_assert(data->put >= 0 && data->put < 4*2*2, return -EINVAL);
if (src_format->rate < dst_format->rate) {
data->pitch = ((src_format->rate << SHIFT) + (dst_format->rate >> 1)) / dst_format->rate;
diff --git a/sound/core/oss/route.c b/sound/core/oss/route.c
index 6ff4de7cc4f39b..c955b7dfdb30fc 100644
--- a/sound/core/oss/route.c
+++ b/sound/core/oss/route.c
@@ -46,9 +46,6 @@ typedef void (*route_channel_f)(snd_pcm_plugin_t *plugin,
typedef struct {
int channel;
int as_int;
-#if ROUTE_PLUGIN_USE_FLOAT
- float as_float;
-#endif
} ttable_src_t;
struct ttable_dst {
@@ -59,7 +56,7 @@ struct ttable_dst {
};
struct route_private_data {
- enum {R_UINT32=0, R_UINT64=1, R_FLOAT=2} sum_type;
+ enum {R_UINT32=0, R_UINT64=1} sum_type;
int get, put;
int conv;
int src_sample_size;
@@ -69,9 +66,6 @@ struct route_private_data {
typedef union {
u_int32_t as_uint32;
u_int64_t as_uint64;
-#if ROUTE_PLUGIN_USE_FLOAT
- float as_float;
-#endif
} sum_t;
@@ -136,20 +130,13 @@ static void route_to_channel(snd_pcm_plugin_t *plugin,
#include "plugin_ops.h"
#undef GET_U_LABELS
#undef PUT_U32_LABELS
- static void *zero_labels[3] = { &&zero_int32, &&zero_int64,
-#if ROUTE_PLUGIN_USE_FLOAT
- &&zero_float
-#endif
- };
+ static void *zero_labels[2] = { &&zero_int32, &&zero_int64 };
/* sum_type att */
- static void *add_labels[3 * 2] = { &&add_int32_noatt, &&add_int32_att,
+ static void *add_labels[2 * 2] = { &&add_int32_noatt, &&add_int32_att,
&&add_int64_noatt, &&add_int64_att,
-#if ROUTE_PLUGIN_USE_FLOAT
- &&add_float_noatt, &&add_float_att
-#endif
};
/* sum_type att shift */
- static void *norm_labels[3 * 2 * 4] = { NULL,
+ static void *norm_labels[2 * 2 * 4] = { NULL,
&&norm_int32_8_noatt,
&&norm_int32_16_noatt,
&&norm_int32_24_noatt,
@@ -165,16 +152,6 @@ static void route_to_channel(snd_pcm_plugin_t *plugin,
&&norm_int64_8_att,
&&norm_int64_16_att,
&&norm_int64_24_att,
-#if ROUTE_PLUGIN_USE_FLOAT
- &&norm_float_0,
- &&norm_float_8,
- &&norm_float_16,
- &&norm_float_24,
- &&norm_float_0,
- &&norm_float_8,
- &&norm_float_16,
- &&norm_float_24,
-#endif
};
route_t *data = (route_t *)plugin->extra_data;
void *zero, *get, *add, *norm, *put_u32;
@@ -225,11 +202,6 @@ static void route_to_channel(snd_pcm_plugin_t *plugin,
zero_int64:
sum.as_uint64 = 0;
goto zero_end;
-#if ROUTE_PLUGIN_USE_FLOAT
- zero_float:
- sum.as_float = 0.0;
- goto zero_end;
-#endif
zero_end:
for (srcidx = 0; srcidx < nsrcs; ++srcidx) {
char *src = srcs[srcidx];
@@ -257,15 +229,6 @@ static void route_to_channel(snd_pcm_plugin_t *plugin,
if (ttp->as_int)
sum.as_uint64 += sample;
goto after_sum;
-#if ROUTE_PLUGIN_USE_FLOAT
- add_float_att:
- sum.as_float += sample * ttp->as_float;
- goto after_sum;
- add_float_noatt:
- if (ttp->as_int)
- sum.as_float += sample;
- goto after_sum;
-#endif
after_sum:
srcs[srcidx] += src_steps[srcidx];
ttp++;
@@ -321,25 +284,6 @@ static void route_to_channel(snd_pcm_plugin_t *plugin,
sample = sum.as_uint64;
goto after_norm;
-#if ROUTE_PLUGIN_USE_FLOAT
- norm_float_8:
- sum.as_float *= 1 << 8;
- goto norm_float;
- norm_float_16:
- sum.as_float *= 1 << 16;
- goto norm_float;
- norm_float_24:
- sum.as_float *= 1 << 24;
- goto norm_float;
- norm_float_0:
- norm_float:
- sum.as_float = floor(sum.as_float + 0.5);
- if (sum.as_float > (u_int32_t)0xffffffff)
- sample = (u_int32_t)0xffffffff;
- else
- sample = sum.as_float;
- goto after_norm;
-#endif
after_norm:
/* Put sample */
@@ -433,13 +377,7 @@ static int route_load_ttable(snd_pcm_plugin_t *plugin,
snd_assert(*sptr >= 0 || *sptr <= FULL, return -ENXIO);
if (*sptr != 0) {
srcs[nsrcs].channel = src_channel;
-#if ROUTE_PLUGIN_USE_FLOAT
- /* Also in user space for non attenuated */
- srcs[nsrcs].as_int = (*sptr == FULL ? ROUTE_PLUGIN_RESOLUTION : 0);
- srcs[nsrcs].as_float = *sptr;
-#else
srcs[nsrcs].as_int = *sptr;
-#endif
if (*sptr != FULL)
att = 1;
t += *sptr;
@@ -558,17 +496,15 @@ int snd_pcm_plugin_build_route(snd_pcm_plug_t *plug,
data = (route_t *) plugin->extra_data;
data->get = getput_index(src_format->format);
+ snd_assert(data->get >= 0 && data->get < 4*2*2, return -EINVAL);
data->put = getput_index(dst_format->format);
+ snd_assert(data->get >= 0 && data->get < 4*2*2, return -EINVAL);
data->conv = conv_index(src_format->format, dst_format->format);
-#if ROUTE_PLUGIN_USE_FLOAT
- data->sum_type = R_FLOAT;
-#else
if (snd_pcm_format_width(src_format->format) == 32)
data->sum_type = R_UINT64;
else
data->sum_type = R_UINT32;
-#endif
data->src_sample_size = snd_pcm_format_width(src_format->format) / 8;
if ((err = route_load_ttable(plugin, ttable)) < 0) {