4

我有一个我编写的 C# 程序,它在 windows 和单声道下运行良好,除了我无法从 Mono 中获得任何声音。我知道 64 位机器和 .Net 无法发出系统哔声的问题,所以我们不要对此感到困惑!

我已经在几台运行 Ubuntu Quantal 和 Raring 的不同 Linux 机器上进行了尝试,并使用了普通的单声道版本,没有声音,也没有错误。

所以我从源代码编译了 3.0.12 版本,并且我尝试过的两个 3.x 版本都崩溃了。

因此,这是导致它崩溃的 C# 行:

System.Media.SoundPlayer tagbeep = new System.Media.SoundPlayer("beep.wav");
                                tagbeep.Load(); 
                                if (tagbeep.IsLoadCompleted) 
                        {

                            Console.WriteLine("I just beeped");
                            tagbeep.Play();

                        }

这是导致此问题的 Mono 版本:

(我也尝试过 3.0.6,结果相同)

Mono JIT compiler version 3.0.12 ((no/d6c5db8 Tue Jun 25 11:21:40 WST 2013)
Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug 
        LLVM:          supported, not enabled.
        GC:            Included Boehm (with typed GC and Parallel Mark)

因此,这是 Mono 崩溃时的输出:

*** Error in `mono': double free or corruption (fasttop): 0x00007f25d002b9b0 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6[0x35ca080a46]
[0x4139f32b]
======= Memory map: ========
00400000-0073b000 r-xp 00000000 08:02 2820404                            /usr/local/bin/mono
0093a000-0093b000 r--p 0033a000 08:02 2820404                            /usr/local/bin/mono
0093b000-00944000 rw-p 0033b000 08:02 2820404                            /usr/local/bin/mono
00944000-0097f000 rw-p 00000000 00:00 0 
0239f000-02758000 rw-p 00000000 00:00 0                                  [heap]
40006000-40017000 rwxp 00000000 00:00 0 
40074000-40085000 rwxp 00000000 00:00 0 
40867000-40868000 r--p 00000000 00:00 0 
409aa000-409ab000 ---p 00000000 00:00 0 
409c4000-409d5000 rwxp 00000000 00:00 0 
41235000-41246000 rwxp 00000000 00:00 0 
41395000-413a6000 rwxp 00000000 00:00 0 
41a2c000-41a3d000 rwxp 00000000 00:00 0 
41b02000-41b13000 rwxp 00000000 00:00 0 
35c9c00000-35c9c23000 r-xp 00000000 08:02 352268                         /lib/x86_64-linux-gnu/ld-2.17.so
35c9e22000-35c9e23000 r--p 00022000 08:02 352268                         /lib/x86_64-linux-gnu/ld-2.17.so
35c9e23000-35c9e25000 rw-p 00023000 08:02 352268                         /lib/x86_64-linux-gnu/ld-2.17.so
35ca000000-35ca1be000 r-xp 00000000 08:02 352284                         /lib/x86_64-linux-gnu/libc-2.17.so
35ca1be000-35ca3bd000 ---p 001be000 08:02 352284                         /lib/x86_64-linux-gnu/libc-2.17.so
35ca3bd000-35ca3c1000 r--p 001bd000 08:02 352284                         /lib/x86_64-linux-gnu/libc-2.17.so
35ca3c1000-35ca3c3000 rw-p 001c1000 08:02 352284                         /lib/x86_64-linux-gnu/libc-2.17.so
35ca3c3000-35ca3c8000 rw-p 00000000 00:00 0 
35ca400000-35ca403000 r-xp 00000000 08:02 352540                         /lib/x86_64-linux-gnu/libdl-2.17.so
35ca403000-35ca602000 ---p 00003000 08:02 352540                         /lib/x86_64-linux-gnu/libdl-2.17.so
35ca602000-35ca603000 r--p 00002000 08:02 352540                         /lib/x86_64-linux-gnu/libdl-2.17.so
35ca603000-35ca604000 rw-p 00003000 08:02 352540                         /lib/x86_64-linux-gnu/libdl-2.17.so
35ca800000-35ca818000 r-xp 00000000 08:02 352538                         /lib/x86_64-linux-gnu/libpthread-2.17.so
35ca818000-35caa17000 ---p 00018000 08:02 352538                         /lib/x86_64-linux-gnu/libpthread-2.17.so
35caa17000-35caa18000 r--p 00017000 08:02 352538                         /lib/x86_64-linux-gnu/libpthread-2.17.so
35caa18000-35caa19000 rw-p 00018000 08:02 352538                         /lib/x86_64-linux-gnu/libpthread-2.17.so
35caa19000-35caa1d000 rw-p 00000000 00:00 0 
35cb000000-35cb103000 r-xp 00000000 08:02 352544                         /lib/x86_64-linux-gnu/libm-2.17.so
35cb103000-35cb303000 ---p 00103000 08:02 352544                         /lib/x86_64-linux-gnu/libm-2.17.so
35cb303000-35cb304000 r--p 00103000 08:02 352544                         /lib/x86_64-linux-gnu/libm-2.17.so
35cb304000-35cb305000 rw-p 00104000 08:02 352544                         /lib/x86_64-linux-gnu/libm-2.17.so
35cbc00000-35cbc07000 r-xp 00000000 08:02 352547                         /lib/x86_64-linux-gnu/librt-2.17.so
35cbc07000-35cbe06000 ---p 00007000 08:02 352547                         /lib/x86_64-linux-gnu/librt-2.17.so
35cbe06000-35cbe07000 r--p 00006000 08:02 352547                         /lib/x86_64-linux-gnu/librt-2.17.so
35cbe07000-35cbe08000 rw-p 00007000 08:02 352547                         /lib/x86_64-linux-gnu/librt-2.17.so
35cc000000-35cc016000 r-xp 00000000 08:02 352543                         /lib/x86_64-linux-gnu/libresolv-2.17.so
35cc016000-35cc216000 ---p 00016000 08:02 352543                         /lib/x86_64-linux-gnu/libresolv-2.17.so
35cc216000-35cc217000 r--p 00016000 08:02 352543                         /lib/x86_64-linux-gnu/libresolv-2.17.so
35cc217000-35cc218000 rw-p 00017000 08:02 352543                         /lib/x86_64-linux-gnu/libresolv-2.17.so
35cc218000-35cc21a000 rw-p 00000000 00:00 0 
35cd400000-35cd402000 r-xp 00000000 08:02 2736244                        /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
35cd402000-35cd602000 ---p 00002000 08:02 2736244                        /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
35cd602000-35cd603000 r--p 00002000 08:02 2736244                        /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
35cd603000-35cd604000 rw-p 00003000 08:02 2736244                        /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
35cd800000-35cd805000 r-xp 00000000 08:02 2736245                        /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
35cd805000-35cda04000 ---p 00005000 08:02 2736245                        /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
35cda04000-35cda05000 r--p 00004000 08:02 2736245                        /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
35cda05000-35cda06000 rw-p 00005000 08:02 2736245                        /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
35ce400000-35ce414000 r-xp 00000000 08:02 352548                         /lib/x86_64-linux-gnu/libgcc_s.so.1
35ce414000-35ce614000 ---p 00014000 08:02 352548                         /lib/x86_64-linux-gnu/libgcc_s.so.1
35ce614000-35ce615000 r--p 00014000 08:02 352548                         /lib/x86_64-linux-gnu/libgcc_s.so.1
35ce615000-35ce616000 rw-p 00015000 08:02 352548                         /lib/x86_64-linux-gnu/libgcc_s.so.1
35dc000000-35dc0a7000 r-xp 00000000 08:02 2736411                        /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6
35dc0a7000-35dc2a7000 ---p 000a7000 08:02 2736411                        /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6
35dc2a7000-35dc2a9000 r--p 000a7000 08:02 2736411                        /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6
35dc2a9000-35dc2ab000 rw-p 000a9000 08:02 2736411                        /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6
35dc2ab000-35dc2ac000 rw-p 00000000 00:00 0 
35df400000-35df417000 r-xp 00000000 08:02 352691                         /lib/x86_64-linux-gnu/libnsl-2.17.so
35df417000-35df616000 ---p 00017000 08:02 352691                         /lib/x86_64-linux-gnu/libnsl-2.17.so
35df616000-35df617000 r--p 00016000 08:02 352691                         /lib/x86_64-linux-gnu/libnsl-2.17.so
35df617000-35df618000 rw-p 00017000 08:02 352691                         /lib/x86_64-linux-gnu/libnsl-2.17.so
35df618000-35df61a000 rw-p 00000000 00:00 0 
35df800000-35df82b000 r-xp 00000000 08:02 2736895                        /usr/lib/x86_64-linux-gnu/libvorbis.so.0.4.5Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) Mono.Audio.AlsaDevice.snd_pcm_hw_params_free (intptr) <0xffffffff>
  at Mono.Audio.AlsaDevice.Dispose (bool) <0x00057>
  at Mono.Audio.AlsaDevice.Finalize () <0x0001d>
  at (wrapper runtime-invoke) object.runtime_invoke_virtual_void__this__ (object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

        mono() [0x4a9091]
        /lib/x86_64-linux-gnu/libpthread.so.0() [0x35ca80fbd0]
        /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x37) [0x35ca037037]
        /lib/x86_64-linux-gnu/libc.so.6(abort+0x148) [0x35ca03a698]
        /lib/x86_64-linux-gnu/libc.so.6() [0x35ca0745ab]
        /lib/x86_64-linux-gnu/libc.so.6() [0x35ca080a46]
        [0x4139f32b]

Debug info from gdb:

Assertion 'pa_atomic_load(&(c)->_ref) >= 1' failed at pulse/context.c:1428, function pa_context_rttime_restart(). Aborting.
Aborted

把它放在这里感觉有点奇怪,但我是被 Mono 网站引导到这里的。这是我的第一篇文章,我检查了重复项,希望有人能提供帮助。

即使您无法解决这个确切的问题,我也很想知道如何使单声道系统发出哔哔声或在 64 位机器上播放哔声。

更新:

我找到了一种不圣洁的方法来做到这一点。

System.Diagnostics.Process proc = new System.Diagnostics.Process();
                            proc.EnableRaisingEvents=false; 
                            proc.StartInfo.FileName = "aplay";
                            proc.StartInfo.Arguments = "-t wav beep.wav";
                            proc.Start();
4

0 回答 0