fix volume being at 0 on engine start. note: seems window focus changes are not detected atm. (relevant for sound dampening)
authorsheepluva
Tue, 12 Jan 2016 20:40:12 +0100
changeset 11499 9c5d9993b14b
parent 11498 1908b919c057
child 11500 3a4026fe7c18
fix volume being at 0 on engine start. note: seems window focus changes are not detected atm. (relevant for sound dampening)
hedgewars/SDLh.pas
hedgewars/uSound.pas
--- a/hedgewars/SDLh.pas	Tue Jan 12 00:36:17 2016 +0100
+++ b/hedgewars/SDLh.pas	Tue Jan 12 20:40:12 2016 +0100
@@ -88,6 +88,9 @@
     SDL_ALLEVENTS        = $FFFFFFFF;    // dummy event type to prevent stack corruption
     SDL_APPINPUTFOCUS    = $02;
 
+    // audio formats
+    AUDIO_S16LSB         = $8010; // Signed 16-bit samples, in little-endian byte order
+
     SDL_BUTTON_LEFT      = 1;
     SDL_BUTTON_MIDDLE    = 2;
     SDL_BUTTON_RIGHT     = 3;
--- a/hedgewars/uSound.pas	Tue Jan 12 00:36:17 2016 +0100
+++ b/hedgewars/uSound.pas	Tue Jan 12 20:40:12 2016 +0100
@@ -310,7 +310,7 @@
     success:= SDL_InitSubSystem(SDL_INIT_AUDIO) >= 0;
 
     if success then
-        success:= Mix_OpenAudio(44100, $8010, channels, 1024) = 0;
+        success:= Mix_OpenAudio(44100, AUDIO_S16LSB, channels, 1024) = 0;
 
     if success then
         WriteLnToConsole(msgOK)
@@ -326,6 +326,7 @@
     WriteLnToConsole(msgOK);
 
     Mix_AllocateChannels(Succ(chanTPU));
+    previousVolume:= cInitVolume;
     ChangeVolume(cInitVolume);
 end;