Mercurial > SDL_sound_CoreAudio
comparison decoders/flac.c @ 400:9d0b5ec9cc26
FIXME cleanups.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Thu, 11 Jul 2002 05:28:52 +0000 |
parents | b12c4483815e |
children | 5b06e23d934e |
comparison
equal
deleted
inserted
replaced
399:e435bdcad552 | 400:9d0b5ec9cc26 |
---|---|
368 const decoder_t *decoder, | 368 const decoder_t *decoder, |
369 FLAC__uint64 *absolute_byte_offset, | 369 FLAC__uint64 *absolute_byte_offset, |
370 void *client_data) | 370 void *client_data) |
371 { | 371 { |
372 flac_t *f = (flac_t *) client_data; | 372 flac_t *f = (flac_t *) client_data; |
373 int pos; /* !!! FIXME: int? Really? */ | 373 int pos; |
374 | 374 |
375 pos = SDL_RWtell(f->rw); | 375 pos = SDL_RWtell(f->rw); |
376 | 376 |
377 if (pos < 0) | 377 if (pos < 0) |
378 { | 378 { |
404 static FLAC__bool eof_callback( | 404 static FLAC__bool eof_callback( |
405 const decoder_t *decoder, | 405 const decoder_t *decoder, |
406 void *client_data) | 406 void *client_data) |
407 { | 407 { |
408 flac_t *f = (flac_t *) client_data; | 408 flac_t *f = (flac_t *) client_data; |
409 int pos; /* !!! FIXME: int? Really? */ | 409 int pos; |
410 | 410 |
411 /* Maybe we could check for SOUND_SAMPLEFLAG_EOF here instead? */ | 411 /* Maybe we could check for SOUND_SAMPLEFLAG_EOF here instead? */ |
412 pos = SDL_RWtell(f->rw); | 412 pos = SDL_RWtell(f->rw); |
413 | 413 |
414 if (pos >= 0 && pos >= f->stream_length) | 414 if (pos >= 0 && pos >= f->stream_length) |
511 f->is_flac = 0 /* !!! FIXME: should be "has_extension", not "0". */; | 511 f->is_flac = 0 /* !!! FIXME: should be "has_extension", not "0". */; |
512 | 512 |
513 internal->decoder_private = f; | 513 internal->decoder_private = f; |
514 d_init(decoder); | 514 d_init(decoder); |
515 | 515 |
516 #if !SOUND_SUPPORTS_SEEKABLE_FLAC | 516 sample->flags = SOUND_SAMPLEFLAG_NONE; |
517 | |
518 #if SOUND_SUPPORTS_SEEKABLE_FLAC | |
519 | |
520 pos = SDL_RWtell(f->rw); | |
521 if (SDL_RWseek(f->rw, 0, SEEK_END) > 0) | |
522 { | |
523 f->stream_length = SDL_RWtell(f->rw); | |
524 if (SDL_RWseek(f->rw, pos, SEEK_SET) == -1) | |
525 { | |
526 free_flac(f); | |
527 BAIL_MACRO(ERR_IO_ERROR, 0); | |
528 } /* if */ | |
529 sample->flags = SOUND_SAMPLEFLAG_CANSEEK; | |
530 } /* if */ | |
531 | |
532 #else | |
533 | |
517 /* | 534 /* |
518 * Annoyingly, the rewind method will put the FLAC decoder in a state | 535 * Annoyingly, the rewind method will put the FLAC decoder in a state |
519 * where it expects to read metadata, so we have to set this marker | 536 * where it expects to read metadata, so we have to set this marker |
520 * before the metadata block. | 537 * before the metadata block. |
521 */ | 538 */ |
522 f->data_offset = SDL_RWtell(f->rw); | 539 f->data_offset = SDL_RWtell(f->rw); |
540 | |
523 #endif | 541 #endif |
524 | 542 |
525 sample->flags = SOUND_SAMPLEFLAG_NONE; | |
526 | |
527 #if SOUND_SUPPORTS_SEEKABLE_FLAC | |
528 /* | |
529 * FIXME?: For the seekable stream decoder to work, we need to know | |
530 * the length of the stream. This is so ugly... | |
531 */ | |
532 pos = SDL_RWtell(f->rw); | |
533 if (SDL_RWseek(f->rw, 0, SEEK_END)) | |
534 { | |
535 f->stream_length = SDL_RWtell(f->rw); | |
536 SDL_RWseek(f->rw, pos, SEEK_SET); | |
537 sample->flags = SOUND_SAMPLEFLAG_CANSEEK; | |
538 } /* if */ | |
539 #endif | |
540 | 543 |
541 /* | 544 /* |
542 * If we are not sure this is a FLAC stream, check for the STREAMINFO | 545 * If we are not sure this is a FLAC stream, check for the STREAMINFO |
543 * metadata block. If not, we'd have to peek at the first audio frame | 546 * metadata block. If not, we'd have to peek at the first audio frame |
544 * and get the sound format from there, but that is not yet | 547 * and get the sound format from there, but that is not yet |