comparison decoders/voc.c @ 22:f6e679afe88b

Byte ordering fix, changed voc_read to voc_read_waveform, and cleaned up some header includes.
author Ryan C. Gordon <icculus@icculus.org>
date Wed, 19 Sep 2001 08:31:54 +0000
parents 41e5e07c5fed
children 4a60ee42ca9a
comparison
equal deleted inserted replaced
21:d9b9d60cf9a9 22:f6e679afe88b
39 39
40 #include <stdio.h> 40 #include <stdio.h>
41 #include <stdlib.h> 41 #include <stdlib.h>
42 #include <string.h> 42 #include <string.h>
43 #include <assert.h> 43 #include <assert.h>
44
45 #include "SDL.h"
46 #include "SDL_endian.h"
47 #include "SDL_sound.h" 44 #include "SDL_sound.h"
48 45
49 #define __SDL_SOUND_INTERNAL__ 46 #define __SDL_SOUND_INTERNAL__
50 #include "SDL_sound_internal.h" 47 #include "SDL_sound_internal.h"
51 48
360 357
361 return 1; 358 return 1;
362 } 359 }
363 360
364 361
365 static int voc_read(Sound_Sample *sample) 362 static int voc_read_waveform(Sound_Sample *sample)
366 { 363 {
367 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; 364 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
368 SDL_RWops *src = internal->rw; 365 SDL_RWops *src = internal->rw;
369 vs_t *v = (vs_t *) internal->decoder_private; 366 vs_t *v = (vs_t *) internal->decoder_private;
370 int done = 0; 367 int done = 0;
396 Uint32 max = (v->rest < internal->buffer_size) ? 393 Uint32 max = (v->rest < internal->buffer_size) ?
397 v->rest : internal->buffer_size; 394 v->rest : internal->buffer_size;
398 done = SDL_RWread(src, buf + v->bufpos, 1, max); 395 done = SDL_RWread(src, buf + v->bufpos, 1, max);
399 v->rest -= done; 396 v->rest -= done;
400 v->bufpos += done; 397 v->bufpos += done;
401 if (v->size == ST_SIZE_WORD)
402 {
403 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
404 for (; v->rest > 0; v->rest -= 2)
405 {
406 *((Uint16 *) buf) = SDL_SwapLE16(*((Uint16 *) buf));
407 ((Uint16 *) buf)++;
408 }
409 #endif
410 }
411 } 398 }
412 399
413 return done; 400 return done;
414 } /* voc_read */ 401 } /* voc_read_waveform */
415 402
416 403
417 static int VOC_open(Sound_Sample *sample, const char *ext) 404 static int VOC_open(Sound_Sample *sample, const char *ext)
418 { 405 {
419 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; 406 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
462 vs_t *v = (vs_t *) internal->decoder_private; 449 vs_t *v = (vs_t *) internal->decoder_private;
463 450
464 v->bufpos = 0; 451 v->bufpos = 0;
465 while (v->bufpos < internal->buffer_size) 452 while (v->bufpos < internal->buffer_size)
466 { 453 {
467 Uint32 rc = voc_read(sample); 454 Uint32 rc = voc_read_waveform(sample);
468 if (rc == 0) /* !!! FIXME: Could be an error... */ 455 if (rc == 0) /* !!! FIXME: Could be an error... */
469 { 456 {
470 sample->flags |= SOUND_SAMPLEFLAG_EOF; 457 sample->flags |= SOUND_SAMPLEFLAG_EOF;
471 break; 458 break;
472 } /* if */ 459 } /* if */