Re: ExtAudioFileSeek doesn't seek properly in m4a file
Re: ExtAudioFileSeek doesn't seek properly in m4a file
- Subject: Re: ExtAudioFileSeek doesn't seek properly in m4a file
- From: 水鳥 敬満 <email@hidden>
- Date: Sat, 09 Jan 2010 00:25:59 +0900
Hi
I think below is different topic. I tried this "off-setting", but result is the same.
Thanks anyway for the info.
Br.
Taka
On 2010/01/08, at 12:45, uɐıʇəqɐz pnoqɥɒɯ wrote:
> Is this related?
>
> http://developer.apple.com/iphone/library/qa/qa2009/qa1678.html
> <iphone_header_sm_left.png><developer_header_sm.png><header_sm_search.png>
>
>
> ExtAudioFile - ExtAudioFileTell Incorrect Position Work Around
> Technical Q&A QA1678
> ExtAudioFile - ExtAudioFileTell Incorrect Position Work Around
> Q: I'm calling ExtAudioFileTell for a .m4a file containing AAC audio (immediately after I set the client format) and the API returns a value of -2112 instead of 0. Is this a know issue?
> A: ExtAudioFileTell currently always returns a value which is the number of priming-frames too small.
>
> The ExtAudioFile APIs should take care of this priming offset on behalf of the client however, as the AAC bitstream contains 2112 priming frames, ExtAudioFileTell returns a value which is priming-frames too small, in this case -2112 instead of 0 (zero).
>
> The work around requires the client to compensate:
>
> • Make an initial call to ExtAudioFileTell immediately after opening the file and setting the client format.
> • If the returned position is negative, all future calls to ExtAudioFileTell will be off by this value and the client should compensate.
> Note: If the returned position is 0, either the file does not have a priming offset or this issue has been resolved.
> Listing 1: Figure out the offset correction value.
>
> ...
>
> // call ExtAudioFileTell immediately after opening the file and setting the client format
> // and get the correction value to add to all future calls
> SInt64 frameOffset = 0;
> SInt64 frameOffsetCorrection = 0;
>
> ExtAudioFileTell(sourceFile, &frameOffset);
>
> if (frameOffset < 0) frameOffsetCorrection = -frameOffset;
>
> ...
>
> Listing 2: As a general work around always add this correction when calling ExtAudioFileTell.
>
> ...
>
> ExtAudioFileTell(sourceFile, &frameOffset);
> frameOffset += frameOffsetCorrection;
>
> ...
>
> Document Revision History
> Date Notes
> 2009-12-07 New document that discusses how to work around a bug in ExtAudioFileTell where the returned value may be priming-frames too small.
> Posted: 2009-12-07
>
> Did this document help you? Yes It's good, but... Not helpful...
> Shop the Apple Online Store (1-800-MY-APPLE), visit an Apple Retail Store, or find a reseller.
> • Mailing Lists
> • RSS Feeds
>
> Copyright © 2009 Apple Inc. All rights reserved.
> • Terms of Use
> • Privacy Policy
>
> iPhone Dev Center <triangle_closed.png> iPhone OS Reference Library <triangle_closed.png> Audio & Video: Audio
> On Jan 7, 2010, at 7:49 AM, Wil Macaulay wrote:
>
>> I have exactly the same experience.
>>
>> wil
>>
>> 2010/1/7 水鳥 敬満 <email@hidden>:
>>> Hi
>>>
>>> While I'm seeking m4a file with ExtAudioFileSeek, I found strange behavior.
>>> I seek m4a file of 44.1kHz sample rate and I set the sample rate of client format 22.05kHz.
>>> According to Ext Audio Service reference, I should give the frame index of "original file data format" to
>>> ExtAudioFileSeek, so I multiply 2 to client frame index since client data sample rate is half of the 44.1kHz.
>>> So code looks like below.
>>>
>>> ExtAudioFileSeek(xafref, 2 * clientFrameIndex)
>>>
>>> This works perfectly on mp3 file, I can seek to exact position I want and following ExtAudioFileRead load audio data from the position I seeked.
>>> But when I do the same things on m4a file, subsequent ExtAudioFileRead works only until the half of the audio file.
>>> If I seeked beyond the half of the audio file length, ExtAudioFileRead doesn't load any frames.
>>> Since this frame index (i.e. the half of the file) is the end of the file in client data format (since sample rate is half), I guess something is misunderstood inside ExtAudioFileSeek or ExtAudioFileRead.
>>> (When I try to set client data format's frame index (i.e. doesn't multiply 2) in ExtAudioFileSeek, the seeked position is not correct.)
>>>
>>> Does any have similar experience ?
>>> I really appreciate any advice on this topic.
>>>
>>> Best regards.
>>> Taka
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Coreaudio-api mailing list (email@hidden)
>>> Help/Unsubscribe/Update your Subscription:
>>>
>>> This email sent to email@hidden
>>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Coreaudio-api mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden