SndPlaySound导致崩溃 [英] SndPlaySound causing crashes

查看:171
本文介绍了SndPlaySound导致崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


*手指交叉,新闻服务器的工作时间足够让我看到任何

回复!! *


我在VB.NET中使用SndPlaySound与SND_ASYNC和SND_MEMORY

时遇到了崩溃。声音从嵌入式资源加载并存储到字节数组中,然后存储在哈希表中以便于第二次检索。偶尔会得到一个有趣的嘟嘟声。声音和

应用程序崩溃,报告告诉我它来自winmm.dll。

我能找到的唯一参考此崩溃是

http://ftp.tuniv.szczecin.pl/pub/win...P/w32s125a.txt


但这是指 MICROSOFT WIN32S UPGRADE"。关于

这个的任何想法?我刚刚制作了我的第一场比赛并且声音一直在制造它

崩溃:-(


尼克。


-

/ \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \\ \\ / \ / \ / \ / \ / \ / \ / \ / \ / \\ \\

无论如何。无论结果如何,您都会被更改。 ;


Fergus - 2003年9月5日

/ \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \\ \\ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \

解决方案

" Nak"< a@a.com> scripsit:

当SNDPlaySound与SND_AS一起使用时,我遇到了崩溃在VB.NET中使用YNC和SND_MEMORY。声音从嵌入式资源加载并存储到字节数组中,然后存储在哈希表中以便于第二次检索。偶尔a得到一个有趣的嘟嘟声并且应用程序崩溃了,报告告诉我它来自winmm.dll。
我能找到的唯一参考是



此示例是否适合您?


< http://www.google.de/groups?selm = exQuKMjfDHA。 1712%40TK2MSFTNGP11.phx.gb l>


请注意'sndPlaySound''不应该再使用了,它只有

可用于兼容旧应用程序。


-

Herfried K. Wagner

MVP·VB Classic,VB.NET
< http://www.mvps.org/dotnet>




听起来这可能是由于GC在
$ b中移动字节数组$ b内存,从而使您传递给指针的指针无效

sndPlaySound。但是,如果没有看到你的代码我就不能肯定。


Mattias


-

Mattias Sj?gren [MVP] mattias @ mvps.org
http:// www。 msjogren.net/dotnet/

请回复新闻组。


Hi Herfried,

此示例是否适合您?


非常好,非常感谢,即使使用我的缓存方法,它仍然有效。我之前使用过的
是没有传递指针,而是整个字节数组,

也许这就是为什么它如此容易失败?

请注意,'sndPlaySound''不应该再使用,它​​只能与旧应用程序兼容。




你会推荐什么用?我不想出于某种原因使用DirectX,

即使我已经开发了类似的类增加了

功能,我的游戏是沼泽标准,所以我做了bog

标准方式:-)


尼克。


-

/ \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \\ \\ / \

无论如何。无论结果如何,你都会被改变。


Fergus - 2003年9月5日

/ \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \\ \\ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \


Hi there,

*fingers crossed that the newsserver works long enough for me to see any
replies to this!!*

I''m having crashes when using SndPlaySound with SND_ASYNC and SND_MEMORY
in VB.NET. The sounds are being loaded from embedded resources and stored
into byte arrays, which are then being stored in a hashtable for easy
retrieval second time around. Occasionally a get a funny "beep" sound and
the application crashes, the report tells me that it comes from "winmm.dll".
The only reference I could find to this crash was

http://ftp.tuniv.szczecin.pl/pub/win...P/w32s125a.txt

But that is in reference to "MICROSOFT WIN32S UPGRADE". Any ideas on
this one? I''ve just made my first ever game and the sounds keep making it
crash :-(

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

解决方案

"Nak" <a@a.com> scripsit:

I''m having crashes when using SndPlaySound with SND_ASYNC and SND_MEMORY
in VB.NET. The sounds are being loaded from embedded resources and stored
into byte arrays, which are then being stored in a hashtable for easy
retrieval second time around. Occasionally a get a funny "beep" sound and
the application crashes, the report tells me that it comes from "winmm.dll".
The only reference I could find to this crash was



Does this sample work for you?

<http://www.google.de/groups?selm=exQuKMjfDHA.1712%40TK2MSFTNGP11.phx.gb l>

Notice that ''sndPlaySound'' should not be used any more, it''s only
available for compatibility with old applications.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>



It sounds like this could be caused by the GC moving the byte array in
memory, and thereby invalidating the pointer you''ve passed to
sndPlaySound. But I can''t say for sure without seeing your code.

Mattias

--
Mattias Sj?gren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.


Hi Herfried,

Does this sample work for you?
Excellent, thank you, it works a treat, even with my caching method. The
one I was using previously wasn''t passing a pointer, but a whole byte array,
maybe that is why it was failing so easily?
Notice that ''sndPlaySound'' should not be used any more, it''s only
available for compatibility with old applications.



What would you recommend using? I didn''t want to use DirectX for a reason,
even though I have already developed similar classes with increased
functionality, my game is "bog standard", so I have done it the "bog
standard" way :-)

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\


这篇关于SndPlaySound导致崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆