diff options
author | Takashi Iwai <tiwai@suse.de> | 2006-01-13 06:09:12 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-03-22 04:23:20 -0500 |
commit | 0534ab4279bd25e2d0a888af07466446dac05d74 (patch) | |
tree | c5e6f6398101e9b278db7d7749f93035d6e1fae6 /sound/core/oss/rate.c | |
parent | 9d83911ac082c6d63c1c08f235349113d8c1d0a3 (diff) |
[ALSA] Clean up pcm-oss plugins
Modules: ALSA<-OSS emulation
Clean up pcm-oss plugin codes.
Removed dead codes, and simplified route/rate plugins.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/oss/rate.c')
-rw-r--r-- | sound/core/oss/rate.c | 80 |
1 files changed, 20 insertions, 60 deletions
diff --git a/sound/core/oss/rate.c b/sound/core/oss/rate.c index c4b75bff0ee5..18d8a0f4e816 100644 --- a/sound/core/oss/rate.c +++ b/sound/core/oss/rate.c | |||
@@ -50,7 +50,6 @@ struct rate_priv { | |||
50 | unsigned int pitch; | 50 | unsigned int pitch; |
51 | unsigned int pos; | 51 | unsigned int pos; |
52 | rate_f func; | 52 | rate_f func; |
53 | int get, put; | ||
54 | snd_pcm_sframes_t old_src_frames, old_dst_frames; | 53 | snd_pcm_sframes_t old_src_frames, old_dst_frames; |
55 | struct rate_channel channels[0]; | 54 | struct rate_channel channels[0]; |
56 | }; | 55 | }; |
@@ -74,21 +73,12 @@ static void resample_expand(struct snd_pcm_plugin *plugin, | |||
74 | unsigned int pos = 0; | 73 | unsigned int pos = 0; |
75 | signed int val; | 74 | signed int val; |
76 | signed short S1, S2; | 75 | signed short S1, S2; |
77 | char *src, *dst; | 76 | signed short *src, *dst; |
78 | unsigned int channel; | 77 | unsigned int channel; |
79 | int src_step, dst_step; | 78 | int src_step, dst_step; |
80 | int src_frames1, dst_frames1; | 79 | int src_frames1, dst_frames1; |
81 | struct rate_priv *data = (struct rate_priv *)plugin->extra_data; | 80 | struct rate_priv *data = (struct rate_priv *)plugin->extra_data; |
82 | struct rate_channel *rchannels = data->channels; | 81 | struct rate_channel *rchannels = data->channels; |
83 | |||
84 | #define GET_S16_LABELS | ||
85 | #define PUT_S16_LABELS | ||
86 | #include "plugin_ops.h" | ||
87 | #undef GET_S16_LABELS | ||
88 | #undef PUT_S16_LABELS | ||
89 | void *get = get_s16_labels[data->get]; | ||
90 | void *put = put_s16_labels[data->put]; | ||
91 | signed short sample = 0; | ||
92 | 82 | ||
93 | for (channel = 0; channel < plugin->src_format.channels; channel++) { | 83 | for (channel = 0; channel < plugin->src_format.channels; channel++) { |
94 | pos = data->pos; | 84 | pos = data->pos; |
@@ -101,10 +91,12 @@ static void resample_expand(struct snd_pcm_plugin *plugin, | |||
101 | continue; | 91 | continue; |
102 | } | 92 | } |
103 | dst_channels[channel].enabled = 1; | 93 | dst_channels[channel].enabled = 1; |
104 | src = (char *)src_channels[channel].area.addr + src_channels[channel].area.first / 8; | 94 | src = (signed short *)src_channels[channel].area.addr + |
105 | dst = (char *)dst_channels[channel].area.addr + dst_channels[channel].area.first / 8; | 95 | src_channels[channel].area.first / 8 / 2; |
106 | src_step = src_channels[channel].area.step / 8; | 96 | dst = (signed short *)dst_channels[channel].area.addr + |
107 | dst_step = dst_channels[channel].area.step / 8; | 97 | dst_channels[channel].area.first / 8 / 2; |
98 | src_step = src_channels[channel].area.step / 8 / 2; | ||
99 | dst_step = dst_channels[channel].area.step / 8 / 2; | ||
108 | src_frames1 = src_frames; | 100 | src_frames1 = src_frames; |
109 | dst_frames1 = dst_frames; | 101 | dst_frames1 = dst_frames; |
110 | while (dst_frames1-- > 0) { | 102 | while (dst_frames1-- > 0) { |
@@ -112,12 +104,7 @@ static void resample_expand(struct snd_pcm_plugin *plugin, | |||
112 | pos &= R_MASK; | 104 | pos &= R_MASK; |
113 | S1 = S2; | 105 | S1 = S2; |
114 | if (src_frames1-- > 0) { | 106 | if (src_frames1-- > 0) { |
115 | goto *get; | 107 | S2 = *src; |
116 | #define GET_S16_END after_get | ||
117 | #include "plugin_ops.h" | ||
118 | #undef GET_S16_END | ||
119 | after_get: | ||
120 | S2 = sample; | ||
121 | src += src_step; | 108 | src += src_step; |
122 | } | 109 | } |
123 | } | 110 | } |
@@ -126,12 +113,7 @@ static void resample_expand(struct snd_pcm_plugin *plugin, | |||
126 | val = -32768; | 113 | val = -32768; |
127 | else if (val > 32767) | 114 | else if (val > 32767) |
128 | val = 32767; | 115 | val = 32767; |
129 | sample = val; | 116 | *dst = val; |
130 | goto *put; | ||
131 | #define PUT_S16_END after_put | ||
132 | #include "plugin_ops.h" | ||
133 | #undef PUT_S16_END | ||
134 | after_put: | ||
135 | dst += dst_step; | 117 | dst += dst_step; |
136 | pos += data->pitch; | 118 | pos += data->pitch; |
137 | } | 119 | } |
@@ -150,21 +132,12 @@ static void resample_shrink(struct snd_pcm_plugin *plugin, | |||
150 | unsigned int pos = 0; | 132 | unsigned int pos = 0; |
151 | signed int val; | 133 | signed int val; |
152 | signed short S1, S2; | 134 | signed short S1, S2; |
153 | char *src, *dst; | 135 | signed short *src, *dst; |
154 | unsigned int channel; | 136 | unsigned int channel; |
155 | int src_step, dst_step; | 137 | int src_step, dst_step; |
156 | int src_frames1, dst_frames1; | 138 | int src_frames1, dst_frames1; |
157 | struct rate_priv *data = (struct rate_priv *)plugin->extra_data; | 139 | struct rate_priv *data = (struct rate_priv *)plugin->extra_data; |
158 | struct rate_channel *rchannels = data->channels; | 140 | struct rate_channel *rchannels = data->channels; |
159 | |||
160 | #define GET_S16_LABELS | ||
161 | #define PUT_S16_LABELS | ||
162 | #include "plugin_ops.h" | ||
163 | #undef GET_S16_LABELS | ||
164 | #undef PUT_S16_LABELS | ||
165 | void *get = get_s16_labels[data->get]; | ||
166 | void *put = put_s16_labels[data->put]; | ||
167 | signed short sample = 0; | ||
168 | 141 | ||
169 | for (channel = 0; channel < plugin->src_format.channels; ++channel) { | 142 | for (channel = 0; channel < plugin->src_format.channels; ++channel) { |
170 | pos = data->pos; | 143 | pos = data->pos; |
@@ -177,21 +150,18 @@ static void resample_shrink(struct snd_pcm_plugin *plugin, | |||
177 | continue; | 150 | continue; |
178 | } | 151 | } |
179 | dst_channels[channel].enabled = 1; | 152 | dst_channels[channel].enabled = 1; |
180 | src = (char *)src_channels[channel].area.addr + src_channels[channel].area.first / 8; | 153 | src = (signed short *)src_channels[channel].area.addr + |
181 | dst = (char *)dst_channels[channel].area.addr + dst_channels[channel].area.first / 8; | 154 | src_channels[channel].area.first / 8 / 2; |
182 | src_step = src_channels[channel].area.step / 8; | 155 | dst = (signed short *)dst_channels[channel].area.addr + |
183 | dst_step = dst_channels[channel].area.step / 8; | 156 | dst_channels[channel].area.first / 8 / 2; |
157 | src_step = src_channels[channel].area.step / 8 / 2; | ||
158 | dst_step = dst_channels[channel].area.step / 8 / 2; | ||
184 | src_frames1 = src_frames; | 159 | src_frames1 = src_frames; |
185 | dst_frames1 = dst_frames; | 160 | dst_frames1 = dst_frames; |
186 | while (dst_frames1 > 0) { | 161 | while (dst_frames1 > 0) { |
187 | S1 = S2; | 162 | S1 = S2; |
188 | if (src_frames1-- > 0) { | 163 | if (src_frames1-- > 0) { |
189 | goto *get; | 164 | S1 = *src; |
190 | #define GET_S16_END after_get | ||
191 | #include "plugin_ops.h" | ||
192 | #undef GET_S16_END | ||
193 | after_get: | ||
194 | S2 = sample; | ||
195 | src += src_step; | 165 | src += src_step; |
196 | } | 166 | } |
197 | if (pos & ~R_MASK) { | 167 | if (pos & ~R_MASK) { |
@@ -201,12 +171,7 @@ static void resample_shrink(struct snd_pcm_plugin *plugin, | |||
201 | val = -32768; | 171 | val = -32768; |
202 | else if (val > 32767) | 172 | else if (val > 32767) |
203 | val = 32767; | 173 | val = 32767; |
204 | sample = val; | 174 | *dst = val; |
205 | goto *put; | ||
206 | #define PUT_S16_END after_put | ||
207 | #include "plugin_ops.h" | ||
208 | #undef PUT_S16_END | ||
209 | after_put: | ||
210 | dst += dst_step; | 175 | dst += dst_step; |
211 | dst_frames1--; | 176 | dst_frames1--; |
212 | } | 177 | } |
@@ -346,8 +311,8 @@ int snd_pcm_plugin_build_rate(struct snd_pcm_substream *plug, | |||
346 | 311 | ||
347 | snd_assert(src_format->channels == dst_format->channels, return -ENXIO); | 312 | snd_assert(src_format->channels == dst_format->channels, return -ENXIO); |
348 | snd_assert(src_format->channels > 0, return -ENXIO); | 313 | snd_assert(src_format->channels > 0, return -ENXIO); |
349 | snd_assert(snd_pcm_format_linear(src_format->format) != 0, return -ENXIO); | 314 | snd_assert(src_format->format == SNDRV_PCM_FORMAT_S16, return -ENXIO); |
350 | snd_assert(snd_pcm_format_linear(dst_format->format) != 0, return -ENXIO); | 315 | snd_assert(dst_format->format == SNDRV_PCM_FORMAT_S16, return -ENXIO); |
351 | snd_assert(src_format->rate != dst_format->rate, return -ENXIO); | 316 | snd_assert(src_format->rate != dst_format->rate, return -ENXIO); |
352 | 317 | ||
353 | err = snd_pcm_plugin_build(plug, "rate conversion", | 318 | err = snd_pcm_plugin_build(plug, "rate conversion", |
@@ -358,11 +323,6 @@ int snd_pcm_plugin_build_rate(struct snd_pcm_substream *plug, | |||
358 | if (err < 0) | 323 | if (err < 0) |
359 | return err; | 324 | return err; |
360 | data = (struct rate_priv *)plugin->extra_data; | 325 | data = (struct rate_priv *)plugin->extra_data; |
361 | data->get = getput_index(src_format->format); | ||
362 | snd_assert(data->get >= 0 && data->get < 4*2*2, return -EINVAL); | ||
363 | data->put = getput_index(dst_format->format); | ||
364 | snd_assert(data->put >= 0 && data->put < 4*2*2, return -EINVAL); | ||
365 | |||
366 | if (src_format->rate < dst_format->rate) { | 326 | if (src_format->rate < dst_format->rate) { |
367 | data->pitch = ((src_format->rate << SHIFT) + (dst_format->rate >> 1)) / dst_format->rate; | 327 | data->pitch = ((src_format->rate << SHIFT) + (dst_format->rate >> 1)) / dst_format->rate; |
368 | data->func = resample_expand; | 328 | data->func = resample_expand; |