尝试使用Monotouch在AVAudioPlayer中播放mp3时获取SIGSEGV

时间:2011-05-03 05:19:07

标签: xamarin.ios avaudioplayer iphone-4 sigsegv

我正在尝试使用以下代码播放mp3文件。

 AVAudioPlayer player = new AVAudioPlayer();
 NSUrl mediaFile = NSUrl.FromFilename(monkeySound);
 player = AVAudioPlayer.FromUrl(mediaFile);
 player.Delegate = new PlayerDelegate();
 if(player.PrepareToPlay()){
     player.Play();
 }

private class PlayerDelegate:AVAudioPlayerDelegate {

        public PlayerDelegate(){

        }

        public override void FinishedPlaying (AVAudioPlayer player, bool flag)
        {
            //Some Stuff Done Here               
        }
}

这是我得到的错误: 堆栈跟踪:

at(wrapper managed-to-native)MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend(intptr,intptr)   在/Users/plasma/Source/iphone/monotouch/Foundation/NSObject.cs:30中的MonoTouch.Foundation.NSObject / MonoTouch_Disposer.Drain(MonoTouch.Foundation.NSObject)[0x0002a]   at(wrapper runtime-invoke).runtime_invoke_void_ this __ object(object,intptr,intptr,intptr)   at(包装器托管到原生)MonoTouch.UIKit.UIApplication.UIApplicationMain(int,string [],intptr,intptr)   在MonoTouch.UIKit.UIApplication.Main(string [],string,string)[0x00038] in /Users/plasma/Source/iphone/monotouch/UIKit/UIApplication.cs:26   在/Users/plasma/Source/iphone/monotouch/UIKit/UIApplication.cs:31中的MonoTouch.UIKit.UIApplication.Main(string [])[0x00000]   在MonkeyShot.Application.Main(string [])[0x00000] in /Users/fencer04/Projects/MonkeyShot/MonkeyShot/Main.cs:14   at(wrapper runtime-invoke).runtime_invoke_void_object(object,intptr,intptr,intptr)

原生堆栈跟踪:

    0   MonkeyShot                          0x000d0d25 mono_handle_native_sigsegv + 343
    1   MonkeyShot                          0x0000f6f4 mono_sigsegv_signal_handler + 322
    2   libSystem.B.dylib                   0x992a345b _sigtramp + 43
    3   ???                                 0xffffffff 0x0 + 4294967295
    4   AVFoundation                        0x0047c28d -[AVAudioPlayer privCommonCleanup] + 50
    5   AVFoundation                        0x0047c339 -[AVAudioPlayer dealloc] + 51
    6   ???                                 0x0a2af91c 0x0 + 170588444
    7   ???                                 0x0a2cab1c 0x0 + 170699548
    8   ???                                 0x077520d6 0x0 + 125116630
    9   MonkeyShot                          0x0000f4af mono_jit_runtime_invoke + 1332
    10  MonkeyShot                          0x001ed319 mono_runtime_invoke + 137
    11  MonkeyShot                          0x0029da57 monotouch_trampoline + 2527
    12  Foundation                          0x0140d94e __NSThreadPerformPerform + 251
    13  CoreFoundation                      0x00e9f8ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    14  CoreFoundation                      0x00dfd88b __CFRunLoopDoSources0 + 571
    15  CoreFoundation                      0x00dfcd86 __CFRunLoopRun + 470
    16  CoreFoundation                      0x00dfc840 CFRunLoopRunSpecific + 208
    17  CoreFoundation                      0x00dfc761 CFRunLoopRunInMode + 97
    18  GraphicsServices                    0x0404b1c4 GSEventRunModal + 217
    19  GraphicsServices                    0x0404b289 GSEventRun + 115
    20  UIKit                               0x01cdfc93 UIApplicationMain + 1160
    21  ???                                 0x09d530a3 0x0 + 164966563
    22  ???                                 0x09d52e74 0x0 + 164966004
    23  ???                                 0x09d52474 0x0 + 164963444
    24  ???                                 0x09d522cc 0x0 + 164963020
    25  ???                                 0x09d5241e 0x0 + 164963358
    26  MonkeyShot                          0x0000f4af mono_jit_runtime_invoke + 1332
    27  MonkeyShot                          0x001ed319 mono_runtime_invoke + 137
    28  MonkeyShot                          0x001efa00 mono_runtime_exec_main + 669
    29  MonkeyShot                          0x001eedea mono_runtime_run_main + 843
    30  MonkeyShot                          0x000a3083 mono_jit_exec + 200
    31  MonkeyShot                          0x002a1697 main + 3838
    32  MonkeyShot                          0x00002809 _start + 208
    33  MonkeyShot                          0x00002738 start + 40

来自gdb的调试信息:

/tmp/mono-gdb-commands.0GDVJY:1:源命令文件中出错: 无法调试自己

=============================================== ================ 执行本机代码时获得SIGSEGV。这通常表明 单声道运行时或其中一个本机库中的致命错误

由您的应用程序使用。

1 个答案:

答案 0 :(得分:0)

我不知道这是不是你的问题,但我在使用C#风格的委托方法和AVAudioPlayer时遇到了一些问题。如果这与我的问题类似,使用“WeakDelegate”构造和导出方法可能会有用。