comparison src/audio/SDL_mixer.c @ 2013:0615fa58c0be

Fixed S32 audio mixing, but I'm a bit nervous about the use of 64-bit datatypes here...
author Ryan C. Gordon <icculus@icculus.org>
date Fri, 01 Sep 2006 19:17:05 +0000
parents 8055185ae4ed
children 7abe37467fa5
comparison
equal deleted inserted replaced
2012:575d5c9d4db8 2013:0615fa58c0be
259 259
260 case AUDIO_S32LSB: 260 case AUDIO_S32LSB:
261 { 261 {
262 const Uint32 *src32 = (Uint32 *) src; 262 const Uint32 *src32 = (Uint32 *) src;
263 Uint32 *dst32 = (Uint32 *) dst; 263 Uint32 *dst32 = (Uint32 *) dst;
264 Sint32 src1, src2; 264 Sint64 src1, src2;
265 Sint64 dst_sample; 265 Sint64 dst_sample;
266 const Sint64 max_audioval = ((((Sint64) 1) << (32 - 1)) - 1); 266 const Sint64 max_audioval = ((((Sint64) 1) << (32 - 1)) - 1);
267 const Sint64 min_audioval = -(((Sint64) 1) << (32 - 1)); 267 const Sint64 min_audioval = -(((Sint64) 1) << (32 - 1));
268 268
269 len /= 4; 269 len /= 4;
270 while (len--) { 270 while (len--) {
271 src1 = (Sint32) SDL_SwapLE32(*src32); 271 src1 = (Sint64) ((Sint32) SDL_SwapLE32(*src32));
272 src32++; 272 src32++;
273 ADJUST_VOLUME(src1, volume); 273 ADJUST_VOLUME(src1, volume);
274 src2 = (Sint32) SDL_SwapLE32(*dst32); 274 src2 = (Sint64) ((Sint32) SDL_SwapLE32(*dst32));
275 dst_sample = src1 + src2; 275 dst_sample = src1 + src2;
276 if (dst_sample > max_audioval) { 276 if (dst_sample > max_audioval) {
277 dst_sample = max_audioval; 277 dst_sample = max_audioval;
278 } else if (dst_sample < min_audioval) { 278 } else if (dst_sample < min_audioval) {
279 dst_sample = min_audioval; 279 dst_sample = min_audioval;
285 285
286 case AUDIO_S32MSB: 286 case AUDIO_S32MSB:
287 { 287 {
288 const Uint32 *src32 = (Uint32 *) src; 288 const Uint32 *src32 = (Uint32 *) src;
289 Uint32 *dst32 = (Uint32 *) dst; 289 Uint32 *dst32 = (Uint32 *) dst;
290 Sint32 src1, src2; 290 Sint64 src1, src2;
291 Sint64 dst_sample; 291 Sint64 dst_sample;
292 const Sint64 max_audioval = ((((Sint64) 1) << (32 - 1)) - 1); 292 const Sint64 max_audioval = ((((Sint64) 1) << (32 - 1)) - 1);
293 const Sint64 min_audioval = -(((Sint64) 1) << (32 - 1)); 293 const Sint64 min_audioval = -(((Sint64) 1) << (32 - 1));
294 294
295 len /= 4; 295 len /= 4;
296 while (len--) { 296 while (len--) {
297 src1 = (Sint32) SDL_SwapBE32(*src32); 297 src1 = (Sint64) ((Sint32) SDL_SwapBE32(*src32));
298 src32++; 298 src32++;
299 ADJUST_VOLUME(src1, volume); 299 ADJUST_VOLUME(src1, volume);
300 src2 = (Sint32) SDL_SwapBE32(*dst32); 300 src2 = (Sint64) ((Sint32) SDL_SwapBE32(*dst32));
301 dst_sample = src1 + src2; 301 dst_sample = src1 + src2;
302 if (dst_sample > max_audioval) { 302 if (dst_sample > max_audioval) {
303 dst_sample = max_audioval; 303 dst_sample = max_audioval;
304 } else if (dst_sample < min_audioval) { 304 } else if (dst_sample < min_audioval) {
305 dst_sample = min_audioval; 305 dst_sample = min_audioval;