aboutsummaryrefslogtreecommitdiffstats
path: root/Game
diff options
context:
space:
mode:
authors_alexander <s_alexander@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-03-06 03:59:31 +0000
committers_alexander <s_alexander@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-03-06 03:59:31 +0000
commit09e53466cd18092dd30944c18cc89c3c567e7b7c (patch)
tree531c454b3e07d5faf359b93e95cfc01a180acef5 /Game
parent36e04782552fde9e26710f29f453d574b2ee9c0b (diff)
downloadusdx-09e53466cd18092dd30944c18cc89c3c567e7b7c.tar.gz
usdx-09e53466cd18092dd30944c18cc89c3c567e7b7c.tar.xz
usdx-09e53466cd18092dd30944c18cc89c3c567e7b7c.zip
add ini file option SDLBufferSize to set the buffersize for the sdl playback driver (not in config screen yes)
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@917 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game')
-rw-r--r--Game/Code/Classes/UAudioPlayback_SDL.pas2
-rw-r--r--Game/Code/Classes/UIni.pas31
-rw-r--r--Game/Code/Classes/UMain.pas87
3 files changed, 72 insertions, 48 deletions
diff --git a/Game/Code/Classes/UAudioPlayback_SDL.pas b/Game/Code/Classes/UAudioPlayback_SDL.pas
index 5dc664fa..1ea0c5b7 100644
--- a/Game/Code/Classes/UAudioPlayback_SDL.pas
+++ b/Game/Code/Classes/UAudioPlayback_SDL.pas
@@ -67,7 +67,7 @@ begin
freq := 44100;
format := AUDIO_S16SYS;
channels := 2;
- samples := 1024; // latency: 23 ms
+ samples := Ini.SDLBufferSize;
callback := @SDLAudioCallback;
userdata := Self;
end;
diff --git a/Game/Code/Classes/UIni.pas b/Game/Code/Classes/UIni.pas
index 91ff9077..431ae0be 100644
--- a/Game/Code/Classes/UIni.pas
+++ b/Game/Code/Classes/UIni.pas
@@ -66,6 +66,7 @@ type
BeatClick: integer;
SavePlayback: integer;
Threshold: integer;
+ SDLBufferSize: integer;
//Song Preview
PreviewVolume: integer;
@@ -103,6 +104,8 @@ type
LPT: integer;
procedure Load();
+ procedure LoadSoundSettings();
+
procedure Save();
procedure SaveNames;
procedure SaveLevel;
@@ -152,6 +155,8 @@ const
IBeatClick: array[0..1] of string = ('Off', 'On');
ISavePlayback: array[0..1] of string = ('Off', 'On');
IThreshold: array[0..3] of string = ('5%', '10%', '15%', '20%');
+ ISDLBufferSize: array[0..8] of string = ('256', '512', '1024', '2048', '4096', '8192', '16384', '32768', '65536');
+
//Song Preview
IPreviewVolume: array[0..10] of string = ('Off', '10%', '20%', '30%', '40%', '50%', '60%', '70%', '80%', '90%', '100%');
IPreviewFading: array[0..5] of string = ('Off', '1 Sec', '2 Secs', '3 Secs', '4 Secs', '5 Secs');
@@ -573,6 +578,13 @@ begin
// Threshold
Threshold := GetArrayIndex(IThreshold, IniFile.ReadString('Sound', 'Threshold', IThreshold[1]));
+ // SDLBufferSize
+ SDLBufferSize := GetArrayIndex(ISDLBufferSize, IniFile.ReadString('Sound', 'SDLBufferSize', '1024'));
+ if (SDLBufferSize = -1) then
+ SDLBufferSize := 1024
+ else
+ SDLBufferSize := StrToInt(ISDLBufferSize[SDLBufferSize]);
+
//Preview Volume
PreviewVolume := GetArrayIndex(IPreviewVolume, IniFile.ReadString('Sound', 'PreviewVolume', IPreviewVolume[7]));
@@ -631,10 +643,6 @@ begin
// Color
Color := GetArrayIndex(IColor, IniFile.ReadString('Themes', 'Color', IColor[0]));
- LoadInputDeviceCfg(IniFile);
-
- //Advanced Settings
-
// LoadAnimation
LoadAnimation := GetArrayIndex(ILoadAnimation, IniFile.ReadString('Advanced', 'LoadAnimation', 'On'));
@@ -739,6 +747,9 @@ begin
// Threshold
IniFile.WriteString('Sound', 'Threshold', IThreshold[Threshold]);
+
+ // SDLBufferSize
+ IniFile.WriteString('Sound', 'SDLBufferSize', IntToStr(SDLBufferSize));
// Song Preview
IniFile.WriteString('Sound', 'PreviewVolume', IPreviewVolume[PreviewVolume]);
@@ -768,11 +779,8 @@ begin
IniFile.WriteString('Themes', 'Color', IColor[Color]);
SaveInputDeviceCfg(IniFile);
-
//Log.LogError(InttoStr(Length(CardList)) + ' Cards Saved');
- //Advanced Settings
-
//LoadAnimation
IniFile.WriteString('Advanced', 'LoadAnimation', ILoadAnimation[LoadAnimation]);
@@ -802,6 +810,15 @@ begin
end;
end;
+procedure TIni.LoadSoundSettings;
+var
+ IniFile: TMemIniFile;
+begin
+ IniFile := TMemIniFile.Create(Filename);
+ LoadInputDeviceCfg(IniFile);
+ IniFile.Free;
+end;
+
procedure TIni.SaveNames;
var
IniFile: TIniFile;
diff --git a/Game/Code/Classes/UMain.pas b/Game/Code/Classes/UMain.pas
index c13050e5..dc76429d 100644
--- a/Game/Code/Classes/UMain.pas
+++ b/Game/Code/Classes/UMain.pas
@@ -169,6 +169,7 @@ begin
InitializePaths;
Log.LogStatus('Load Language', 'Initialization');
Language := TLanguage.Create;
+
// Add Const Values:
Language.AddConst('US_VERSION', USDXVersionStr);
Log.BenchmarkEnd(1);
@@ -188,21 +189,14 @@ begin
Log.BenchmarkEnd(1);
Log.LogBenchmark('Initializing SDL_ttf', 1);
- // Skin
+ // Skin
Log.BenchmarkStart(1);
Log.LogStatus('Loading Skin List', 'Initialization');
Skin := TSkin.Create;
Log.BenchmarkEnd(1);
Log.LogBenchmark('Loading Skin List', 1);
- // Sound
- Log.BenchmarkStart(1);
- Log.LogStatus('Initialize Sound', 'Initialization');
- InitializeSound();
- Log.BenchmarkEnd(1);
- Log.LogBenchmark('Initializing Sound', 1);
-
- // Ini + Paths (depends on Sound)
+ // Ini + Paths
Log.BenchmarkStart(1);
Log.LogStatus('Load Ini', 'Initialization');
Ini := TIni.Create;
@@ -217,6 +211,19 @@ begin
Log.BenchmarkEnd(1);
Log.LogBenchmark('Loading Ini', 1);
+ // Sound
+ Log.BenchmarkStart(1);
+ Log.LogStatus('Initialize Sound', 'Initialization');
+ InitializeSound();
+ Log.BenchmarkEnd(1);
+ Log.LogBenchmark('Initializing Sound', 1);
+
+ // Load Sound Settings from Ini
+ Log.BenchmarkStart(1);
+ Log.LogStatus('Load Sound Settings', 'Initialization');
+ Ini.LoadSoundSettings;
+ Log.BenchmarkEnd(1);
+ Log.LogBenchmark('Load Sound Settings', 1);
// LCD
Log.BenchmarkStart(1);
@@ -453,43 +460,43 @@ begin
begin
//
end;
- end;
- }
- SDL_VIDEORESIZE:
- begin
- ScreenW := Event.resize.w;
- ScreenH := Event.resize.h;
-
- screen := SDL_SetVideoMode(ScreenW, ScreenH, (Ini.Depth+1) * 16, SDL_OPENGL or SDL_RESIZABLE);
+ end;
+ }
+ SDL_VIDEORESIZE:
+ begin
+ ScreenW := Event.resize.w;
+ ScreenH := Event.resize.h;
+
+ screen := SDL_SetVideoMode(ScreenW, ScreenH, (Ini.Depth+1) * 16, SDL_OPENGL or SDL_RESIZABLE);
end;
SDL_KEYDOWN:
begin
// remap the "keypad enter" key to the "standard enter" key
if (Event.key.keysym.sym = SDLK_KP_ENTER) then
Event.key.keysym.sym := SDLK_RETURN;
-
- if (Event.key.keysym.sym = SDLK_F11) or
- ((Event.key.keysym.sym = SDLK_RETURN) and
- ((Event.key.keysym.modifier and KMOD_ALT) <> 0)) then // toggle full screen
- begin
- Ini.FullScreen := integer( not boolean( Ini.FullScreen ) );
-
- if boolean( Ini.FullScreen ) then
- begin
- SDL_SetVideoMode(ScreenW, ScreenH, (Ini.Depth+1) * 16, SDL_OPENGL or SDL_FULLSCREEN);
- SDL_ShowCursor(0);
- end
- else
- begin
- SDL_SetVideoMode(ScreenW, ScreenH, (Ini.Depth+1) * 16, SDL_OPENGL or SDL_RESIZABLE);
- SDL_ShowCursor(1);
- end;
-
- glViewPort(0, 0, ScreenW, ScreenH);
- end
- // ScreenShot hack. If Print is pressed-> Make screenshot and Save to Screenshots Path
- else if (Event.key.keysym.sym = SDLK_SYSREQ) or (Event.key.keysym.sym = SDLK_PRINT) then
- Display.ScreenShot
+
+ if (Event.key.keysym.sym = SDLK_F11) or
+ ((Event.key.keysym.sym = SDLK_RETURN) and
+ ((Event.key.keysym.modifier and KMOD_ALT) <> 0)) then // toggle full screen
+ begin
+ Ini.FullScreen := integer( not boolean( Ini.FullScreen ) );
+
+ if boolean( Ini.FullScreen ) then
+ begin
+ SDL_SetVideoMode(ScreenW, ScreenH, (Ini.Depth+1) * 16, SDL_OPENGL or SDL_FULLSCREEN);
+ SDL_ShowCursor(0);
+ end
+ else
+ begin
+ SDL_SetVideoMode(ScreenW, ScreenH, (Ini.Depth+1) * 16, SDL_OPENGL or SDL_RESIZABLE);
+ SDL_ShowCursor(1);
+ end;
+
+ glViewPort(0, 0, ScreenW, ScreenH);
+ end
+ // ScreenShot hack. If Print is pressed-> Make screenshot and Save to Screenshots Path
+ else if (Event.key.keysym.sym = SDLK_SYSREQ) or (Event.key.keysym.sym = SDLK_PRINT) then
+ Display.ScreenShot
// popup hack... if there is a visible popup then let it handle input instead of underlying screen
// shoud be done in a way to be sure the topmost popup has preference (maybe error, then check)
else if (ScreenPopupError <> nil) and (ScreenPopupError.Visible) then