DEADSOFTWARE

fix sdlmixer on bigendian machines (i hope fully)
[d2df-sdl.git] / src / engine / e_sound_sdl.inc
index eb42c8bfea70d0374e304fe7546847db33d60b49..afbb8758f3658b92da93419d4f11737c80b3a87f 100644 (file)
@@ -2,8 +2,7 @@
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * the Free Software Foundation, version 3 of the License ONLY.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 interface
 
 uses
-  sdl2,
-  SDL2_mixer,
   {$IFDEF USE_MEMPOOL}mempool,{$ENDIF}
-  e_log,
-  SysUtils;
+  SDL2, SDL2_mixer, envvars,
+  e_log, SysUtils;
 
 type
   TSoundRec = record
@@ -181,6 +178,11 @@ begin
   Result := False;
   SoundInitialized := False;
 
+  {$IFDEF HEADLESS}
+    // HACK: shit this into env and hope for the best
+    SetEnvVar('SDL_AUDIODRIVER', 'dummy');
+  {$ENDIF}
+
   if NoOutput then begin Result := true; Exit end;
 
   // wow, this is actually MIDI player!
@@ -195,7 +197,7 @@ begin
   if (res and MIX_INIT_FLUIDSYNTH) <> 0 then e_WriteLog('SDL: FLUIDSYNTH playback is active', TMsgType.Notify);
 
   e_WriteLog(Format('SDL: initializing mixer at %d with buffer %d', [gsSDLSampleRate, gsSDLBufferSize]), TMsgType.Notify);
-  res := Mix_OpenAudio(gsSDLSampleRate, AUDIO_S16LSB, 2, gsSDLBufferSize);
+  res := Mix_OpenAudio(gsSDLSampleRate, {$IFDEF FPC_LITTLE_ENDIAN}AUDIO_S16LSB{$ELSE}AUDIO_S16MSB{$ENDIF}, 2, gsSDLBufferSize);
   if res = -1 then
   begin
     e_WriteLog('Error initializing SDL mixer:', TMsgType.Fatal);