From ada35fd2a0ab335fd532b8543366346fd12e18d0 Mon Sep 17 00:00:00 2001
From: johns <>
Date: Thu, 8 Mar 2001 10:10:43 +0000
Subject: [PATCH] Fixed bug: Core dumped if SoundFildes==-1.

---
 src/video/X11.cpp     |  6 +++---
 src/video/sdl.cpp     | 10 +++++-----
 src/video/svgalib.cpp |  4 ++--
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/video/X11.cpp b/src/video/X11.cpp
index 85df3fc60..0dcaf2ed9 100644
--- a/src/video/X11.cpp
+++ b/src/video/X11.cpp
@@ -798,7 +798,7 @@ global void WaitEventsAndKeepSync(void)
 	//
 	//	Sound
 	//
-	if( !SoundOff && !SoundThreadRunning ) {
+	if( !SoundOff && !SoundThreadRunning && SoundFildes!=-1 ) {
 	    if( SoundFildes>maxfd ) {
 		maxfd=SoundFildes;
 	    }
@@ -852,8 +852,8 @@ global void WaitEventsAndKeepSync(void)
 	    //
 	    //	Sound
 	    //
-	    if( !SoundOff && !SoundThreadRunning
-			&& FD_ISSET(SoundFildes,&wfds) ) {
+	    if( !SoundOff && !SoundThreadRunning && SoundFildes!=-1 
+		    && FD_ISSET(SoundFildes,&wfds) ) {
 		WriteSound();
 	    }
 
diff --git a/src/video/sdl.cpp b/src/video/sdl.cpp
index 5f2a3ab58..28155fb9b 100644
--- a/src/video/sdl.cpp
+++ b/src/video/sdl.cpp
@@ -220,7 +220,7 @@ global void InitVideoSdl(void)
 #endif
 #endif
 
-    DebugLevel0Fn("Video init ready %d %d\n",VideoDepth,VideoBpp);
+    DebugLevel3Fn("Video init ready %d %d\n",VideoDepth,VideoBpp);
 }
 
 /**
@@ -569,11 +569,11 @@ global void WaitEventsAndKeepSync(void)
 	    }
 	}
 
-#ifndef USE_WIN32
+#ifndef USE_SDLA
 	//
 	//	Sound
 	//
-	if( !SoundOff && !SoundThreadRunning ) {
+	if( !SoundOff && !SoundThreadRunning && SoundFildes!=-1 ) {
 	    if( SoundFildes>maxfd ) {
 		maxfd=SoundFildes;
 	    }
@@ -596,11 +596,11 @@ global void WaitEventsAndKeepSync(void)
 	}
 
 	if( maxfd>0 ) {
-#ifndef USE_WIN32
+#ifndef USE_SDLA
 	    //
 	    //	Sound
 	    //
-	    if( !SoundOff && !SoundThreadRunning
+	    if( !SoundOff && !SoundThreadRunning && SoundFildes!=-1 
 			&& FD_ISSET(SoundFildes,&wfds) ) {
 		WriteSound();
 	    }
diff --git a/src/video/svgalib.cpp b/src/video/svgalib.cpp
index 471b22309..647c67a26 100644
--- a/src/video/svgalib.cpp
+++ b/src/video/svgalib.cpp
@@ -975,7 +975,7 @@ global void WaitEventsAndKeepSync(void)
 	//
 	//	Sound
 	//
-	if(!SoundOff && !SoundThreadRunning) {
+	if( !SoundOff && !SoundThreadRunning && SoundFildes!=-1 ) {
 	    FD_SET(SoundFildes, &wfds);
 	}
 
@@ -985,7 +985,7 @@ global void WaitEventsAndKeepSync(void)
 	    //
 	    //	Sound
 	    //
-	    if(!SoundOff && !SoundThreadRunning
+	    if(!SoundOff && !SoundThreadRunning && SoundFildes!=-1 
 			&& FD_ISSET(SoundFildes, &wfds)) {
 		WriteSound();
 	    }