I'm writing an iPad app that uses an Audio Queue. I'm running into an error resulting from calling AudioSessionInitialize more than once. I'm trying to find a way to test whether or not AudioSessionInitialize has already been called to avoid this, but so far no luck. Does anyone have a way to do this?

Thanks in advanced.
['https://Stackoverflow.com/questions/11161920', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1475624/']
You could just wrap it in a dispatch\_once block as per:

```
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
    AudioSessionInitialize(NULL, NULL, InterruptionListenerCallback, clientData);
    // Perform other setup here...
});

```

although you may find it easier in the long term to use implicit initialisation of your session and handle events through a delegate, as discussed here:

[Audio Session Programming Guide - Initializing Your Audio Session](http://developer.apple.com/library/ios/#documentation/Audio/Conceptual/AudioSessionProgrammingGuide/Configuration/Configuration.html#//apple_ref/doc/uid/TP40007875-CH3-SW4)
Since the audio session is currently a global property, you could set a C global variable flag when initializing, and then check this global variable before attempting to (re)initialize. However a dispatch\_once block would be less likely to incur race condition bugs if your app is multi-threaded.