[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gnubg] Sound Flags in GNUBg for Win32

From: Nardy Pillards
Subject: [Bug-gnubg] Sound Flags in GNUBg for Win32
Date: Fri, 27 Sep 2002 15:59:30 +0200

(yep, me again)

This is possible:

1. SND_ASYNC (as it is now)
PlaySound() starts playing a wav file, and immediatly returns the control to
the caller (the GNUBg progam).
Advantage: no delays in the program.
Disadvantage: a second call to PlaySound(), stops the first one. Thus: some
sounds are not played, or only for a very short time (time needed to load
the new wav, but is done within 1/10 sec). The exit sound is never played.
Example: Game Resign. The PlaySound ( SOUND_RESIGN) starts playing, but is
immediatly terminated by the call to PlaySound ( SOUND_abc_WIN_GAME )

PlaySound() starts playing a wav file and does not return the control to the
caller, until the sound is finished.
Advantage: all sounds are played. The exit sound plays before the program
Disadvantage: the program has to 'wait' until the sound is played. No prob
for short sounds (less than 1/2 sec), no prob for 'end of game', 'end of
match', but: there is a delay.

PlaySound() starts playing a wav file and returns the contral to the caller.
But: a 2nd (and 3rd, 4th) call to PlaySound() return a 0 value as long as
that first sound is not finished.
Meaning: some sounds will not be played because PlaySound() is still
Example: Game Resign. The PlaySound ( SOUND_RESIGN ) is played, but the
'game won' will not be played because the call PlaySound to (
SOUND_abc_WIN_GAME ) is called before the 'resign' sound is finished.

4. PlaySound ( 0, 0, 0 )
To stop a sound that is played.

5. Sleep (time)
Just to delay the program time/1000th second.

I am not pleased with SND_ASYNC as it is now. Since some sounds are never
played. And the exit sound just produces some kind of 'P'.
It is indeed no solution to change SND_ASYNC to SND_SYNC, since the program
becomes slower, just because sounds are played... and that can not be the
goal of a powerful bacgammon program.

So I thought of this:
Either continue with SND_ASYNC, but put a Sleep (time) wherever a sound
needs to be heard.
Example: PlaySound ( RESIGN ); Sleep ( 500 ); and PlaySound ( EXIT ); Sleep
( 2500 );
( BTW: the SoundWait() after PlaySound ( SOUND_EXIT ) has no effect on
WinME )
Make a call to SND_SYNC for sounds that need to be played, and leave the
SND_ASYNC for all other calls.
Use SND_NOSTOP and put a PlaySound ( 0, 0, 0 ) before sounds that need to be

I could try to test some of these.... but I am not a C-programmer,
if someone of the C-programmers could tell me how to make two functions.
sound.c now has (for Win32):
      PlaySound ( filename, NULL, SND_FILENAME | SND_ASYNC );

What code is needed to make a second function? So that a call to that
function would execute:
      PlaySound ( filename, NULL, SND_FILENAME | SND_SYNC );
or function that executes:
      PlaySound ( 0, 0, 0 );


reply via email to

[Prev in Thread] Current Thread [Next in Thread]