rnd-20001104-1-src
authorHolger Schemel <info@artsoft.org>
Sat, 4 Nov 2000 16:59:10 +0000 (17:59 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:35:01 +0000 (10:35 +0200)
CHANGES
src/init.c
src/sound.c
src/sound.h

diff --git a/CHANGES b/CHANGES
index bb830209d4660ea6092c5c926e4a9dcfc695e405..c8ad050dc4b5a473a256f69ff936b921eeb13a4a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,9 @@
+Version 1.5.0
+-------------
+       - SDL!!!
+       - trying to open already busy audio device does not block the game
 
-Release Version 1.3.5 [?? SEP 1999]
+Release Version 1.4.0 [27 OCT 1999]
 -----------------------------------
        - new Boulderdash elements for better game emulation
        - new cool medium-sized crystal font
index 4d3a034ddb626e79c8528a4c4d435abcfd985856..941881f3218f6126181cfad12fc76d15217e020a 100644 (file)
@@ -193,7 +193,7 @@ void InitSound()
     return;
   }
 
-  if ((sound_device = open(sound_device_name,O_WRONLY))<0)
+  if ((sound_device = OpenAudio(sound_device_name)) < 0)
   {
     Error(ERR_WARN, "cannot open sound device - no sounds");
     sound_status = SOUND_OFF;
index 6db2f63329a54bab3a1575982463ac276abd13ec..1ab2b8c5f7c748cb732a56ced661cf349c30d02e 100644 (file)
@@ -54,6 +54,21 @@ static void SoundServer_StopSound(int);
 static void SoundServer_StopAllSounds();
 #endif
 
+int OpenAudio(char *audio_device_name)
+{
+  int audio_fd;
+
+  /* try to open audio device in non-blocking mode */
+  if ((audio_fd = open(audio_device_name, O_WRONLY | O_NONBLOCK)) < 0)
+    return audio_fd;
+
+  /* re-open audio device in blocking mode */
+  close(audio_fd);
+  audio_fd = open(audio_device_name, O_WRONLY);
+
+  return audio_fd;
+}
+
 void SoundServer()
 {
   int i;
@@ -144,7 +159,8 @@ void SoundServer()
       int sample_rate = 22050;
 #endif
 
-      if (playing_sounds || (sound_device=open(sound_device_name,O_WRONLY))>=0)
+      if (playing_sounds ||
+         (sound_device = OpenAudio(sound_device_name)) >= 0)
       {
        if (!playing_sounds)    /* we just opened the audio device */
        {
@@ -306,7 +322,7 @@ void SoundServer()
       int wait_percent = 90;   /* wait 90% of the real playing time */
       int i;
 
-      if ((sound_device=open(sound_device_name,O_WRONLY))>=0)
+      if ((sound_device = OpenAudio(sound_device_name)) >= 0)
       {
        playing_sounds = 1;
 
index dada0e89bcba1beefc78c3ed93163a1abc3725ab..6eb0dad26bf408e5371c6deded9c7d39c34ac260 100644 (file)
@@ -160,6 +160,7 @@ struct SoundControl
 };
 
 /* start sound server */
+int OpenAudio(char *);
 void SoundServer(void);
 
 /* client functions */