Block fruity channel values in dspaudio, or the fragment size won't be a SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Sun, 12 Nov 2006 21:23:57 +0000
branchSDL-1.2
changeset 3895 aeb55f698ee3
parent 3894 5a20cffc7027
child 3896 1a327643e741
Block fruity channel values in dspaudio, or the fragment size won't be a power of 2.
src/audio/dsp/SDL_dspaudio.c
--- a/src/audio/dsp/SDL_dspaudio.c	Tue Nov 07 15:17:31 2006 +0000
+++ b/src/audio/dsp/SDL_dspaudio.c	Sun Nov 12 21:23:57 2006 +0000
@@ -168,6 +168,15 @@
 	int frag_spec;
 	Uint16 test_format;
 
+    /* Make sure fragment size stays a power of 2, or OSS fails. */
+    /* I don't know which of these are actually legal values, though... */
+    if (spec->channels > 8)
+        spec->channels = 8;
+    else if (spec->channels > 4)
+        spec->channels = 4;
+    else if (spec->channels > 2)
+        spec->channels = 2;
+
 	/* Open the audio device */
 	audio_fd = SDL_OpenAudioPath(audiodev, sizeof(audiodev), OPEN_FLAGS, 0);
 	if ( audio_fd < 0 ) {