Mercurial > SDL_sound_CoreAudio
comparison decoders/voc.c @ 468:cd46c97e58bc
Fixed broken VOC decoder...would always dereference NULL during VOC_open().
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Sat, 25 Oct 2003 12:38:57 +0000 |
parents | daeb71a3f1ed |
children | c66080364dff 3f03af31e246 |
comparison
equal
deleted
inserted
replaced
467:ea1eaab18df9 | 468:cd46c97e58bc |
---|---|
183 return(1); /* success! */ | 183 return(1); /* success! */ |
184 } /* voc_check_header */ | 184 } /* voc_check_header */ |
185 | 185 |
186 | 186 |
187 /* Read next block header, save info, leave position at start of data */ | 187 /* Read next block header, save info, leave position at start of data */ |
188 static int voc_get_block(Sound_Sample *sample) | 188 static int voc_get_block(Sound_Sample *sample, vs_t *v) |
189 { | 189 { |
190 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; | 190 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; |
191 SDL_RWops *src = internal->rw; | 191 SDL_RWops *src = internal->rw; |
192 vs_t *v = (vs_t *) internal->decoder_private; | |
193 Uint8 bits24[3]; | 192 Uint8 bits24[3]; |
194 Uint8 uc, block; | 193 Uint8 uc, block; |
195 Uint32 sblen; | 194 Uint32 sblen; |
196 Uint16 new_rate_short; | 195 Uint16 new_rate_short; |
197 Uint32 new_rate_long; | 196 Uint32 new_rate_long; |
382 Uint8 silence = 0x80; | 381 Uint8 silence = 0x80; |
383 Uint8 *buf = internal->buffer; | 382 Uint8 *buf = internal->buffer; |
384 | 383 |
385 if (v->rest == 0) | 384 if (v->rest == 0) |
386 { | 385 { |
387 if (!voc_get_block(sample)) | 386 if (!voc_get_block(sample, v)) |
388 return 0; | 387 return 0; |
389 } /* if */ | 388 } /* if */ |
390 | 389 |
391 if (v->rest == 0) | 390 if (v->rest == 0) |
392 return 0; | 391 return 0; |
455 BAIL_IF_MACRO(v == NULL, ERR_OUT_OF_MEMORY, 0); | 454 BAIL_IF_MACRO(v == NULL, ERR_OUT_OF_MEMORY, 0); |
456 memset(v, '\0', sizeof (vs_t)); | 455 memset(v, '\0', sizeof (vs_t)); |
457 | 456 |
458 v->start_pos = SDL_RWtell(internal->rw); | 457 v->start_pos = SDL_RWtell(internal->rw); |
459 v->rate = -1; | 458 v->rate = -1; |
460 if (!voc_get_block(sample)) | 459 if (!voc_get_block(sample, v)) |
461 { | 460 { |
462 free(v); | 461 free(v); |
463 return(0); | 462 return(0); |
464 } /* if */ | 463 } /* if */ |
465 | 464 |
500 SOUND_SAMPLEFLAG_ERROR : | 499 SOUND_SAMPLEFLAG_ERROR : |
501 SOUND_SAMPLEFLAG_EOF; | 500 SOUND_SAMPLEFLAG_EOF; |
502 break; | 501 break; |
503 } /* if */ | 502 } /* if */ |
504 | 503 |
505 if (!voc_get_block(sample)) | 504 if (!voc_get_block(sample, v)) |
506 { | 505 { |
507 sample->flags |= (v->error) ? | 506 sample->flags |= (v->error) ? |
508 SOUND_SAMPLEFLAG_ERROR : | 507 SOUND_SAMPLEFLAG_ERROR : |
509 SOUND_SAMPLEFLAG_EOF; | 508 SOUND_SAMPLEFLAG_EOF; |
510 break; | 509 break; |
549 v->bufpos = 0; | 548 v->bufpos = 0; |
550 | 549 |
551 while (offset > 0) | 550 while (offset > 0) |
552 { | 551 { |
553 Uint32 rc = voc_read_waveform(sample, 0, offset); | 552 Uint32 rc = voc_read_waveform(sample, 0, offset); |
554 if ( (rc == 0) || (!voc_get_block(sample)) ) | 553 if ( (rc == 0) || (!voc_get_block(sample, v)) ) |
555 { | 554 { |
556 SDL_RWseek(internal->rw, origpos, SEEK_SET); | 555 SDL_RWseek(internal->rw, origpos, SEEK_SET); |
557 v->rest = origrest; | 556 v->rest = origrest; |
558 return(0); | 557 return(0); |
559 } /* if */ | 558 } /* if */ |