wavestream.c
changeset 621 944412baab72
parent 617 87116a42526e
child 625 1d489d8ec2e0
equal deleted inserted replaced
620:e178da4a838c 621:944412baab72
   126         }
   126         }
   127         return(NULL);
   127         return(NULL);
   128     }
   128     }
   129     wave = (WAVStream *)SDL_malloc(sizeof *wave);
   129     wave = (WAVStream *)SDL_malloc(sizeof *wave);
   130     if ( wave ) {
   130     if ( wave ) {
   131         memset(wave, 0, (sizeof *wave));
   131         SDL_memset(wave, 0, (sizeof *wave));
   132         wave->freerw = freerw;
   132         wave->freerw = freerw;
   133         if ( strcmp(magic, "RIFF") == 0 ) {
   133         if ( strcmp(magic, "RIFF") == 0 ) {
   134             wave->rw = LoadWAVStream(rw, &wavespec,
   134             wave->rw = LoadWAVStream(rw, &wavespec,
   135                     &wave->start, &wave->stop);
   135                     &wave->start, &wave->stop);
   136         } else
   136         } else
   168 }
   168 }
   169 
   169 
   170 /* Play some of a stream previously started with WAVStream_Start() */
   170 /* Play some of a stream previously started with WAVStream_Start() */
   171 int WAVStream_PlaySome(Uint8 *stream, int len)
   171 int WAVStream_PlaySome(Uint8 *stream, int len)
   172 {
   172 {
   173     long pos;
   173     Sint64 pos;
   174     int left = 0;
   174     Sint64 left = 0;
   175 
   175 
   176     if ( music && ((pos=SDL_RWtell(music->rw)) < music->stop) ) {
   176     if ( music && ((pos=SDL_RWtell(music->rw)) < music->stop) ) {
   177         if ( music->cvt.needed ) {
   177         if ( music->cvt.needed ) {
   178             int original_len;
   178             int original_len;
   179 
   179 
   336         default:
   336         default:
   337             Mix_SetError("Unknown WAVE data format");
   337             Mix_SetError("Unknown WAVE data format");
   338             was_error = 1;
   338             was_error = 1;
   339             goto done;
   339             goto done;
   340     }
   340     }
   341     memset(spec, 0, (sizeof *spec));
   341     SDL_memset(spec, 0, (sizeof *spec));
   342     spec->freq = SDL_SwapLE32(format->frequency);
   342     spec->freq = SDL_SwapLE32(format->frequency);
   343     switch (SDL_SwapLE16(format->bitspersample)) {
   343     switch (SDL_SwapLE16(format->bitspersample)) {
   344         case 8:
   344         case 8:
   345             spec->format = AUDIO_U8;
   345             spec->format = AUDIO_U8;
   346             break;
   346             break;
   410     int found_SSND;
   410     int found_SSND;
   411     int found_COMM;
   411     int found_COMM;
   412 
   412 
   413     Uint32 chunk_type;
   413     Uint32 chunk_type;
   414     Uint32 chunk_length;
   414     Uint32 chunk_length;
   415     long next_chunk;
   415     Sint64 next_chunk;
   416 
   416 
   417     /* AIFF magic header */
   417     /* AIFF magic header */
   418     Uint32 FORMchunk;
   418     Uint32 FORMchunk;
   419     Uint32 AIFFmagic;
   419     Uint32 AIFFmagic;
   420     /* SSND chunk        */
   420     /* SSND chunk        */
   496     }
   496     }
   497 
   497 
   498     *stop = *start + channels * numsamples * (samplesize / 8);
   498     *stop = *start + channels * numsamples * (samplesize / 8);
   499 
   499 
   500     /* Decode the audio data format */
   500     /* Decode the audio data format */
   501     memset(spec, 0, (sizeof *spec));
   501     SDL_memset(spec, 0, (sizeof *spec));
   502     spec->freq = frequency;
   502     spec->freq = frequency;
   503     switch (samplesize) {
   503     switch (samplesize) {
   504         case 8:
   504         case 8:
   505             spec->format = AUDIO_S8;
   505             spec->format = AUDIO_S8;
   506             break;
   506             break;