1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
--- kxl-1.1.7.orig/src/KXLsound.c
+++ kxl-1.1.7/src/KXLsound.c
@@ -22,7 +25,7 @@
struct {
Uint16 ListCnt;
Sint32 ID;
- Sint32 Pipe[2];
+ int Pipe[2];
Sint32 Device;
Uint16 PlayCnt;
KXL_SoundControl PlaySound[MAX_SOUNDS_PLAYING];
@@ -242,11 +245,19 @@
KXL_SoundOk = False;
KXL_LoadSoundData(path, fname);
- // device check
- if ((KXL_SoundData.Device = open("/dev/dsp", O_WRONLY)) == -1) {
- fprintf(stderr, "KXL error message\nnot found sound card\n");
+ // Open the sound device in non-blocking mode, because ALSA's OSS
+ // emulation and some broken OSS drivers would make a blocking call
+ // wait forever until the device is available. Since this breaks the
+ // OSS spec, we immediately put it back to blocking mode if the
+ // operation was successful.
+ KXL_SoundData.Device = open("/dev/dsp", O_WRONLY|O_NDELAY);
+ if (KXL_SoundData.Device < 0) {
+ fprintf(stderr, "KXL error message\ncould not open sound card (%s)\n",
+ strerror(errno));
return;
}
+ fcntl( KXL_SoundData.Device, F_SETFL,
+ fcntl( KXL_SoundData.Device, F_GETFL ) &~ FNDELAY );
// create pipe
if (pipe(KXL_SoundData.Pipe) < 0) {
fprintf(stderr, "KXL error message\npipe error\n");
|