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

发布于 2024-11-04 20:46:14 字数 4388 浏览 2 评论 0原文

我正在尝试使用以下代码播放 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               
        }
}

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

位于(包装器托管到本机)MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend(intptr,intptr) 在 MonoTouch.Foundation.NSObject/MonoTouch_Disposer.Drain (MonoTouch.Foundation.NSObject) [0x0002a] 在 /Users/plasma/Source/iphone/monotouch/Foundation/NSObject.cs:305 at (包装运行时调用) .runtime_invoke_void_this__object (object,intptr,intptr,intptr) at (包装器托管到本机) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) 在 /Users/plasma/Source/iphone/monotouch/UIKit/UIApplication.cs:26 中的 MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00038] 在 /Users/plasma/Source/iphone/monotouch/UIKit/UIApplication.cs:31 中的 MonoTouch.UIKit.UIApplication.Main (string[]) [0x00000] 在 /Users/fencer04/Projects/MonkeyShot/MonkeyShot/Main.cs:14 中的 MonkeyShot.Application.Main (string[]) [0x00000] 在(包装器运行时调用).runtime_invoke_void_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。这通常表明 本机库之一中的致命错误。

单声道运行时或应用程序使用的

I am trying to play an mp3 file with the following code.

 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               
        }
}

This is the error I get:
Stacktrace:

at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend (intptr,intptr)
at MonoTouch.Foundation.NSObject/MonoTouch_Disposer.Drain (MonoTouch.Foundation.NSObject) [0x0002a] in /Users/plasma/Source/iphone/monotouch/Foundation/NSObject.cs:305
at (wrapper runtime-invoke) .runtime_invoke_void_this__object (object,intptr,intptr,intptr)
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00038] in /Users/plasma/Source/iphone/monotouch/UIKit/UIApplication.cs:26
at MonoTouch.UIKit.UIApplication.Main (string[]) [0x00000] in /Users/plasma/Source/iphone/monotouch/UIKit/UIApplication.cs:31
at 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)

Native stacktrace:

    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

Debug info from gdb:

/tmp/mono-gdb-commands.0GDVJY:1: Error in sourced command file:
unable to debug self

===============================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries

used by your application.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

就此别过 2024-11-11 20:46:14

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

I don't know if this is your issue, but I had some issues using the C#-style delegate methods and AVAudioPlayer. If this is similar to my issue, using the "WeakDelegate" construct and exporting methods might be useful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文