Re: iPhone hardware assisted AAC > PCM conversion using ExtAudioFileRead
Re: iPhone hardware assisted AAC > PCM conversion using ExtAudioFileRead
- Subject: Re: iPhone hardware assisted AAC > PCM conversion using ExtAudioFileRead
- From: David Blake <email@hidden>
- Date: Fri, 25 Jan 2013 18:38:15 +1100
Hi Adriano,
Thanks for your reply.. !
I had a go at changing my AVAudioSession. It was previously set to AVAudioSessionCategoryPlayback (which supports hardware encoding/decoding) but I tried changing it to Ambient (which doesn't) to see if there was any noticeable performance difference. Results did not seem to be any slower than having it set to Playback however. Which leads me to believe that regardless of the AVAudioSession, ExtAudioFile still uses software codec for decoding. All references to hardware assistance with ExtAudioFile that I have come across indeed all point to encoding only. I tried setting hardware codec manually anyway incase they were using encoding and decoding synonymously but it didnt seem to affect performance (see below for code).
UInt32 codec = kAppleHardwareAudioCodecManufacturer;
UInt32 size = sizeof(codec);
result = ExtAudioFileSetProperty(audioFileObject,
kExtAudioFileProperty_CodecManufacturer,
size,
&codec);
if(result) printf("ExtAudioFileSetProperty %ld \n", result);
Only way to get access to hardware decoding I have found is to use AudioQueues, which stop me if I'm wrong you cant use if you are using Audio Units (I presume as queues are just a higher level wrapper for units).
Thinking I might abandon trying to use AAC files and maybe switch to a lighter compression such as IMA4, wont be as small but wont be as huge as PCM either :) hopefully it'll be less cpu heavy to decode.
On 23 January 2013 20:32, Adriano Goncalves
<email@hidden> wrote:
According to this document: http://developer.apple.com/library/ios/documentation/audiovideo/conceptual/multimediapg/multimediaprogrammingguide.pdf
"
When using hardware-assisted decoding, the device can play only a single instance of one of the supported formats at a time. For example, if you are playing a stereo MP3 sound using the hardware codec, a second simultaneous MP3 sound will use software decoding. Similarly, you cannot simultaneously play an AAC and an ALAC sound using hardware. If the iPod application is playing an AAC or MP3 sound in the background, it has claimed the hardware codec; your application then plays AAC, ALAC, and MP3 audio using software decoding.
"
In the same document there's a table with all the formats that support hardware decoding.
Also, I believe you should set your audio session category:
http://developer.apple.com/library/ios/#documentation/Audio/Conceptual/AudioSessionProgrammingGuide/Configuration/Configuration.html
Hope this may help you finding the solution for your question!
Adriano
On 23/01/2013, at 00:46, David Blake <
email@hidden> wrote:
> In my iphone app I have a large number of PCM sound files that can be played at any time. I load the first few frames of each sound file into memory and then as they are played I load the next frames into a buffer that is read by a render callback in remote io.
>
> Problem is these files take up a lot of space and ideally I would like to reduce the size of my app by storing these in a compressed AAC format and decoding this on the fly as needed. Right now I am using ExtAudioFileSeek and ExtAudioFileRead in a background thread to decode the next buffer to be read. When doing this with AAC files right now it pushes the iPhone 4 to its absolute limits when playing the max number of potential sounds at once. I know the iPhone has a hardware decoder for the AAC format - how can I know if this is being used, or is it even possible to use this when doing offline decoding/converting via ExtAudioFileRead ?
>
> If it is using software decoding by default, my hope is that setting ExtAudioFileRead to use the hardware decode might alleviate some of the cpu stress on the iPhone 4.
>
> I have read about the kExtAudioFileProperty_CodecManufacturer / kAppleHardwareAudioCodecManufacturer property that be set on ExtAudioFile but have yet to find example code of applying this that actually works, or if it only applies to encoding and not decoding. Indeed I came across this old thread
http://web.archiveorange.com/archive/v/q7bubfjRLCAE0t1Q38V2 which suggests its encoding only for ExtAudioFileRead. If this is the case are there alternative methods to doing offline hardware assisted decoding of AAC files (that are compatible with my remote io setup) ? If I am to believe that thread than audio queues are the only way to get access to the hardware decoder.
>
> Any advice/help would be greatly appreciated.
>
> Cheers,
> David
>
>
> _______________________________________________
> 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