音频错误导致我的 C++ 崩溃程序
我正在使用 C++ 和 SDL/SDL_mixer 编写一个非常简单的游戏。游戏使用了一些简单的音频功能,当有事情发生时会播放声音效果,而我的程序到目前为止一直运行良好。在看似随机的时间,程序将开始发出刺耳的声音和静态噪音(但仍然能够播放声音效果。)我用笔记本电脑的麦克风录制了声音:http://www.mediafire.com/?oe9nrdk9w5r572k。发出声音时,程序可能会崩溃,也可能不会崩溃。我不知道该怎么办。
I'm writing a very simple game with C++ and SDL/SDL_mixer. The game uses some simple audio functions that play sound effects when something happens, and my program has been working fine until now. At a seemingly random time, the program will start making screeching and static noises (but will still be able to play sound effects.) I recorded the sound with my laptop's mic: http://www.mediafire.com/?oe9nrdk9w5r572k. While making the sounds the program may or may not crash. I'm at a loss with what to do.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来存储声音数据的内存区域被覆盖/损坏(导致“噪音”输出)。您的程序因访问冲突而崩溃也表明内存损坏。
确保包含音频数据的缓冲区已正确分配,并且在仍在使用时未被释放/删除/...。
It sounds like the memory area where you store the sound data is overwritten/corrupted (leading to "noise" output). That your program crashes with an access violation also points to memory corruption.
Make sure that the buffer with the audio data is properly allocated and isn't freed/deleted/... while it is still in use.