aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-02-04 17:42:12 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-02-04 17:42:12 +0000
commite0337089ed8777756ecfbdfcbc417a5392e90838 (patch)
treeacb247c483766d2501d8b08102a53e699466e168 /src
parent4bfd179d6903b623b446b17db42c1454aa0b56a0 (diff)
downloadusdx-e0337089ed8777756ecfbdfcbc417a5392e90838.tar.gz
usdx-e0337089ed8777756ecfbdfcbc417a5392e90838.tar.xz
usdx-e0337089ed8777756ecfbdfcbc417a5392e90838.zip
PChar replaced by PByteArray (for byte buffers) or PAnsiString (for zero-terminated strings)
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1583 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'src')
-rw-r--r--src/media/UAudioConverter.pas14
-rw-r--r--src/media/UAudioDecoder_Bass.pas6
-rw-r--r--src/media/UAudioDecoder_FFmpeg.pas26
-rw-r--r--src/media/UAudioPlayback_Bass.pas18
-rw-r--r--src/media/UAudioPlayback_SDL.pas14
-rw-r--r--src/media/UAudioPlayback_SoftMixer.pas38
6 files changed, 57 insertions, 59 deletions
diff --git a/src/media/UAudioConverter.pas b/src/media/UAudioConverter.pas
index 24131b16..657b80dd 100644
--- a/src/media/UAudioConverter.pas
+++ b/src/media/UAudioConverter.pas
@@ -70,7 +70,7 @@ type
function Init(SrcFormatInfo: TAudioFormatInfo; DstFormatInfo: TAudioFormatInfo): boolean; override;
destructor Destroy(); override;
- function Convert(InputBuffer: PChar; OutputBuffer: PChar; var InputSize: integer): integer; override;
+ function Convert(InputBuffer: PByteArray; OutputBuffer: PByteArray; var InputSize: integer): integer; override;
function GetOutputBufferSize(InputSize: integer): integer; override;
function GetRatio(): double; override;
end;
@@ -87,7 +87,7 @@ type
function Init(SrcFormatInfo: TAudioFormatInfo; DstFormatInfo: TAudioFormatInfo): boolean; override;
destructor Destroy(); override;
- function Convert(InputBuffer: PChar; OutputBuffer: PChar; var InputSize: integer): integer; override;
+ function Convert(InputBuffer: PByteArray; OutputBuffer: PByteArray; var InputSize: integer): integer; override;
function GetOutputBufferSize(InputSize: integer): integer; override;
function GetRatio(): double; override;
end;
@@ -103,7 +103,7 @@ type
function Init(SrcFormatInfo: TAudioFormatInfo; DstFormatInfo: TAudioFormatInfo): boolean; override;
destructor Destroy(); override;
- function Convert(InputBuffer: PChar; OutputBuffer: PChar; var InputSize: integer): integer; override;
+ function Convert(InputBuffer: PByteArray; OutputBuffer: PByteArray; var InputSize: integer): integer; override;
function GetOutputBufferSize(InputSize: integer): integer; override;
function GetRatio(): double; override;
end;
@@ -173,7 +173,7 @@ begin
Result := cvt.len_ratio;
end;
-function TAudioConverter_SDL.Convert(InputBuffer: PChar; OutputBuffer: PChar; var InputSize: integer): integer;
+function TAudioConverter_SDL.Convert(InputBuffer: PByteArray; OutputBuffer: PByteArray; var InputSize: integer): integer;
begin
Result := -1;
@@ -242,7 +242,7 @@ begin
inherited;
end;
-function TAudioConverter_FFmpeg.Convert(InputBuffer: PChar; OutputBuffer: PChar; var InputSize: integer): integer;
+function TAudioConverter_FFmpeg.Convert(InputBuffer: PByteArray; OutputBuffer: PByteArray; var InputSize: integer): integer;
var
InputSampleCount: integer;
OutputSampleCount: integer;
@@ -360,11 +360,11 @@ begin
inherited;
end;
-function TAudioConverter_SRC.Convert(InputBuffer: PChar; OutputBuffer: PChar; var InputSize: integer): integer;
+function TAudioConverter_SRC.Convert(InputBuffer: PByteArray; OutputBuffer: PByteArray; var InputSize: integer): integer;
var
FloatInputBuffer: PSingle;
FloatOutputBuffer: PSingle;
- TempBuffer: PChar;
+ TempBuffer: PByteArray;
TempSize: integer;
NumSamples: integer;
OutputSize: integer;
diff --git a/src/media/UAudioDecoder_Bass.pas b/src/media/UAudioDecoder_Bass.pas
index 3c31175d..6bbdaeaa 100644
--- a/src/media/UAudioDecoder_Bass.pas
+++ b/src/media/UAudioDecoder_Bass.pas
@@ -65,7 +65,7 @@ type
function IsEOF(): boolean; override;
function IsError(): boolean; override;
- function ReadData(Buffer: PChar; BufSize: integer): integer; override;
+ function ReadData(Buffer: PByteArray; BufSize: integer): integer; override;
end;
type
@@ -193,7 +193,7 @@ begin
Result := Error;
end;
-function TBassDecodeStream.ReadData(Buffer: PChar; BufSize: integer): integer;
+function TBassDecodeStream.ReadData(Buffer: PByteArray; BufSize: integer): integer;
begin
Result := BASS_ChannelGetData(Handle, Buffer, BufSize);
// check error state (do not handle EOF as error)
@@ -237,7 +237,7 @@ begin
// TODO: use BASS_STREAM_PRESCAN for accurate seeking in VBR-files?
// disadvantage: seeking will slow down.
- Stream := BASS_StreamCreateFile(False, PChar(Filename), 0, 0, BASS_STREAM_DECODE);
+ Stream := BASS_StreamCreateFile(False, PAnsiChar(Filename), 0, 0, BASS_STREAM_DECODE);
if (Stream = 0) then
begin
//Log.LogError(BassCore.ErrorGetString(), 'TAudioDecoder_Bass.Open');
diff --git a/src/media/UAudioDecoder_FFmpeg.pas b/src/media/UAudioDecoder_FFmpeg.pas
index 399c2f52..2d221f40 100644
--- a/src/media/UAudioDecoder_FFmpeg.pas
+++ b/src/media/UAudioDecoder_FFmpeg.pas
@@ -57,7 +57,6 @@ implementation
uses
Classes,
- SysUtils,
Math,
UMusic,
UIni,
@@ -68,8 +67,9 @@ uses
avio,
mathematics, // used for av_rescale_q
rational,
- UMediaCore_FFmpeg,
SDL,
+ SysUtils,
+ UMediaCore_FFmpeg,
ULog,
UCommon,
UConfig;
@@ -129,14 +129,14 @@ type
// state-vars for DecodeFrame (locked by DecoderLock)
AudioPaket: TAVPacket;
- AudioPaketData: PChar;
+ AudioPaketData: PByteArray;
AudioPaketSize: integer;
AudioPaketSilence: integer; // number of bytes of silence to return
// state-vars for AudioCallback (locked by DecoderLock)
AudioBufferPos: integer;
AudioBufferSize: integer;
- AudioBuffer: PChar;
+ AudioBuffer: PByteArray;
Filename: string;
@@ -153,7 +153,7 @@ type
procedure PauseParser();
procedure ResumeParser();
- function DecodeFrame(Buffer: PChar; BufferSize: integer): integer;
+ function DecodeFrame(Buffer: PByteArray; BufferSize: integer): integer;
procedure FlushCodecBuffers();
procedure PauseDecoder();
procedure ResumeDecoder();
@@ -173,11 +173,11 @@ type
function IsEOF(): boolean; override;
function IsError(): boolean; override;
- function ReadData(Buffer: PChar; BufferSize: integer): integer; override;
+ function ReadData(Buffer: PByteArray; BufferSize: integer): integer; override;
end;
type
- TAudioDecoder_FFmpeg = class( TInterfacedObject, IAudioDecoder )
+ TAudioDecoder_FFmpeg = class(TInterfacedObject, IAudioDecoder)
public
function GetName: string;
@@ -289,7 +289,7 @@ begin
Self.Filename := Filename;
// open audio file
- if (av_open_input_file(FormatCtx, PChar(Filename), nil, 0, nil) <> 0) then
+ if (av_open_input_file(FormatCtx, PAnsiChar(Filename), nil, 0, nil) <> 0) then
begin
Log.LogError('av_open_input_file failed: "' + Filename + '"', 'UAudio_FFmpeg');
Exit;
@@ -310,7 +310,7 @@ begin
FormatCtx^.pb.eof_reached := 0;
{$IFDEF DebugFFmpegDecode}
- dump_format(FormatCtx, 0, pchar(Filename), 0);
+ dump_format(FormatCtx, 0, PAnsiChar(Filename), 0);
{$ENDIF}
AudioStreamIndex := FFmpegCore.FindAudioStreamIndex(FormatCtx);
@@ -862,7 +862,7 @@ begin
end;
end;
-function TFFmpegDecodeStream.DecodeFrame(Buffer: PChar; BufferSize: integer): integer;
+function TFFmpegDecodeStream.DecodeFrame(Buffer: PByteArray; BufferSize: integer): integer;
var
PaketDecodedSize: integer; // size of packet data used for decoding
DataSize: integer; // size of output data decoded by FFmpeg
@@ -945,7 +945,7 @@ begin
Exit;
// handle Status-packet
- if (PChar(AudioPaket.data) = STATUS_PACKET) then
+ if (PAnsiChar(AudioPaket.data) = STATUS_PACKET) then
begin
AudioPaket.data := nil;
AudioPaketData := nil;
@@ -986,7 +986,7 @@ begin
Continue;
end;
- AudioPaketData := PChar(AudioPaket.data);
+ AudioPaketData := AudioPaket.data;
AudioPaketSize := AudioPaket.size;
// if available, update the stream position to the presentation time of this package
@@ -1005,7 +1005,7 @@ begin
end;
end;
-function TFFmpegDecodeStream.ReadData(Buffer: PChar; BufferSize: integer): integer;
+function TFFmpegDecodeStream.ReadData(Buffer: PByteArray; BufferSize: integer): integer;
var
CopyByteCount: integer; // number of bytes to copy
RemainByteCount: integer; // number of bytes left (remain) to read
diff --git a/src/media/UAudioPlayback_Bass.pas b/src/media/UAudioPlayback_Bass.pas
index d68ac1d4..923c1d7b 100644
--- a/src/media/UAudioPlayback_Bass.pas
+++ b/src/media/UAudioPlayback_Bass.pas
@@ -37,7 +37,6 @@ implementation
uses
Classes,
- SysUtils,
Math,
UIni,
UMain,
@@ -46,7 +45,8 @@ uses
UAudioCore_Bass,
ULog,
sdl,
- bass;
+ bass,
+ SysUtils;
type
PHDSP = ^HDSP;
@@ -90,7 +90,7 @@ type
function GetAudioFormatInfo(): TAudioFormatInfo; override;
- function ReadData(Buffer: PChar; BufferSize: integer): integer;
+ function ReadData(Buffer: PByteArray; BufferSize: integer): integer;
property EOF: boolean READ IsEOF;
end;
@@ -106,8 +106,8 @@ type
function Open(ChannelMap: integer; FormatInfo: TAudioFormatInfo): boolean; override;
procedure Close(); override;
- procedure WriteData(Buffer: PChar; BufferSize: integer); override;
- function ReadData(Buffer: PChar; BufferSize: integer): integer; override;
+ procedure WriteData(Buffer: PByteArray; BufferSize: integer); override;
+ function ReadData(Buffer: PByteArray; BufferSize: integer): integer; override;
function IsEOF(): boolean; override;
function IsError(): boolean; override;
end;
@@ -163,14 +163,14 @@ begin
Result := BytesRead;
end;
-function TBassPlaybackStream.ReadData(Buffer: PChar; BufferSize: integer): integer;
+function TBassPlaybackStream.ReadData(Buffer: PByteArray; BufferSize: integer): integer;
var
AdjustedSize: integer;
RequestedSourceSize, SourceSize: integer;
SkipCount: integer;
SourceFormatInfo: TAudioFormatInfo;
FrameSize: integer;
- PadFrame: PChar;
+ PadFrame: PByteArray;
//Info: BASS_INFO;
//Latency: double;
begin
@@ -610,7 +610,7 @@ begin
inherited Close();
end;
-procedure TBassVoiceStream.WriteData(Buffer: PChar; BufferSize: integer);
+procedure TBassVoiceStream.WriteData(Buffer: PByteArray; BufferSize: integer);
var QueueSize: DWORD;
begin
if ((Handle <> 0) and (BufferSize > 0)) then
@@ -626,7 +626,7 @@ begin
end;
// Note: we do not need the read-function for the BASS implementation
-function TBassVoiceStream.ReadData(Buffer: PChar; BufferSize: integer): integer;
+function TBassVoiceStream.ReadData(Buffer: PByteArray; BufferSize: integer): integer;
begin
Result := -1;
end;
diff --git a/src/media/UAudioPlayback_SDL.pas b/src/media/UAudioPlayback_SDL.pas
index b0887676..8403ef03 100644
--- a/src/media/UAudioPlayback_SDL.pas
+++ b/src/media/UAudioPlayback_SDL.pas
@@ -33,16 +33,14 @@ interface
{$I switches.inc}
-uses
- Classes,
- SysUtils,
- UMusic;
-
implementation
uses
+ Classes,
sdl,
+ SysUtils,
UAudioPlayback_SoftMixer,
+ UMusic,
ULog,
UIni,
UMain;
@@ -60,13 +58,13 @@ type
function GetLatency(): double; override;
public
function GetName: String; override;
- procedure MixBuffers(dst, src: PChar; size: Cardinal; volume: Single); override;
+ procedure MixBuffers(dst, src: PByteArray; size: Cardinal; volume: Single); override;
end;
{ TAudioPlayback_SDL }
-procedure SDLAudioCallback(userdata: Pointer; stream: PChar; len: integer); cdecl;
+procedure SDLAudioCallback(userdata: Pointer; stream: PByteArray; len: integer); cdecl;
var
Engine: TAudioPlayback_SDL;
begin
@@ -172,7 +170,7 @@ begin
Result := Latency;
end;
-procedure TAudioPlayback_SDL.MixBuffers(dst, src: PChar; size: Cardinal; volume: Single);
+procedure TAudioPlayback_SDL.MixBuffers(dst, src: PByteArray; size: Cardinal; volume: Single);
begin
SDL_MixAudio(PUInt8(dst), PUInt8(src), size, Round(volume * SDL_MIX_MAXVOLUME));
end;
diff --git a/src/media/UAudioPlayback_SoftMixer.pas b/src/media/UAudioPlayback_SoftMixer.pas
index f3797dd6..c8da6bcd 100644
--- a/src/media/UAudioPlayback_SoftMixer.pas
+++ b/src/media/UAudioPlayback_SoftMixer.pas
@@ -35,8 +35,8 @@ interface
uses
Classes,
- SysUtils,
sdl,
+ SysUtils,
URingBuffer,
UMusic,
UAudioPlaybackBase;
@@ -48,12 +48,12 @@ type
private
Engine: TAudioPlayback_SoftMixer;
- SampleBuffer: PChar;
+ SampleBuffer: PByteArray;
SampleBufferSize: integer;
SampleBufferCount: integer; // number of available bytes in SampleBuffer
SampleBufferPos: cardinal;
- SourceBuffer: PChar;
+ SourceBuffer: PByteArray;
SourceBufferSize: integer;
SourceBufferCount: integer; // number of available bytes in SourceBuffer
@@ -70,7 +70,7 @@ type
procedure Reset();
- procedure ApplySoundEffects(Buffer: PChar; BufferSize: integer);
+ procedure ApplySoundEffects(Buffer: PByteArray; BufferSize: integer);
function InitFormatConversion(): boolean;
procedure FlushBuffers();
@@ -100,7 +100,7 @@ type
function GetAudioFormatInfo(): TAudioFormatInfo; override;
- function ReadData(Buffer: PChar; BufferSize: integer): integer;
+ function ReadData(Buffer: PByteArray; BufferSize: integer): integer;
function GetPCMData(var Data: TPCMData): Cardinal; override;
procedure GetFFTData(var Data: TFFTData); override;
@@ -114,7 +114,7 @@ type
Engine: TAudioPlayback_SoftMixer;
ActiveStreams: TList;
- MixerBuffer: PChar;
+ MixerBuffer: PByteArray;
InternalLock: PSDL_Mutex;
AppVolume: single;
@@ -129,7 +129,7 @@ type
destructor Destroy(); override;
procedure AddStream(Stream: TAudioPlaybackStream);
procedure RemoveStream(Stream: TAudioPlaybackStream);
- function ReadData(Buffer: PChar; BufferSize: integer): integer;
+ function ReadData(Buffer: PByteArray; BufferSize: integer): integer;
property Volume: single read GetVolume write SetVolume;
end;
@@ -144,7 +144,7 @@ type
function StartAudioPlaybackEngine(): boolean; virtual; abstract;
procedure StopAudioPlaybackEngine(); virtual; abstract;
function FinalizeAudioPlaybackEngine(): boolean; virtual; abstract;
- procedure AudioCallback(Buffer: PChar; Size: integer); {$IFDEF HasInline}inline;{$ENDIF}
+ procedure AudioCallback(Buffer: PByteArray; Size: integer); {$IFDEF HasInline}inline;{$ENDIF}
function CreatePlaybackStream(): TAudioPlaybackStream; override;
public
@@ -159,7 +159,7 @@ type
function GetMixer(): TAudioMixerStream; {$IFDEF HasInline}inline;{$ENDIF}
function GetAudioFormatInfo(): TAudioFormatInfo;
- procedure MixBuffers(DstBuffer, SrcBuffer: PChar; Size: Cardinal; Volume: Single); virtual;
+ procedure MixBuffers(DstBuffer, SrcBuffer: PByteArray; Size: Cardinal; Volume: Single); virtual;
end;
type
@@ -174,8 +174,8 @@ type
function Open(ChannelMap: integer; FormatInfo: TAudioFormatInfo): boolean; override;
procedure Close(); override;
- procedure WriteData(Buffer: PChar; BufferSize: integer); override;
- function ReadData(Buffer: PChar; BufferSize: integer): integer; override;
+ procedure WriteData(Buffer: PByteArray; BufferSize: integer); override;
+ function ReadData(Buffer: PByteArray; BufferSize: integer): integer; override;
function IsEOF(): boolean; override;
function IsError(): boolean; override;
end;
@@ -276,7 +276,7 @@ begin
Unlock();
end;
-function TAudioMixerStream.ReadData(Buffer: PChar; BufferSize: integer): integer;
+function TAudioMixerStream.ReadData(Buffer: PByteArray; BufferSize: integer): integer;
var
i: integer;
Size: integer;
@@ -545,7 +545,7 @@ begin
SourceBufferCount := 0;
end;
-procedure TGenericPlaybackStream.ApplySoundEffects(Buffer: PChar; BufferSize: integer);
+procedure TGenericPlaybackStream.ApplySoundEffects(Buffer: PByteArray; BufferSize: integer);
var
i: integer;
begin
@@ -558,7 +558,7 @@ begin
end;
end;
-function TGenericPlaybackStream.ReadData(Buffer: PChar; BufferSize: integer): integer;
+function TGenericPlaybackStream.ReadData(Buffer: PByteArray; BufferSize: integer): integer;
var
ConversionInputCount: integer;
ConversionOutputSize: integer; // max. number of converted data (= buffer size)
@@ -573,7 +573,7 @@ var
SkipSourceCount: integer; // number of source-data bytes to skip
FillCount: integer; // number of bytes to fill with padding data
CopyCount: integer;
- PadFrame: PChar;
+ PadFrame: PByteArray;
i: integer;
begin
Result := -1;
@@ -986,7 +986,7 @@ begin
inherited Close();
end;
-procedure TGenericVoiceStream.WriteData(Buffer: PChar; BufferSize: integer);
+procedure TGenericVoiceStream.WriteData(Buffer: PByteArray; BufferSize: integer);
begin
// lock access to buffer
SDL_mutexP(BufferLock);
@@ -999,7 +999,7 @@ begin
end;
end;
-function TGenericVoiceStream.ReadData(Buffer: PChar; BufferSize: integer): integer;
+function TGenericVoiceStream.ReadData(Buffer: PByteArray; BufferSize: integer): integer;
begin
Result := -1;
@@ -1059,7 +1059,7 @@ begin
Result := true;
end;
-procedure TAudioPlayback_SoftMixer.AudioCallback(Buffer: PChar; Size: integer);
+procedure TAudioPlayback_SoftMixer.AudioCallback(Buffer: PByteArray; Size: integer);
begin
MixerStream.ReadData(Buffer, Size);
end;
@@ -1102,7 +1102,7 @@ begin
MixerStream.Volume := Volume;
end;
-procedure TAudioPlayback_SoftMixer.MixBuffers(DstBuffer, SrcBuffer: PChar; Size: Cardinal; Volume: Single);
+procedure TAudioPlayback_SoftMixer.MixBuffers(DstBuffer, SrcBuffer: PByteArray; Size: Cardinal; Volume: Single);
var
SampleIndex: Cardinal;
SampleInt: Integer;