index 0ebe256b9d9d818245067079d9fe22c99a5e252c..ba7bcdf67057a5d65f6e057b6ab4c755838f3b01 100644 (file)
implementation
implementation
-uses sdl2, utils, e_log;
+uses
+ {$IFDEF USE_SDL}
+ SDL,
+ {$ELSE}
+ SDL2,
+ {$ENDIF}
+ utils, e_log;
(* TWAVLoaderFactory *)
(* TWAVLoaderFactory *)
end;
(* TWAVLoader *)
end;
(* TWAVLoader *)
-
function TWAVLoader.Load(Data: Pointer; Len: LongWord; SStreaming: Boolean): Boolean;
var
Spec: TSDL_AudioSpec;
function TWAVLoader.Load(Data: Pointer; Len: LongWord; SStreaming: Boolean): Boolean;
var
Spec: TSDL_AudioSpec;
RW := SDL_RWFromConstMem(Data, Len);
RW := SDL_RWFromConstMem(Data, Len);
+{$IFDEF USE_SDL2}
if SDL_LoadWAV_RW(RW, 0, @Spec, @TmpBuf, @TmpLen) = nil then
if SDL_LoadWAV_RW(RW, 0, @Spec, @TmpBuf, @TmpLen) = nil then
+{$ELSE}
+ if SDL_LoadWAV_RW(RW, 0, @Spec, PUInt8(@TmpBuf), @TmpLen) = nil then
+{$ENDIF}
begin
e_LogWriteln('Could not load WAV: ' + SDL_GetError());
end
else
begin
FFormat.SampleRate := Spec.freq;
begin
e_LogWriteln('Could not load WAV: ' + SDL_GetError());
end
else
begin
FFormat.SampleRate := Spec.freq;
- FFormat.SampleBits := SDL_AUDIO_BITSIZE(Spec.format);
+ {$IFDEF USE_SDL2}
+ FFormat.SampleBits := SDL_AUDIO_BITSIZE(Spec.format);
+ {$ELSE}
+ FFormat.SampleBits := Spec.format and $FF;
+ {$ENDIF}
FFormat.Channels := Spec.channels;
FStreaming := False; // never stream wavs
FDataLen := TmpLen;
FFormat.Channels := Spec.channels;
FStreaming := False; // never stream wavs
FDataLen := TmpLen;
exit;
end;
exit;
end;
+{$IFDEF USE_SDL2}
if SDL_LoadWAV_RW(RW, 0, @Spec, @TmpBuf, @TmpLen) = nil then
if SDL_LoadWAV_RW(RW, 0, @Spec, @TmpBuf, @TmpLen) = nil then
+{$ELSE}
+ if SDL_LoadWAV_RW(RW, 0, @Spec, PUInt8(@TmpBuf), @TmpLen) = nil then
+{$ENDIF}
begin
e_LogWritefln('Could not load WAV file `%s`: %s', [FName, SDL_GetError()]);
end
else
begin
FFormat.SampleRate := Spec.freq;
begin
e_LogWritefln('Could not load WAV file `%s`: %s', [FName, SDL_GetError()]);
end
else
begin
FFormat.SampleRate := Spec.freq;
- FFormat.SampleBits := SDL_AUDIO_BITSIZE(Spec.format);
+ {$IFDEF USE_SDL2}
+ FFormat.SampleBits := SDL_AUDIO_BITSIZE(Spec.format);
+ {$ELSE}
+ FFormat.SampleBits := Spec.format and $FF;
+ {$ENDIF}
FFormat.Channels := Spec.channels;
FStreaming := False; // never stream wavs
FDataLen := TmpLen;
FFormat.Channels := Spec.channels;
FStreaming := False; // never stream wavs
FDataLen := TmpLen;