【问题标题】:iPhone crash when playing audio file using AVAudioPlayer and incoming call interrupts playback使用 AVAudioPlayer 播放音频文件和来电中断播放时 iPhone 崩溃
【发布时间】:2011-06-06 14:01:32
【问题描述】:

我开发了一个可以播放不同音乐文件的 iPhone 应用程序。一切正常,除非来电中断播放。这会使应用程序崩溃并显示以下日志:

开始崩溃日志

Thread 0 Crashed:

0   libobjc.A.dylib                 0x32d98f20 objc_msgSend + 20
1   AVFoundation                    0x30739ddc AVAudioSessionPropertyListener(void*, unsigned long, unsigned long, void const*) + 284
2   AudioToolbox                    0x36d78bec SSServer_AudioSessionInterruptionListenerMessage + 316
3   AudioToolbox                    0x36d017bc _XAudioSessionInterruptionListenerMessage + 128
4   AudioToolbox                    0x36c68584 mshMIGPerform + 224
5   CoreFoundation                  0x3752f5c4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 22
6   CoreFoundation                  0x3752f582 __CFRunLoopDoSource1 + 158
7   CoreFoundation                  0x3752182e __CFRunLoopRun + 574
8   CoreFoundation                  0x37521504 CFRunLoopRunSpecific + 220
9   CoreFoundation                  0x37521412 CFRunLoopRunInMode + 54
10  GraphicsServices                0x33e76d1c GSEventRunModal + 188
11  UIKit                           0x3591d574 -[UIApplication _run] + 580
12  UIKit                           0x3591a550 UIApplicationMain + 964

结束崩溃日志

我已将其缩小到应用程序委托中的 applicationWillResignActive 方法中的调用,但我似乎无法弄清楚,因为如果应用程序进入后台模式(通过按下主页按钮)应用程序正常工作,它只在接到电话时崩溃。

导致 applicationWillResignActive 方法崩溃的行是:

[navController popToRootViewControllerAnimated:NO]; //navController 是 UINavigationController 的一个实例;我使用此语句删除了所有视图控制器,当应用程序恢复时,我推送第一个视图控制器,以便应用程序从头开始。

有谁知道为什么只有在接到电话时才会发生这种崩溃?

【问题讨论】:

    标签: iphone audio crash multitasking


    【解决方案1】:

    我们刚刚跟踪了一次非常相似的崩溃。

    我们的结果如下所述:

    https://github.com/mattgallagher/AudioStreamer/issues/6

    特别是 MyAudioSessionInterruptionListener(或传递给 AudioSessionInitialize) 并且它的 inClientData 在注册后无法更改,因此即使底层对象已被释放,回调也必须始终做一些明智的事情。

    AudioStream 建议的解决方案是使用静态变量,并确保它指向当前对回调感兴趣的对象,而不是指向已释放的对象 - 重要的是不要使用 inClientData。

    【讨论】:

      猜你喜欢
      • 2017-03-30
      • 1970-01-01
      • 2011-07-21
      • 1970-01-01
      • 2016-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多