X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fcore%2Foss%2Fmulaw.c;h=2eb18807e6d04662f9d85bed3355d8ad2cd5b5e6;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=0d16c620f64624dca20a7a492c8339852f187d34;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/sound/core/oss/mulaw.c b/sound/core/oss/mulaw.c index 0d16c620f..2eb18807e 100644 --- a/sound/core/oss/mulaw.c +++ b/sound/core/oss/mulaw.c @@ -22,6 +22,9 @@ */ #include + +#ifdef CONFIG_SND_PCM_OSS_PLUGINS + #include #include #include @@ -139,25 +142,25 @@ static int ulaw2linear(unsigned char u_val) * Basic Mu-Law plugin */ -typedef void (*mulaw_f)(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channels, +typedef void (*mulaw_f)(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channels, snd_pcm_uframes_t frames); -typedef struct mulaw_private_data { +struct mulaw_priv { mulaw_f func; int conv; -} mulaw_t; +}; -static void mulaw_decode(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channels, +static void mulaw_decode(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channels, snd_pcm_uframes_t frames) { #define PUT_S16_LABELS #include "plugin_ops.h" #undef PUT_S16_LABELS - mulaw_t *data = (mulaw_t *)plugin->extra_data; + struct mulaw_priv *data = (struct mulaw_priv *)plugin->extra_data; void *put = put_s16_labels[data->conv]; int channel; int nchannels = plugin->src_format.channels; @@ -191,15 +194,15 @@ static void mulaw_decode(snd_pcm_plugin_t *plugin, } } -static void mulaw_encode(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channels, +static void mulaw_encode(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channels, snd_pcm_uframes_t frames) { #define GET_S16_LABELS #include "plugin_ops.h" #undef GET_S16_LABELS - mulaw_t *data = (mulaw_t *)plugin->extra_data; + struct mulaw_priv *data = (struct mulaw_priv *)plugin->extra_data; void *get = get_s16_labels[data->conv]; int channel; int nchannels = plugin->src_format.channels; @@ -234,12 +237,12 @@ static void mulaw_encode(snd_pcm_plugin_t *plugin, } } -static snd_pcm_sframes_t mulaw_transfer(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channels, +static snd_pcm_sframes_t mulaw_transfer(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channels, snd_pcm_uframes_t frames) { - mulaw_t *data; + struct mulaw_priv *data; snd_assert(plugin != NULL && src_channels != NULL && dst_channels != NULL, return -ENXIO); if (frames == 0) @@ -257,20 +260,39 @@ static snd_pcm_sframes_t mulaw_transfer(snd_pcm_plugin_t *plugin, } } #endif - data = (mulaw_t *)plugin->extra_data; + data = (struct mulaw_priv *)plugin->extra_data; data->func(plugin, src_channels, dst_channels, frames); return frames; } -int snd_pcm_plugin_build_mulaw(snd_pcm_plug_t *plug, - snd_pcm_plugin_format_t *src_format, - snd_pcm_plugin_format_t *dst_format, - snd_pcm_plugin_t **r_plugin) +static int getput_index(int format) +{ + int sign, width, endian; + sign = !snd_pcm_format_signed(format); + width = snd_pcm_format_width(format) / 8 - 1; + if (width < 0 || width > 3) { + snd_printk(KERN_ERR "snd-pcm-oss: invalid format %d\n", format); + width = 0; + } +#ifdef SNDRV_LITTLE_ENDIAN + endian = snd_pcm_format_big_endian(format); +#else + endian = snd_pcm_format_little_endian(format); +#endif + if (endian < 0) + endian = 0; + return width * 4 + endian * 2 + sign; +} + +int snd_pcm_plugin_build_mulaw(struct snd_pcm_substream *plug, + struct snd_pcm_plugin_format *src_format, + struct snd_pcm_plugin_format *dst_format, + struct snd_pcm_plugin **r_plugin) { int err; - mulaw_t *data; - snd_pcm_plugin_t *plugin; - snd_pcm_plugin_format_t *format; + struct mulaw_priv *data; + struct snd_pcm_plugin *plugin; + struct snd_pcm_plugin_format *format; mulaw_f func; snd_assert(r_plugin != NULL, return -ENXIO); @@ -295,13 +317,16 @@ int snd_pcm_plugin_build_mulaw(snd_pcm_plug_t *plug, err = snd_pcm_plugin_build(plug, "Mu-Law<->linear conversion", src_format, dst_format, - sizeof(mulaw_t), &plugin); + sizeof(struct mulaw_priv), &plugin); if (err < 0) return err; - data = (mulaw_t*)plugin->extra_data; + data = (struct mulaw_priv *)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; } + +#endif