diff options
author | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-03-09 19:05:37 +0000 |
---|---|---|
committer | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-03-09 19:05:37 +0000 |
commit | 78ea8d5b1d7608255de7a776d98032fa14d47b76 (patch) | |
tree | a000111e7d2acdfab12fa6f5c88897121edf4894 /Game/Code/Classes/UAudioPlayback_SDL.pas | |
parent | 5493dcdf6ace3edb2c45b727aa5e580714de8709 (diff) | |
download | usdx-78ea8d5b1d7608255de7a776d98032fa14d47b76.tar.gz usdx-78ea8d5b1d7608255de7a776d98032fa14d47b76.tar.xz usdx-78ea8d5b1d7608255de7a776d98032fa14d47b76.zip |
new MixBuffers() function as replacement for SDL_MixAudio. Now portaudio works without crackling. MixBuffers is not optimized yet (no MMX, etc.) but I think it is fast enough for now. If SDL is used for audio output SDL_MixAudio() is used instead because it is more optimized.
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@948 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r-- | Game/Code/Classes/UAudioPlayback_SDL.pas | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Game/Code/Classes/UAudioPlayback_SDL.pas b/Game/Code/Classes/UAudioPlayback_SDL.pas index 1ea0c5b7..4c9200b2 100644 --- a/Game/Code/Classes/UAudioPlayback_SDL.pas +++ b/Game/Code/Classes/UAudioPlayback_SDL.pas @@ -31,6 +31,7 @@ type procedure StopAudioPlaybackEngine(); override;
public
function GetName: String; override;
+ procedure MixBuffers(dst, src: PChar; size: Cardinal; volume: Integer); override;
end;
var
@@ -100,6 +101,12 @@ begin SDL_CloseAudio();
end;
+procedure TAudioPlayback_SDL.MixBuffers(dst, src: PChar; size: Cardinal; volume: Integer);
+begin
+ // Note: (volume * SDL_MIX_MAXVOLUME) may exceed High(Integer)
+ // if SDL_MIX_MAXVOLUME (=128 at the moment) changes
+ SDL_MixAudio(PUInt8(dst), PUInt8(src), size, volume * SDL_MIX_MAXVOLUME div 100);
+end;
initialization
|