bug-gnubg
[Top][All Lists]
Advanced

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

[Bug-gnubg] Missing sound file hangs gnubg on Windows


From: Petr Kadlec
Subject: [Bug-gnubg] Missing sound file hangs gnubg on Windows
Date: Thu, 01 Apr 2004 09:03:08 +0200

Hi!
Gnubg waits for the previous sound to finish, but it does it not do that in a 
correct way. If the sound that should be started is missing (or cannot be 
played for whatever reason), gnubg will wait forever. This patch should fix 
that:
Change the WIN32 part of play_file_child() in sound.c to:

    case SOUND_SYSTEM_WINDOWS:

#ifdef WIN32
        SetLastError(0);
        while (!PlaySound(filename, NULL, SND_FILENAME | SND_ASYNC | SND_NOSTOP 
| SND_NODEFAULT) &&
               !GetLastError()) {
            Sleep(1); /* Wait (1ms) for previous sound to finish */
            SetLastError(0);
        }
#else
      assert ( FALSE );
#endif
      break;

The GetLastError() call should do the trick, as PlaySound seems to set the 
"last error" variable if it does not find the file (although it is not 
explicitly mentioned in the documentation).

Petr








reply via email to

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