Mercurial > SDL_sound_CoreAudio
changeset 583:fbb3f1abdd9e
Automated merge with http://hg.assembla.com/SDL_sound_CoreAudio
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Tue, 09 Nov 2010 12:11:56 -0500 |
parents | 6927c489964c (diff) 05a7b1d35ba9 (current diff) |
children | 2e5e01679f32 4b741aa1dd28 |
files | decoders/quicktime.c |
diffstat | 1 files changed, 22 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/decoders/coreaudio.c Fri Oct 29 03:39:46 2010 -0400 +++ b/decoders/coreaudio.c Tue Nov 09 12:11:56 2010 -0500 @@ -582,6 +582,7 @@ Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; CoreAudioFileContainer* core_audio_file_container = (CoreAudioFileContainer *) internal->decoder_private; + free(core_audio_file_container->outputFormat); ExtAudioFileDispose(core_audio_file_container->extAudioFileRef); AudioFileClose(*core_audio_file_container->audioFileID); free(core_audio_file_container->audioFileID); @@ -712,7 +713,11 @@ return(1); } /* CoreAudio_rewind */ - +/* Note: I found this tech note: + http://developer.apple.com/library/mac/#qa/qa2009/qa1678.html + I don't know if this applies to us. So far, I haven't noticed the problem, + so I haven't applied any of the techniques. + */ static int CoreAudio_seek(Sound_Sample *sample, Uint32 ms) { OSStatus error_result = noErr; @@ -722,6 +727,16 @@ AudioStreamBasicDescription actual_format; UInt32 format_size; + + /* I'm confused. The Apple documentation says this: + "Seek position is specified in the sample rate and frame count of the file’s audio data format + — not your application’s audio data format." + My interpretation is that I want to get the "actual format of the file and compute the frame offset. + But when I try that, seeking goes to the wrong place. + When I use outputFormat, things seem to work correctly. + I must be misinterpreting the documentation or doing something wrong. + */ +#if 0 /* not working */ format_size = sizeof(AudioStreamBasicDescription); error_result = AudioFileGetProperty( *core_audio_file_container->audioFileID, @@ -736,7 +751,12 @@ } /* if */ // packetIndex = (pos * sampleRate) / framesPerPacket - frame_offset = (SInt64)((ms/1000.0 * actual_format.mSampleRate) / actual_format.mFramesPerPacket); + // frame_offset = (SInt64)((ms/1000.0 * actual_format.mSampleRate) / actual_format.mFramesPerPacket); +#else /* seems to work, but I'm confused */ + // packetIndex = (pos * sampleRate) / framesPerPacket + frame_offset = (SInt64)((ms/1000.0 * core_audio_file_container->outputFormat->mSampleRate) / core_audio_file_container->outputFormat->mFramesPerPacket); +#endif + // computed against actual format and not the client format error_result = ExtAudioFileSeek(core_audio_file_container->extAudioFileRef, frame_offset); if(error_result != noErr)