JuceDemo Bug: Audio Related - latest tip (Tue Mar 6 16:03)

I still have a very similiar crash on the iPad 1 with the latest tip. I pause playback and let my app running paused for a long time. Then I unlock the iPad and after my app screen shows, it crashes in juce_ios_Audio.cpp, createAudioUnit() on line 419:
AudioComponentInstanceDispose (audioUnit);

It seems the audioUnit has somehow already been freed during the long pause.

Here is the complete crash report:

Exception Type: SIGSEGV
Exception Codes: SEGV_ACCERR at 0x70
Crashed Thread: 0

Thread 0 Crashed:
0 ??? 0x00000070 0x0 + 0
1 AudioToolbox 0x0001231b AudioComponentInstanceDispose + 15
2 SonicWebRadio 0x00050e68 juce::IPhoneAudioIODevice::createAudioUnit() (juce_ios_Audio.cpp:419)
3 SonicWebRadio 0x000510e0 juce::IPhoneAudioIODevice::routingChanged(void const*) (juce_ios_Audio.cpp:323)
4 SonicWebRadio 0x000513e4 juce::IPhoneAudioIODevice::routingChangedStatic(void*, unsigned long, unsigned long, void const*) (juce_ios_Audio.cpp:401)
5 AudioToolbox 0x000e7307 AudioSessionPropertyListeners::CallPropertyListenersImp(unsigned long, unsigned long, void const*) + 275
6 AudioToolbox 0x000e75e5 AudioSessionPropertyListeners::CallPropertyListeners(unsigned long, unsigned long, void const*) + 241
7 AudioToolbox 0x000e6a09 HandleCFPropertyListChange(unsigned int, unsigned long, unsigned char*, unsigned int) + 437
8 AudioToolbox 0x000e6adb SSServer_AudioSessionPropertyChangedBlobListenerMessage + 203
9 AudioToolbox 0x0008cea9 _XAudioSessionPropertyChangedBlobListenerMessage + 113
10 AudioToolbox 0x00021ce3 mshMIGPerform + 375
11 CoreFoundation 0x0008d523 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 39
12 CoreFoundation 0x0008d4c5 __CFRunLoopDoSource1 + 141
13 CoreFoundation 0x0008c313 __CFRunLoopRun + 1371
14 CoreFoundation 0x0000f4a5 CFRunLoopRunSpecific + 301
15 CoreFoundation 0x0000f36d CFRunLoopRunInMode + 105
16 GraphicsServices 0x00004439 GSEventRunModal + 137
17 UIKit 0x00031e7d UIApplicationMain + 1081
18 SonicWebRadio 0x000033c0 main (main.mm:15)

Ah! Looks like the routing change listener is registered but never de-registered! Try this:

void close() { if (isRunning) { isRunning = false; AudioSessionRemovePropertyListenerWithUserData (kAudioSessionProperty_AudioRouteChange, routingChangedStatic, this); AudioSessionSetActive (false);

I am happy to confirm that this change fixed the crash!

Yes, the latest changes seem to have stopped the outright crashes that used to occur in both the demo and the app that I’m working on. However, Siri still behaves very strangely if used with an active audio device running unless I specifically do a deviceManager.closeAudioDevice() before using it.

Also, if you modify the plist to allow background recording, the background processing not automatically resume at the end of an audio session interruption. This is not such a problem so long as I can put the app into a paused state when the interruption occurs. The user can then go back to the app and enable a running mode again manually. What would be the most elegant way to notify the paused/playing function in my main app code from the interruptionListener member function in juce_ios_Audio.cpp?

Thanks

Thought I'd post this here because I still occasionally get a very similar crash... it's in an app with a mix of JUCE for the audio part and the iOS SDK for all the rest. Any idea what could be going wrong here? I'm using the latest tip...

 

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   AudioToolbox                      0x32d9f368 AudioComponentInstanceDispose + 8
1   Giggler                           0x001c0ce8 juce::iOSAudioIODevice::createAudioUnit() (juce_ios_Audio.cpp:471)
2   Giggler                           0x001c0c3e juce::iOSAudioIODevice::routingChanged(void const*) (juce_ios_Audio.cpp:381)
3   AudioToolbox                      0x32de7b30 AudioSessionPropertyListeners::CallPropertyListenersImp(unsigned long, unsigned long, void const*) + 168
4   AudioToolbox                      0x32de78c8 AudioSessionPropertyListeners::CallPropertyListeners(unsigned long, unsigned long, void const*) + 240
5   AudioToolbox                      0x32e9c180 HandleCFPropertyListChange(unsigned int, unsigned long, unsigned char*, unsigned int) + 200
6   AudioToolbox                      0x32e9c02c HandleAudioSessionPropertyChangedBlobListenerMessage(unsigned int, void*, unsigned int) + 208
7   AudioToolbox                      0x32de7730 ASCallbackReceiver_AudioSessionPropertyChangedBlobListenerMessage + 104
8   AudioToolbox                      0x32de76be _XAudioSessionPropertyChangedBlobListenerMessage + 114
9   AudioToolbox                      0x32de7588 mshMIGPerform + 380
10  CoreFoundation                    0x3338a3e4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
11  CoreFoundation                    0x3338a386 __CFRunLoopDoSource1 + 134
12  CoreFoundation                    0x3338920a __CFRunLoopRun + 1378
13  CoreFoundation                    0x332fc238 CFRunLoopRunSpecific + 352
14  CoreFoundation                    0x332fc0c4 CFRunLoopRunInMode + 100
15  GraphicsServices                  0x36edb336 GSEventRunModal + 70
16  UIKit                             0x352182b4 UIApplicationMain + 1116
17  Giggler                           0x00227996 main (main.mm:10)
18  Giggler                           0x000c8614 ___lldb_unnamed_function1$$Giggler + 36