开发者

Sound Multithreading

开发者 https://www.devze.com 2023-03-11 17:39 出处:网络
I want to play sound while a game is running. I know how to play sound and run the game, but I can\'t do them at the same time. The DOS game pauses while the sound is playing. Here is the cpp code for

I want to play sound while a game is running. I know how to play sound and run the game, but I can't do them at the same time. The DOS game pauses while the sound is playing. Here is the cpp code for the sound:

void watersplashsound()
{PlaySound(TEXT("waterSPLASH.wav"), NULL, SND_FILENAME);}

I don't know if it is a situation where开发者_StackOverflow社区 you have to multithread. I think I know what multithreading is but I'm not sure.


Playsound needs another flag to not run synchronously. Call it like this:

void watersplashsound()
{
  PlaySound(TEXT("waterSPLASH.wav"), NULL, SND_FILENAME | SND_ASYNC);
}

Notice that i have no idea how to stop the sound until it finishes.

0

精彩评论

暂无评论...
验证码 换一张
取 消