Mercurial > SDL_sound_CoreAudio
comparison decoders/aiff.c @ 332:8ba541e81c1e
seek method implementation.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Mon, 20 May 2002 09:41:38 +0000 |
parents | c97be6e1bd27 |
children | d76a34316c84 |
comparison
equal
deleted
inserted
replaced
331:e683cb99f88f | 332:8ba541e81c1e |
---|---|
99 Uint32 data_starting_offset; | 99 Uint32 data_starting_offset; |
100 | 100 |
101 void (*free)(struct S_AIFF_FMT_T *fmt); | 101 void (*free)(struct S_AIFF_FMT_T *fmt); |
102 Uint32 (*read_sample)(Sound_Sample *sample); | 102 Uint32 (*read_sample)(Sound_Sample *sample); |
103 int (*rewind_sample)(Sound_Sample *sample); | 103 int (*rewind_sample)(Sound_Sample *sample); |
104 int (*seek_sample)(Sound_Sample *sample, Uint32 ms); | |
104 | 105 |
105 | 106 |
106 #if 0 | 107 #if 0 |
107 /* | 108 /* |
108 this is ripped from wav.c as ann example of format-specific data. | 109 this is ripped from wav.c as ann example of format-specific data. |
330 /* no-op. */ | 331 /* no-op. */ |
331 return(1); | 332 return(1); |
332 } /* rewind_sample_fmt_normal */ | 333 } /* rewind_sample_fmt_normal */ |
333 | 334 |
334 | 335 |
336 static int seek_sample_fmt_normal(Sound_Sample *sample, Uint32 ms) | |
337 { | |
338 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; | |
339 aiff_t *a = (aiff_t *) internal->decoder_private; | |
340 fmt_t *fmt = &a->fmt; | |
341 int offset = __Sound_convertMsToBytePos(&sample->actual, ms); | |
342 int pos = (int) (fmt->data_starting_offset + offset); | |
343 int rc = SDL_RWseek(internal->rw, pos, SEEK_SET); | |
344 BAIL_IF_MACRO(rc != pos, ERR_IO_ERROR, 0); | |
345 a->bytesLeft = fmt->total_bytes - offset; | |
346 return(1); /* success. */ | |
347 } /* seek_sample_fmt_normal */ | |
348 | |
349 | |
335 static void free_fmt_normal(fmt_t *fmt) | 350 static void free_fmt_normal(fmt_t *fmt) |
336 { | 351 { |
337 /* it's a no-op. */ | 352 /* it's a no-op. */ |
338 } /* free_fmt_normal */ | 353 } /* free_fmt_normal */ |
339 | 354 |
342 { | 357 { |
343 /* (don't need to read more from the RWops...) */ | 358 /* (don't need to read more from the RWops...) */ |
344 fmt->free = free_fmt_normal; | 359 fmt->free = free_fmt_normal; |
345 fmt->read_sample = read_sample_fmt_normal; | 360 fmt->read_sample = read_sample_fmt_normal; |
346 fmt->rewind_sample = rewind_sample_fmt_normal; | 361 fmt->rewind_sample = rewind_sample_fmt_normal; |
362 fmt->seek_sample = seek_sample_fmt_normal; | |
347 return(1); | 363 return(1); |
348 } /* read_fmt_normal */ | 364 } /* read_fmt_normal */ |
349 | 365 |
350 | 366 |
351 | 367 |
507 | 523 |
508 a->fmt.total_bytes = a->bytesLeft = bytes_per_sample * c.numSampleFrames; | 524 a->fmt.total_bytes = a->bytesLeft = bytes_per_sample * c.numSampleFrames; |
509 a->fmt.data_starting_offset = SDL_RWtell(rw); | 525 a->fmt.data_starting_offset = SDL_RWtell(rw); |
510 internal->decoder_private = (void *) a; | 526 internal->decoder_private = (void *) a; |
511 | 527 |
512 sample->flags = SOUND_SAMPLEFLAG_NONE; | 528 sample->flags = SOUND_SAMPLEFLAG_CANSEEK; |
513 | 529 |
514 SNDDBG(("AIFF: Accepting data stream.\n")); | 530 SNDDBG(("AIFF: Accepting data stream.\n")); |
515 return(1); /* we'll handle this data. */ | 531 return(1); /* we'll handle this data. */ |
516 } /* AIFF_open */ | 532 } /* AIFF_open */ |
517 | 533 |
545 } /* AIFF_rewind */ | 561 } /* AIFF_rewind */ |
546 | 562 |
547 | 563 |
548 static int AIFF_seek(Sound_Sample *sample, Uint32 ms) | 564 static int AIFF_seek(Sound_Sample *sample, Uint32 ms) |
549 { | 565 { |
550 BAIL_MACRO("!!! FIXME: Not implemented", 0); | 566 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; |
567 aiff_t *a = (aiff_t *) internal->decoder_private; | |
568 return(a->fmt.seek_sample(sample, ms)); | |
551 } /* AIFF_seek */ | 569 } /* AIFF_seek */ |
552 | 570 |
553 #endif /* SOUND_SUPPORTS_AIFF */ | 571 #endif /* SOUND_SUPPORTS_AIFF */ |
554 | 572 |
555 /* end of aiff.c ... */ | 573 /* end of aiff.c ... */ |