src/audio/alsa/SDL_alsa_audio.c
changeset 942 41a59de7f2ed
parent 939 c7c04f811994
child 1161 05d4b93b911e
--- a/src/audio/alsa/SDL_alsa_audio.c	Sat Aug 21 11:34:24 2004 +0000
+++ b/src/audio/alsa/SDL_alsa_audio.c	Sat Aug 21 12:27:02 2004 +0000
@@ -163,13 +163,15 @@
 
 #endif /* ALSA_DYNAMIC */
 
-static const char *get_audio_device()
+static const char *get_audio_device(int channels)
 {
 	const char *device;
 	
 	device = getenv("AUDIODEV");	/* Is there a standard variable name? */
 	if ( device == NULL ) {
-		device = DEFAULT_DEVICE;
+		if (channels == 6) device = "surround51";
+		else if (channels == 4) device = "surround40";
+		else device = DEFAULT_DEVICE;
 	}
 	return device;
 }
@@ -186,7 +188,7 @@
 	if (LoadALSALibrary() < 0) {
 		return available;
 	}
-	status = SDL_NAME(snd_pcm_open)(&handle, get_audio_device(), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
+	status = SDL_NAME(snd_pcm_open)(&handle, get_audio_device(2), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
 	if ( status >= 0 ) {
 		available = 1;
         	SDL_NAME(snd_pcm_close)(handle);
@@ -319,7 +321,9 @@
 	Uint16               test_format;
 
 	/* Open the audio device */
-	status = SDL_NAME(snd_pcm_open)(&pcm_handle, get_audio_device(), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
+	/* Name of device should depend on # channels in spec */
+	status = SDL_NAME(snd_pcm_open)(&pcm_handle, get_audio_device(spec->channels), SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
+
 	if ( status < 0 ) {
 		SDL_SetError("Couldn't open audio device: %s", SDL_NAME(snd_strerror)(status));
 		return(-1);