]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_sdl.c
Fix CL_VM_InputeEvent prototype in keys.c
[xonotic/darkplaces.git] / snd_sdl.c
index 90b53129c10947a239375d9e0a59ff007a84cb29..64f0dde64c3870c0db6d171ade524a9e70786282 100644 (file)
--- a/snd_sdl.c
+++ b/snd_sdl.c
@@ -16,11 +16,11 @@ You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
+#include "quakedef.h"
 
 #include <math.h>
 #include <SDL.h>
 
-#include "quakedef.h"
 #include "snd_main.h"
 
 
@@ -38,7 +38,7 @@ static void Buffer_Callback (void *userdata, Uint8 *stream, int len)
                Sys_Error("SDL sound: invalid buffer length passed to Buffer_Callback (%d bytes)\n", len);
 
        RequestedFrames = (unsigned int)len / factor;
-       
+
        // Transfert up to a chunk of samples from snd_renderbuffer to stream
        MaxFrames = snd_renderbuffer->endframe - snd_renderbuffer->startframe;
        if (MaxFrames > RequestedFrames)
@@ -53,7 +53,7 @@ static void Buffer_Callback (void *userdata, Uint8 *stream, int len)
 
                PartialLength1 = (snd_renderbuffer->maxframes - StartOffset) * factor;
                memcpy(stream, &snd_renderbuffer->ring[StartOffset * factor], PartialLength1);
-               
+
                PartialLength2 = FrameCount * factor - PartialLength1;
                memcpy(&stream[PartialLength1], &snd_renderbuffer->ring[0], PartialLength2);
        }
@@ -62,7 +62,7 @@ static void Buffer_Callback (void *userdata, Uint8 *stream, int len)
 
        snd_renderbuffer->startframe += FrameCount;
 
-       if (FrameCount < RequestedFrames)
+       if (FrameCount < RequestedFrames && developer.integer >= 1000 && vid_activewindow)
                Con_DPrintf("SDL sound: %u sample frames missing\n", RequestedFrames - FrameCount);
 
        sdlaudiotime += RequestedFrames;
@@ -109,7 +109,7 @@ qboolean SndSys_Init (const snd_format_t* requested, snd_format_t* suggested)
                                wantspec.channels, wantspec.format, wantspec.freq, wantspec.samples);
 
        if( SDL_OpenAudio( &wantspec, &obtainspec ) )
-       {       
+       {
                Con_Printf( "Failed to open the audio device! (%s)\n", SDL_GetError() );
                return false;
        }
@@ -141,16 +141,21 @@ qboolean SndSys_Init (const snd_format_t* requested, snd_format_t* suggested)
        }
 
        snd_renderbuffer = Snd_CreateRingBuffer(requested, 0, NULL);
+       if (snd_channellayout.integer == SND_CHANNELLAYOUT_AUTO)
+       {
+               int newlayout;
 
 #ifdef __linux__
-       alsaspeakerlayout = true;
+               newlayout = SND_CHANNELLAYOUT_ALSA;
 #else
-       alsaspeakerlayout = false;
+               newlayout = SND_CHANNELLAYOUT_STANDARD;
 #endif
+               Cvar_SetValueQuick (&snd_channellayout, newlayout);
+       }
 
        sdlaudiotime = 0;
        SDL_PauseAudio( false );
-       
+
        return true;
 }