load_voc.c
changeset 777 92882ef2ab81
parent 755 7c9cfb3bf040
child 792 5121e121451b
equal deleted inserted replaced
776:07b8e286bc03 777:92882ef2ab81
    26   This file by Ryan C. Gordon (icculus@icculus.org).
    26   This file by Ryan C. Gordon (icculus@icculus.org).
    27 
    27 
    28   Heavily borrowed from sox v12.17.1's voc.c.
    28   Heavily borrowed from sox v12.17.1's voc.c.
    29         (http://www.freshmeat.net/projects/sox/)
    29         (http://www.freshmeat.net/projects/sox/)
    30 */
    30 */
    31 
       
    32 /* $Id$ */
       
    33 
       
    34 #include <stdio.h>
       
    35 #include <stdlib.h>
       
    36 #include <string.h>
       
    37 
       
    38 #include "SDL_mutex.h"
       
    39 #include "SDL_endian.h"
       
    40 #include "SDL_timer.h"
       
    41 
    31 
    42 #include "SDL_mixer.h"
    32 #include "SDL_mixer.h"
    43 #include "load_voc.h"
    33 #include "load_voc.h"
    44 
    34 
    45 /* Private data for VOC file */
    35 /* Private data for VOC file */
   140 
   130 
   141         if (SDL_RWread(src, bits24, sizeof (bits24), 1) != 1)
   131         if (SDL_RWread(src, bits24, sizeof (bits24), 1) != 1)
   142             return 1;  /* assume that's the end of the file. */
   132             return 1;  /* assume that's the end of the file. */
   143 
   133 
   144         /* Size is an 24-bit value. Ugh. */
   134         /* Size is an 24-bit value. Ugh. */
   145         sblen = ( (bits24[0]) | (bits24[1] << 8) | (bits24[2] << 16) );
   135         sblen = ((bits24[0]) | (bits24[1] << 8) | (bits24[2] << 16));
   146 
   136 
   147         switch(block)
   137         switch(block)
   148         {
   138         {
   149             case VOC_DATA:
   139             case VOC_DATA:
   150                 if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
   140                 if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
   382     int was_error = 1;
   372     int was_error = 1;
   383     int samplesize;
   373     int samplesize;
   384     Uint8 *fillptr;
   374     Uint8 *fillptr;
   385     void *ptr;
   375     void *ptr;
   386 
   376 
   387     if ( (!src) || (!audio_buf) || (!audio_len) )   /* sanity checks. */
   377     if ((!src) || (!audio_buf) || (!audio_len))   /* sanity checks. */
   388         goto done;
   378         goto done;
   389 
   379 
   390     if ( !voc_check_header(src) )
   380     if (!voc_check_header(src))
   391         goto done;
   381         goto done;
   392 
   382 
   393     v.rate = -1;
   383     v.rate = -1;
   394     v.rest = 0;
   384     v.rest = 0;
   395     v.has_extended = 0;
   385     v.has_extended = 0;
   455 
   445 
   456     return(spec);
   446     return(spec);
   457 } /* Mix_LoadVOC_RW */
   447 } /* Mix_LoadVOC_RW */
   458 
   448 
   459 /* end of load_voc.c ... */
   449 /* end of load_voc.c ... */
       
   450 
       
   451 /* vi: set ts=4 sw=4 expandtab: */