Стартовый пул

This commit is contained in:
2024-04-02 08:46:59 +03:00
parent fd57fffd3a
commit 3bb34d000b
5591 changed files with 3291734 additions and 0 deletions

View File

@@ -0,0 +1,481 @@
(*
this file is a part of audio components suite v 2.3.
copyright (c) 2002-2005 andrei borovsky. all rights reserved.
see the license file for more details.
you can contact me at mail@z0m3ie.de
*)
{
$Log: acs_alsaaudio.pas,v $
Revision 1.6 2006/08/30 18:59:51 z0m3ie
*** empty log message ***
Revision 1.5 2006/07/04 17:12:45 z0m3ie
ACS 2.4 alt wiederhergestellt (unterschiedliche Sampleformate ...)
Revision 1.2 2006/01/01 18:46:40 z0m3ie
*** empty log message ***
Revision 1.1 2005/12/19 18:36:05 z0m3ie
*** empty log message ***
Revision 1.1 2005/09/13 21:53:45 z0m3ie
maked seperat driver (not complete jet)
Revision 1.1 2005/09/12 22:04:52 z0m3ie
modified structure again, fileformats are now in an sperat folder.
all File In/Out classes are capsulated from TFileIn and TFileOut
Revision 1.3 2005/08/28 20:31:17 z0m3ie
linux restructuring for 2.4
Revision 1.2 2005/08/26 17:03:20 z0m3ie
begon to make acs resourcestring aware
more advanced tmixer for windows
restructured tmixer its better handleable now
Revision 1.1 2005/08/25 20:18:00 z0m3ie
Version 2.4 restructure
TCDPlayer removed (fits not in component structure)
TMP3ToWavConverter removed (fits not in component structure)
Revision 1.2 2005/08/22 20:17:01 z0m3ie
changed Headers to log
changed mail adress
}
{$ifdef mswindows}{$message error 'unit not supported'}{$endif}
unit acs_alsaaudio;
interface
uses
Classes, SysUtils, ACS_Types, ACS_Classes, baseunix, alsa, ACS_Strings,ACS_Audio;
const
BUF_SIZE = $4000;
ALSAStateIdle = $ffffffff; // additional DriverState value;
LATENCY = 60;
type
EALSABufferUnderrun = class(EACSException);
EALSABufferOverrun = class(EACSException);
{ TALSAAudioIn }
TALSAAudioIn = class(TACSBaseAudioIn)
private
FDevice : String;
FPeriodSize, FPeriodNum : Integer;
_audio_handle : Psnd_pcm_t;
_hw_params : Psnd_pcm_hw_params_t;
Busy : Boolean;
FBPS, FChan, FFreq : Integer;
BufStart, BufEnd : Integer;
FOpened : Integer;
FRecTime : Integer;
FRecBytes : Integer;
FLatency : Double;
FSilentOnOverrun : Boolean;
function GetDriverState: Integer;
procedure OpenAudio;
procedure CloseAudio;
// function GetDriverState : Integer;
protected
function GetBPS : Integer; override;
function GetCh : Integer; override;
function GetSR : Integer; override;
procedure SetDevice(Ch : Integer);override;
function GetDeviceInfo : TACSDeviceInfo;override;
function GetTotalTime : real; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function GetData(Buffer : Pointer; BufferSize : Integer): Integer; override;
procedure Init; override;
procedure Flush; override;
property DriverState : Integer read GetDriverState;
published
property PeriodSize : Integer read FPeriodSize write FPeriodSize;
property PeriodNum : Integer read FPeriodNum write FPeriodNum;
property SilentOnOverrun : Boolean read FSilentOnOverrun write FSilentOnOverrun;
end;
{ TALSAAudioOut }
TALSAAudioOut = class(TACSBaseAudioOut)
private
FDevice : String;
FPeriodSize, FPeriodNum : Integer;
_audio_handle : Psnd_pcm_t;
_hw_params : Psnd_pcm_hw_params_t;
FBufferSize : Integer;
FVolume : Byte;
_audio_fd : Integer;
Buffer : array [0..BUF_SIZE-1] of Byte;
FLatency : Double;
FSilentOnUnderrun : Boolean;
function GetDriverState : Integer;
protected
procedure Done; override;
function DoOutput(Abort : Boolean):Boolean; override;
procedure Prepare; override;
procedure SetDevice(Ch : Integer);override;
function GetDeviceInfo : TACSDeviceInfo;override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property DriverState : Integer read GetDriverState;
property Latency : Double read FLatency;
published
property BufferSize : Integer read FBufferSize write FBufferSize;
property Device : String read FDevice write FDevice stored True;
property PeriodSize : Integer read FPeriodSize write FPeriodSize;
property PeriodNum : Integer read FPeriodNum write FPeriodNum;
property SilentOnUnderrun : Boolean read FSilentOnUnderrun write FSilentOnUnderrun;
property Volume : Byte read FVolume write FVolume stored True;
end;
implementation
constructor TALSAAudioIn.Create;
begin
inherited Create(AOwner);
if not (csDesigning in ComponentState) then
if not AsoundlibLoaded then
raise EACSException.Create(Format(strcoudntloadLib,[asoundlib_path]));
FBPS := 8;
FChan := 1;
FFreq := 8000;
FSize := -1;
FRecTime := 600;
FDevice := 'default';
BufferSize := 32768;
FSilentOnOverrun := True;
end;
destructor TALSAAudioIn.Destroy;
begin
inherited Destroy;
CloseAudio;
end;
procedure TALSAAudioIn.OpenAudio;
var
Res : Integer;
begin
if FOpened = 0 then
begin
Res := snd_pcm_open(_audio_handle, @FDevice[1], SND_PCM_STREAM_CAPTURE, 0);
if Res < 0 then
raise EACSException.Create(Format(strcoudntopendevice,[FDevice]));
// snd_pcm_reset(_audio_handle);
end;
Inc(FOpened);
end;
procedure TALSAAudioIn.CloseAudio;
begin
if FOpened = 1 then
begin
snd_pcm_drop(_audio_handle);
snd_pcm_close(_audio_handle);
end;
if FOpened > 0 then Dec(FOpened);
end;
(* Note on the following three methods.
These methods simply return the values passed by the user.
As the actual input process begins, ALSAAudioIn may return a bit different
value of the samplerate that is actually set by the ALSA drivers.*)
function TALSAAudioIn.GetBPS : Integer;
begin
Result := FBPS;
end;
function TALSAAudioIn.GetCh : Integer;
begin
Result := FChan;
end;
function TALSAAudioIn.GetSR : Integer;
begin
Result := FFreq;
end;
procedure TALSAAudioIn.SetDevice(Ch: Integer);
begin
FDevice := IntToStr(ch);
end;
function TALSAAudioIn.GetDeviceInfo: TACSDeviceInfo;
begin
end;
procedure TALSAAudioIn.Init;
var
aBufSize : Integer;
begin
if Busy then raise EACSException.Create(strBusy);
BufEnd := 0;
BufStart := 1;
FPosition := 0;
OpenAudio;
snd_pcm_hw_params_malloc(_hw_params);
snd_pcm_hw_params_any(_audio_handle, _hw_params);
snd_pcm_hw_params_set_access(_audio_handle, _hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
if FBPS = 8 then snd_pcm_hw_params_set_format(_audio_handle, _hw_params, SND_PCM_FORMAT_U8)
else snd_pcm_hw_params_set_format(_audio_handle, _hw_params, SND_PCM_FORMAT_S16_LE);
Self.FFreq := snd_pcm_hw_params_set_rate_near(_audio_handle, _hw_params, FFreq, 0);
snd_pcm_hw_params_set_channels(_audio_handle, _hw_params, FChan);
if (FPeriodSize <> 0) and (FPeriodNum <> 0) then
begin
snd_pcm_hw_params_set_period_size_near(_audio_handle, _hw_params, FPeriodSize, 0);
snd_pcm_hw_params_set_periods_near(_audio_handle, _hw_params, FPeriodNum, 0);
aBufSize := (FPeriodSize * FPeriodNum) div (FChan * (FBPS shr 3));
end
else aBufSize := Self.BufferSize div (FChan * (FBPS shr 3));
snd_pcm_hw_params_set_buffer_size_near(_audio_handle, _hw_params, aBufSize);
snd_pcm_hw_params(_audio_handle, _hw_params);
snd_pcm_hw_params_free(_hw_params);
if snd_pcm_prepare(_audio_handle) < 0 then
begin
CloseAudio;
raise EACSException.Create(strInputstartfailed);
end;
try
FLatency := snd_pcm_hw_params_get_period_size(_audio_handle, 0) *
snd_pcm_hw_params_get_periods(_audio_handle, 0)/(FFreq * FChan * (FBPS shr 3));
except
end;
FRecBytes := FRecTime * (GetBPS div 8) * GetCh * GetSR;
Busy := True;
FSize := FRecBytes;
end;
procedure TALSAAudioIn.Flush;
begin
snd_pcm_drain(_audio_handle);
CloseAudio;
Busy := False;
end;
function TALSAAudioIn.GetData(Buffer : Pointer; BufferSize : Integer): Integer;
var
l : Integer;
begin
if not Busy then raise EACSException.Create(strStreamnotopen);
if FPosition >= FRecBytes then
begin
Result := 0;
Exit;
end;
if BufStart > BufEnd then
begin
BufStart := 1;
l := snd_pcm_readi(_audio_handle, @FBuffer[1], (BUF_SIZE div FChan) div (FBPS shr 3));
while l < 0 do
begin
snd_pcm_prepare(_audio_handle);
if not FSilentOnOverrun then
raise EALSABufferOverrun.Create(strBufferoverrun);
l := snd_pcm_readi(_audio_handle, @FBuffer[1], (BUF_SIZE div FChan) div (FBPS shr 3));
end;
if l <> (BUF_SIZE div FChan) div (FBPS shr 3) then
begin
Result := 0;
Exit;
end
else BufEnd := l*FChan*(FBPS shr 3);
end;
if BufferSize < (BufEnd - BufStart + 1)
then Result := BufferSize
else Result := BufEnd - BufStart + 1;
Move(FBuffer[BufStart-1], Buffer^, Result);
Inc(BufStart, Result);
Inc(FPosition, Result);
end;
function TALSAAudioIn.GetTotalTime : real;
begin
Result := FRecTime;
end;
function TALSAAudioIn.GetDriverState : Integer;
begin
if FOpened = 0 then Result := ALSAStateIdle
else Result := snd_pcm_state(_audio_handle);
end;
constructor TALSAAudioOut.Create;
begin
inherited Create(AOwner);
if not (csDesigning in ComponentState) then
if not AsoundlibLoaded then
raise EACSException.Create(Format(strCoudntloadLib,[asoundlib_path]));
FVolume := 255;
FDevice := 'default';
FBufferSize := 32768;
FSilentOnUnderrun := True;
end;
destructor TALSAAudioOut.Destroy;
begin
if _audio_handle <> nil then snd_pcm_close(_audio_handle);
inherited Destroy;
end;
procedure TALSAAudioOut.Prepare;
var
Res, aBufSize : Integer;
begin
FInput.Init;
Res := snd_pcm_open(_audio_handle, @FDevice[1], SND_PCM_STREAM_PLAYBACK, 0);
if Res < 0 then
raise EACSException.Create(Format(strCoudntopendeviceOut,[FDevice]));
//snd_pcm_reset(_audio_handle);
snd_pcm_hw_params_malloc(_hw_params);
snd_pcm_hw_params_any(_audio_handle, _hw_params);
snd_pcm_hw_params_set_access(_audio_handle, _hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
if FInput.BitsPerSample = 8 then
snd_pcm_hw_params_set_format(_audio_handle, _hw_params, SND_PCM_FORMAT_U8)
else
snd_pcm_hw_params_set_format(_audio_handle, _hw_params, SND_PCM_FORMAT_S16_LE);
snd_pcm_hw_params_set_rate_near(_audio_handle, _hw_params, FInput.SampleRate, 0);
snd_pcm_hw_params_set_channels(_audio_handle, _hw_params, FInput.Channels);
if (FPeriodSize <> 0) and (FPeriodNum <> 0) then
begin
snd_pcm_hw_params_set_period_size_near(_audio_handle, _hw_params, FPeriodSize, 0);
snd_pcm_hw_params_set_periods_near(_audio_handle, _hw_params, FPeriodNum, 0);
aBufSize := (FPeriodSize * FPeriodNum) div (Finput.Channels * (Finput.BitsPerSample shr 3));
end
else aBufSize := Self.FBufferSize div (Finput.Channels * (Finput.BitsPerSample shr 3));
snd_pcm_hw_params_set_buffer_size_near(_audio_handle, _hw_params, aBufSize);
snd_pcm_hw_params(_audio_handle, _hw_params);
snd_pcm_hw_params_free(_hw_params);
if snd_pcm_prepare(_audio_handle) < 0 then
begin
raise EACSException.Create(strFailedtostartoutput);
end;
try
FLatency := snd_pcm_hw_params_get_period_size(_audio_handle, 0) *
snd_pcm_hw_params_get_periods(_audio_handle, 0)/(Finput.Channels * (Finput.BitsPerSample shr 3));
except
end;
end;
procedure TALSAAudioOut.SetDevice(Ch: Integer);
begin
// FDevice := IntToStr(ch);
end;
function TALSAAudioOut.GetDeviceInfo: TACSDeviceInfo;
begin
end;
procedure TALSAAudioOut.Done;
begin
snd_pcm_drain(_audio_handle);
snd_pcm_close(_audio_handle);
_audio_handle := 0;
FInput.Flush;
end;
function TALSAAudioOut.DoOutput(Abort : Boolean):Boolean;
var
Len, i, VCoef, l : Integer;
P : Pointer;
P1 : PACSBuffer8;
P2 : PACSBuffer16;
begin
// No exceptions Here
Result := True;
if not CanOutput then Exit;
Len := 0;
if Abort then
begin
snd_pcm_drain(_audio_handle);
snd_pcm_close(_audio_handle);
_audio_handle := 0;
Result := False;
Exit;
end;
try
P := @Buffer[0];
while InputLock do;
InputLock := True;
Len := Finput.GetData(P, BUF_SIZE);
InputLock := False;
if Len = 0 then
begin
Result := False;
Exit;
end;
if FVolume < 255 then
begin
VCoef := Round(FVolume/255);
if FInput.BitsPerSample = 16 then
begin
P2 := @Buffer[0];
for i := 0 to (Len shr 1) -1 do
P2[i] := P2[i]*VCoef;
end else
begin
P1 := @Buffer[0];
for i := 0 to Len - 1 do
P1[i] := P1[i]*VCoef;
end;
end;
l := snd_pcm_writei(_audio_handle, P, (Len div Finput.Channels) div (FInput.BitsPerSample shr 3));
while l < 0 do
begin
snd_pcm_prepare(_audio_handle);
if not FSilentOnUnderrun then
raise EALSABufferUnderrun.Create(strBufferunderrun);
l := snd_pcm_writei(_audio_handle, P, (Len div Finput.Channels) div (FInput.BitsPerSample shr 3));
end;
if l = (Len div Finput.Channels) div (FInput.BitsPerSample shr 3)
then Result := True
else Result := False;
except
end;
end;
function TALSAAudioOut.GetDriverState : Integer;
begin
if not Busy then Result := ALSAStateIdle
else Result := snd_pcm_state(_audio_handle);
end;
initialization
if AsoundlibLoaded then
begin
RegisterAudioOut('Alsa',TAlsaAudioOut,LATENCY);
RegisterAudioIn('Alsa',TAlsaAudioIn,LATENCY);
end;
end.

View File

@@ -0,0 +1,216 @@
(*
this file is a part of audio components suite v 2.3.
copyright (c) 2002-2005 andrei borovsky. all rights reserved.
see the license file for more details.
you can contact me at mail@z0m3ie.de
*)
{$Log: acs_aolive.pas,v $
{Revision 1.2 2006/01/01 18:46:40 z0m3ie
{*** empty log message ***
{
{Revision 1.1 2005/12/19 18:36:05 z0m3ie
{*** empty log message ***
{
{Revision 1.2 2005/09/14 21:19:37 z0m3ie
{*** empty log message ***
{
{Revision 1.1 2005/09/13 21:53:45 z0m3ie
{maked seperat driver (not complete jet)
{}
unit acs_aolive;
interface
uses
Classes,ACS_Classes,ACS_Audio,libao,SysUtils,ACS_Strings,ACS_Types;
const
LATENCY = 45;//how to measure ?
type
{ TAOLiveAudioOut }
TAOLiveAudioOut = class(TACSBaseAudioOut)
private
_device : PAODevice;
FVolume : Byte;
FDrivers : TStringList;
FCurrentDriver,
FDefaultDriver : String;
function IsDevicePlayable(const Dev : String) : Boolean;
protected
procedure Done; override;
function DoOutput(Abort : Boolean):Boolean; override;
procedure Prepare; override;
procedure SetDevice(Ch : Integer);override;
function GetDeviceInfo : TACSDeviceInfo;override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
implementation
constructor TAOLiveAudioOut.Create;
var
DrList : PPAOInfo;
DrCount, i : Integer;
Info : PAOInfo;
begin
if not LibaoLoaded then
raise EACSException.Create(Format(strCoudntloadlib,[LibaoPath]));
inherited Create(AOwner);
if AOInitialized = 0 then
ao_initialize;
Inc(AOInitialized);
FDrivers := TStringList.Create;
DrList := ao_driver_info_list(DrCount);
for i := 0 to DrCount-1 do
begin
if DrList^._type = AO_TYPE_LIVE then
begin
FDrivers.Add(String(DrList^.short_name));
end;
Inc(DrList);
end;
Info := ao_driver_info(ao_default_driver_id);
FDefaultDriver := Info.short_name;
FVolume := 255;
end;
destructor TAOLiveAudioOut.Destroy;
begin
FDrivers.Free;
if AOInitialized = 1 then
ao_shutdown;
Dec(AOInitialized);
inherited Destroy;
end;
procedure TAOLiveAudioOut.Prepare;
var
did : Integer;
sf : ao_sample_format;
opt : PAOOption;
Info : PAOInfo;
begin
FInput.Init;
if FCurrentDriver = '' then
begin
did := ao_default_driver_id;
Info := ao_driver_info(did);
FCurrentDriver := Info.short_name;
end
else did := ao_driver_id(@FCurrentDriver[1]);
opt := nil;
sf.bits := Finput.BitsPerSample;
sf.rate := Finput.SampleRate;
sf.channels := Finput.Channels;
sf.byte_format := AO_FMT_NATIVE;
_device := ao_open_live(did, @sf, opt);
FreeOptionsList(Opt);
if _device = nil then
raise EACSException.Create(Format(strDevnotplayable,['+FCurrentDriver+']));
end;
procedure TAOLiveAudioOut.SetDevice(Ch: Integer);
begin
if ch < FDrivers.Count-1 then
if IsDevicePlayable(FDrivers[ch]) then
FCurrentDriver := FDrivers[ch];
end;
function TAOLiveAudioOut.GetDeviceInfo: TACSDeviceInfo;
begin
end;
procedure TAOLiveAudioOut.Done;
begin
Finput.Flush;
if _device <> nil then
ao_close(_device);
end;
function TAOLiveAudioOut.DoOutput(Abort : Boolean):Boolean;
var
Len, i : Integer;
P : Pointer;
P1 : PACSBuffer8;
P2 : PACSBuffer16;
begin
// No exceptions Here
Result := True;
if not CanOutput then Exit;
Len := 0;
if Abort then
begin
ao_close(_device);
_device := nil;
Result := False;
Exit;
end;
try
P := @FBuffer[0];
while InputLock do;
InputLock := True;
Len := Finput.GetData(P, FBufferSize);
InputLock := False;
if FVolume < 255 then
begin
if FInput.BitsPerSample = 16 then
begin
P2 := @FBuffer[0];
for i := 0 to (Len shr 1) -1 do
P2[i] := Round(P2[i]*(FVolume/255));
end else
begin
P1 := @FBuffer[0];
for i := 0 to Len - 1 do
P1[i] := Round(P1[i]*(FVolume/255));
end;
end;
ao_play(_device, P, Len);
except
end;
if Len > 0 then Result := True
else Result := False;
end;
function TAOLiveAudioOut.IsDevicePlayable(const Dev : String) : Boolean;
var
i, did : Integer;
sf : ao_sample_format;
opt : PAOOption;
begin
Result := True;
if Dev = '' then Exit;
if Busy then
raise EACSException.Create(strBusy);
for i := 0 to FDrivers.Count-1 do
if FDrivers.Strings[i] = Dev then
begin
did := ao_driver_id(@Dev[1]);
sf.bits := 16;
sf.rate := 22050;
sf.channels := 2;
sf.byte_format := AO_FMT_NATIVE;
opt := nil;
_device := ao_open_live(did, @sf, opt);
if _device <> nil then
begin
ao_close(_device);
FreeOptionsList(Opt);
Exit;
end else Break;
end;
Result := False;
end;
initialization
RegisterAudioOut('AOlive',TAOLiveAudioOut,LATENCY);
end.

View File

@@ -0,0 +1,563 @@
(*
this file is a part of audio components suite v 2.3.
copyright (c) 2002-2005 andrei borovsky. all rights reserved.
see the license file for more details.
you can contact me at mail@z0m3ie.de
*)
{
$Log: acs_dxaudio.pas,v $
Revision 1.7 2006/08/31 20:10:56 z0m3ie
*** empty log message ***
Revision 1.6 2006/07/09 16:40:35 z0m3ie
*** empty log message ***
Revision 1.5 2006/07/04 17:12:45 z0m3ie
ACS 2.4 alt wiederhergestellt (unterschiedliche Sampleformate ...)
Revision 1.3 2006/01/01 18:46:40 z0m3ie
*** empty log message ***
Revision 1.2 2005/12/26 17:31:39 z0m3ie
fixed some problems in acs_dsfiles
fixed some problems in acs_vorbis
reworked all buffers
Revision 1.1 2005/12/19 18:36:05 z0m3ie
*** empty log message ***
Revision 1.9 2005/12/18 17:01:54 z0m3ie
delphi compatibility
Revision 1.8 2005/12/04 16:54:34 z0m3ie
All classes are renamed, Style TACS... than T... to avoid conflicts with other components (eg TMixer is TACSMixer now)
Revision 1.7 2005/10/02 16:51:31 z0m3ie
*** empty log message ***
Revision 1.6 2005/09/23 14:04:58 z0m3ie
*** empty log message ***
Revision 1.5 2005/09/18 19:28:59 z0m3ie
more progress on driver handling
Revision 1.4 2005/09/16 17:34:29 z0m3ie
*** empty log message ***
Revision 1.3 2005/09/15 20:59:38 z0m3ie
start translate the documentation in the source for pasdoc
Revision 1.2 2005/09/14 21:19:37 z0m3ie
*** empty log message ***
Revision 1.1 2005/09/13 21:53:45 z0m3ie
maked seperat driver (not complete jet)
Revision 1.1 2005/09/12 22:04:52 z0m3ie
modified structure again, fileformats are now in an sperat folder.
all File In/Out classes are capsulated from TFileIn and TFileOut
Revision 1.1 2005/08/25 20:18:00 z0m3ie
Version 2.4 restructure
TCDPlayer removed (fits not in component structure)
TMP3ToWavConverter removed (fits not in component structure)
Revision 1.3 2005/08/22 20:17:02 z0m3ie
changed Headers to log
changed mail adress
}
{$ifdef linux}{$message error 'unit not supported'}{$endif linux}
unit acs_dxaudio;
interface
uses
ACS_Audio,SysUtils, Classes, Forms, ACS_Types, ACS_Classes, Windows,ACS_Strings;
const
LATENCY = 25;
DS_POLLING_INTERVAL = 400; //milliseconds
type
TDSoundWrapper = record
dsw_pDirectSound : Pointer;
dsw_OutputBuffer : Pointer;
dsw_WriteOffset : LongWord;
dsw_OutputSize : Integer;
dsw_BytesPerFrame : Integer;
dsw_CounterTicksPerBuffer : Int64;
dsw_LastPlayTime : Int64;
dsw_LastPlayCursor : Int64;
dsw_OutputUnderflows : Int64;
dsw_OutputRunning : LongBool;
dsw_FramesWritten : Double;
dsw_FramesPlayed : Double;
dsw_pDirectSoundCapture : Pointer;
dsw_InputBuffer : Pointer;
dsw_ReadOffset : LongWord;
dsw_InputSize : LongWord;
end;
PDSoundWrapper = ^TDSoundWrapper;
TDSW_DeviceInfo = record
guid : TGUID;
name : array[0..127] of char;
end;
TDSW_Devices = record
devcount : Integer;
dinfo : array [0..15] of TDSW_DeviceInfo;
end;
PDSW_Devices = ^TDSW_Devices;
{ TDXAudioOut }
TDXAudioOut = class(TACSBaseAudioOut)
private
DSW : TDSoundWrapper;
Devices : TDSW_Devices;
Chan, SR, BPS : Integer;
EndOfInput, StartInput : Boolean;
FDeviceNumber : Integer;
FDeviceCount : Integer;
procedure SetDevice(Ch : Integer);override;
function GetDeviceInfo : TACSDeviceInfo;override;
function GetDeviceCount : Integer;override;
protected
procedure Done; override;
function DoOutput(Abort : Boolean):Boolean; override;
procedure Prepare; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Pause;override;
procedure Resume;override;
end;
TDXAudioIn = class(TACSBaseAudioIn)
private
DSW : TDSoundWrapper;
Devices : TDSW_Devices;
FDeviceNumber : Integer;
FDeviceCount : Integer;
FBPS, FChan, FFreq : Integer;
FOpened : Integer;
FBytesToRead : Integer;
FRecTime : Integer;
procedure SetDevice(i : Integer);override;
function GetDeviceName(Number : Integer) : String;
procedure OpenAudio;
procedure CloseAudio;
function GetBPS : Integer; override;
function GetCh : Integer; override;
function GetSR : Integer; override;
function GetTotalTime : real; override;
procedure SetRecTime(aRecTime : Integer);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function GetData(Buffer : Pointer; BufferSize : Integer): Integer; override;
procedure Init; override;
procedure Flush; override;
property DeviceCount : Integer read FDeviceCount;
property DeviceName[Number : Integer] : String read GetDeviceName;
end;
implementation
type
DSW_Init_t = function(dsw: PDSoundWrapper) : HRESULT; cdecl;
DSW_Term_t = procedure(dsw: PDSoundWrapper); cdecl;
DSW_InitOutputDevice_t = function (dsw: PDSoundWrapper; const guid : TGUID) : HRESULT; cdecl;
DSW_InitOutputBuffer_t = function (dsw: PDSoundWrapper; Wnd : HWND; bps, nFrameRate : LongWord; nChannels, bufSize : Integer): HRESULT; cdecl;
DSW_StartOutput_t = function (dsw: PDSoundWrapper) : HRESULT; cdecl;
DSW_StopOutput_t = function(dsw: PDSoundWrapper) : HRESULT; cdecl;
DSW_RestartOutput_t = function(dsw: PDSoundWrapper) : HRESULT; cdecl;
DSW_GetOutputStatus_t = function(dsw: PDSoundWrapper) : DWORD; cdecl;
DSW_WriteBlock_t = function(dsw: PDSoundWrapper; buf : PByte; numBytes : Integer) : HRESULT; cdecl;
DSW_ZeroEmptySpace_t = function(dsw: PDSoundWrapper) : HRESULT; cdecl;
DSW_QueryOutputSpace_t = function(dsw: PDSoundWrapper; var bytesEmpty ) : HRESULT; cdecl;
DSW_Enumerate_t = function(var devices : TDSW_Devices) : HRESULT; cdecl;
DSW_InitInputBuffer_t = function(dsw: PDSoundWrapper; bps, nFrameRate, nChannels, bufSize : Integer) : HRESULT; cdecl;
DSW_InitInputDevice_t = function(dsw: PDSoundWrapper; const GUID : TGUID) : HRESULT; cdecl;
DSW_StartInput_t = function(dsw: PDSoundWrapper) : HRESULT; cdecl;
DSW_StopInput_t = function(dsw: PDSoundWrapper) : HRESULT; cdecl;
DSW_ReadBlock_t = function(dsw: PDSoundWrapper; buf : PByte; numBytes : Integer) : HRESULT; cdecl;
DSW_QueryInputFilled_t = function(dsw: PDSoundWrapper; var bytesFilled : Integer) : HRESULT; cdecl;
var
LibdswLoaded : Boolean = False;
DSW_Init : DSW_Init_t;
DSW_Term : DSW_Term_t;
DSW_InitOutputDevice : DSW_InitOutputDevice_t;
DSW_InitOutputBuffer : DSW_InitOutputBuffer_t;
DSW_StartOutput : DSW_StartOutput_t;
DSW_StopOutput : DSW_StopOutput_t;
DSW_RestartOutput : DSW_RestartOutput_t;
DSW_GetOutputStatus : DSW_GetOutputStatus_t;
DSW_WriteBlock : DSW_WriteBlock_t;
DSW_ZeroEmptySpace : DSW_ZeroEmptySpace_t;
DSW_QueryOutputSpace : DSW_QueryOutputSpace_t;
DSW_Enumerate : DSW_Enumerate_t;
DSW_InitInputBuffer : DSW_InitInputBuffer_t;
DSW_InitInputDevice : DSW_InitInputDevice_t;
DSW_StartInput : DSW_StartInput_t;
DSW_StopInput : DSW_StopInput_t;
DSW_ReadBlock : DSW_ReadBlock_t;
DSW_QueryInputFilled : DSW_QueryInputFilled_t;
Libhandle : HMODULE;
procedure TDXAudioOut.Prepare;
var
Res : HResult;
Wnd : HWND;
Form : TForm;
begin
if (FDeviceNumber >= FDeviceCount) then raise EACSException.Create(Format(strChannelnotavailable,[FDeviceNumber]));
FInput.Init;
FBuffer := AllocMem(FBufferSize);
Chan := FInput.Channels;
SR := FInput.SampleRate;
BPS := FInput.BitsPerSample;
DSW_Init(@DSW);
Res := DSW_InitOutputDevice(@DSW, Devices.dinfo[FDeviceNumber].guid);
if Res <> 0 then raise EACSException.Create(strFailedtoCreateDSdev);
{ if Owner is TForm then
begin
Form := Owner as TForm;
Wnd := Form.Handle;
end else }
Wnd := 0;
Res := DSW_InitOutputBuffer(@DSW, Wnd, BPS, SR, Chan, FBufferSize);
if Res <> 0 then raise EACSException.Create(strFailedtoCreateDSbuf);
StartInput := True;
EndOfInput := False;
end;
procedure TDXAudioOut.Done;
begin
Finput.Flush;
DSW_Term(@DSW);
FreeMem(FBuffer);
end;
function TDXAudioOut.DoOutput(Abort : Boolean):Boolean;
var
Len, offs, lb : Integer;
Stat : LongWord;
Res : HRESULT;
PlayTime, CTime : LongWord;
begin
Result := True;
if not Busy then Exit;
if not CanOutput then
begin
Result := False;
Exit;
end;
if Abort then
begin
DSW_StopOutput(@DSW);
CanOutput := False;
Result := False;
Exit;
end;
if StartInput then
begin
Len := 0;
while Len < FBufferSize do
begin
offs := FInput.GetData(@FBuffer^[Len], FBufferSize-Len);
if offs = 0 then
begin
EndOfInput := True;
Break;
end;
Inc(Len, offs);
end;
DSW_WriteBlock(@DSW, @FBuffer^, Len);
DSW_StartOutput(@DSW);
StartInput := False;
end;
if EndOfInput then
begin
CanOutput := False;
PlayTime := Round(FBufferSize/(Chan*(BPS div 8)*SR))*1000;
CTime := 0;
while CTime < PlayTime do
begin
Sleep(100);
DSW_ZeroEmptySpace(@DSW);
Inc(CTime, 100);
end;
DSW_StopOutput(@DSW);
Result := False;
Exit;
end;
Sleep(DS_POLLING_INTERVAL);
DSW_QueryOutputSpace(@DSW, lb);
lb := lb - (lb mod 1024);
Len := 0;
while Len < lb do
begin
if FInput.Busy then
begin
try
offs := Finput.GetData(@FBuffer^[Len], lb-Len);
except
DSW_StopOutput(@DSW);
CanOutput := False;
Result := False;
Exit;
end;
end;
if offs = 0 then Break;
Inc(Len, offs);
end;
DSW_WriteBlock(@DSW, @Fbuffer^, Len);
if offs = 0 then
begin
DSW_ZeroEmptySpace(@DSW);
EndOfInput := True;
end;
end;
constructor TDXAudioOut.Create;
begin
inherited Create(AOwner);
FBufferSize := $40000;
if not (csDesigning in ComponentState) then
begin
if not LibdswLoaded then
raise EACSException.Create(Format(strCoudntloadlib,['dswrapper.dll']));
end;
if LibdswLoaded then DSW_Enumerate(Devices);
FDeviceCount := Devices.devcount;
end;
destructor TDXAudioOut.Destroy;
begin
if LibdswLoaded then DSW_Term(@DSW);
end;
procedure TDXAudioOut.Pause;
begin
if EndOfInput then Exit;
DSW_StopOutput(@DSW);
end;
procedure TDXAudioOut.Resume;
begin
if EndOfInput then Exit;
DSW_RestartOutput(@DSW);
end;
procedure TDXAudioOut.SetDevice(Ch: Integer);
begin
FBaseChannel := Ch;
end;
function TDXAudioOut.GetDeviceInfo: TACSDeviceInfo;
begin
if (FBaseChannel >= FDeviceCount) then
exit;
Result.DeviceName := PChar(@(Devices.dinfo[FBaseChannel].Name[0]));
end;
function TDXAudioOut.GetDeviceCount: Integer;
begin
Result := FDeviceCount;
end;
constructor TDXAudioIn.Create;
begin
inherited Create(AOwner);
FBPS := 8;
FChan := 1;
FFreq := 8000;
FSize := -1;
BufferSize := $2000;
if not (csDesigning in ComponentState) then
begin
if not LibdswLoaded then
raise EACSException.Create(Format(strCoudntloadlib,['dswrapper.dll']));
end;
if LibdswLoaded then DSW_Enumerate(Devices);
FDeviceCount := Devices.devcount;
end;
destructor TDXAudioIn.Destroy;
begin
if LibdswLoaded then DSW_Term(@DSW);
inherited Destroy;
end;
procedure TDXAudioIn.OpenAudio;
var
Res : HResult;
BufSize : Integer;
begin
BufSize := BufferSize;
if FOpened = 0 then
begin
DSW_Init(@DSW);
if not Assigned(DSW_InitInputDevice) then raise EACSException.Create(Format(strChannelNotAvailable,[FDeviceNumber]));
Res := DSW_InitInputDevice(@DSW, Devices.dinfo[FDeviceNumber].guid);
if Res <> 0 then raise EACSException.Create(strFailedtoCreateDSdev);
Res := DSW_InitInputBuffer(@DSW, FBPS, FFreq, FChan, BufSize);
if Res <> 0 then raise EACSException.Create(strFailedtoCreateDSbuf);
end;
Inc(FOpened);
end;
procedure TDXAudioIn.CloseAudio;
begin
if FOpened = 1 then DSW_Term(@DSW);
if FOpened > 0 then Dec(FOpened);
end;
function TDXAudioIn.GetBPS : Integer;
begin
Result := FBPS;
end;
function TDXAudioIn.GetCh : Integer;
begin
Result := FChan;
end;
function TDXAudioIn.GetSR : Integer;
begin
Result := FFreq;
end;
procedure TDXAudioIn.Init;
begin
if Busy then raise EACSException.Create(strBusy);
if (FDeviceNumber >= FDeviceCount) then raise EACSException.Create(Format(strChannelnotavailable,[FDeviceNumber]));
if FRecTime > 0 then FBytesToRead := FRecTime*FFreq*FChan*(FBPS div 8);
BufEnd := 0;
BufStart := 1;
FPosition := 0;
FBusy := True;
FSize := FBytesToRead;
OpenAudio;
DSW_StartInput(@DSW);
end;
procedure TDXAudioIn.Flush;
begin
DSW_StopInput(@DSW);
CloseAudio;
FBusy := False;
end;
function TDXAudioIn.GetData(Buffer : Pointer; BufferSize : Integer): Integer;
var
l : Integer;
begin
if not Busy then raise EACSException.Create(strStreamnotopen);
if (FBytesToRead >=0) and (FPosition >= FBytesToRead) then
begin
Result := 0;
Exit;
end;
if BufStart >= BufEnd then
begin
BufStart := 0;
Sleep(DS_POLLING_INTERVAL);
DSW_QueryInputFilled(@DSW, l);
if l > BufferSize then
l := BufferSize; (* We have lost some data.
Generally this shouldn't happen. *)
l := l - (l mod 1024);
DSW_ReadBlock(@DSW, @FBuffer, l);
BufEnd := l;
end;
if BufferSize < (BufEnd - BufStart)
then Result := BufferSize
else Result := BufEnd - BufStart;
Move(FBuffer[BufStart], Buffer^, Result);
Inc(BufStart, Result);
Inc(FPosition, Result);
end;
procedure TDXAudioIn.SetRecTime;
begin
FRecTime := aRecTime;
if FRecTime > 0 then
FBytesToRead := FRecTime*FFreq*FChan*(FBPS div 8)
else
FBytesToRead := -1;
end;
procedure TDXAudioIn.SetDevice(i : Integer);
begin
FDeviceNumber := i
end;
function TDXAudioIn.GetDeviceName(Number : Integer) : String;
begin
if (Number < FDeviceCount) then Result := PChar(@(Devices.dinfo[Number].Name[0]))
else Result := '';
end;
function TDXAudioIn.GetTotalTime : real;
var
BytesPerSec : Integer;
begin
BytesPerSec := FFreq*FChan*(FBPS div 8);
Result := FBytesToRead/BytesPerSec;
end;
initialization
Libhandle := LoadLibraryEx('dswrapper.dll', 0, 0);
if Libhandle <> 0 then
begin
LibdswLoaded := True;
DSW_Init := GetProcAddress(Libhandle, 'DSW_Init');
DSW_Term := GetProcAddress(Libhandle, 'DSW_Term');
DSW_InitOutputDevice := GetProcAddress(Libhandle, 'DSW_InitOutputDevice');
DSW_InitOutputBuffer := GetProcAddress(Libhandle, 'DSW_InitOutputBuffer');
DSW_StartOutput := GetProcAddress(Libhandle, 'DSW_StartOutput');
DSW_StopOutput := GetProcAddress(Libhandle, 'DSW_StopOutput');
DSW_RestartOutput := GetProcAddress(Libhandle, 'DSW_RestartOutput');
DSW_GetOutputStatus := GetProcAddress(Libhandle, 'DSW_GetOutputStatus');
DSW_WriteBlock := GetProcAddress(Libhandle, 'DSW_WriteBlock');
DSW_ZeroEmptySpace := GetProcAddress(Libhandle, 'DSW_ZeroEmptySpace');
DSW_QueryOutputSpace := GetProcAddress(Libhandle, 'DSW_QueryOutputSpace');
DSW_Enumerate := GetProcAddress(Libhandle, 'DSW_Enumerate');
DSW_InitInputDevice := GetProcAddress(Libhandle, 'DSW_InitInputDevice');
DSW_InitInputBuffer := GetProcAddress(Libhandle, 'DSW_InitInputBuffer');
DSW_StartInput := GetProcAddress(Libhandle, 'DSW_StartInput');
DSW_StopInput := GetProcAddress(Libhandle, 'DSW_StopInput');
DSW_ReadBlock := GetProcAddress(Libhandle, 'DSW_ReadBlock');
DSW_QueryInputFilled := GetProcAddress(Libhandle, 'DSW_QueryInputFilled');
end;
RegisterAudioOut('DirectSound',TDXAudioOut,LATENCY);
RegisterAudioIn('DirectSound',TDXAudioIn,LATENCY);
finalization
if Libhandle <> 0 then FreeLibrary(Libhandle);
end.

View File

@@ -0,0 +1,232 @@
(*
this file is a part of audio components suite v 2.3 (delphi version).
copyright (c) 2002-2005 andrei borovsky. all rights reserved.
see the license file for more details.
you can contact me at acs@compiler4.net
this is the acs for delphi (windows) version of the unit.
*)
{
$Log: acs_stdaudio.pas,v $
Revision 1.6 2006/07/04 17:12:45 z0m3ie
ACS 2.4 alt wiederhergestellt (unterschiedliche Sampleformate ...)
Revision 1.4 2006/01/01 18:46:40 z0m3ie
*** empty log message ***
Revision 1.3 2005/12/30 11:10:57 z0m3ie
some corrections to lazarus-linux depending things
Revision 1.2 2005/12/26 17:31:39 z0m3ie
fixed some problems in acs_dsfiles
fixed some problems in acs_vorbis
reworked all buffers
Revision 1.1 2005/12/19 18:36:05 z0m3ie
*** empty log message ***
Revision 1.8 2005/12/04 16:54:34 z0m3ie
All classes are renamed, Style TACS... than T... to avoid conflicts with other components (eg TMixer is TACSMixer now)
Revision 1.7 2005/11/27 16:50:33 z0m3ie
add ACS VolumeQuerry
make ACS_VolumeQuerry localizeable
some little errorfixes (buffersize for linuxdrivers was initially 0)
make TAudioIn workable
Revision 1.6 2005/10/05 20:26:36 z0m3ie
Linux changes
Revision 1.5 2005/10/02 16:51:31 z0m3ie
*** empty log message ***
Revision 1.4 2005/09/23 14:04:58 z0m3ie
*** empty log message ***
Revision 1.3 2005/09/18 19:28:59 z0m3ie
more progress on driver handling
Revision 1.2 2005/09/14 21:19:37 z0m3ie
*** empty log message ***
Revision 1.1 2005/09/13 21:53:45 z0m3ie
maked seperat driver (not complete jet)
Revision 1.1 2005/09/12 22:04:52 z0m3ie
modified structure again, fileformats are now in an sperat folder.
all File In/Out classes are capsulated from TFileIn and TFileOut
Revision 1.3 2005/09/02 16:27:49 z0m3ie
*** empty log message ***
Revision 1.2 2005/08/28 20:31:17 z0m3ie
linux restructuring for 2.4
Revision 1.1 2005/08/25 20:18:00 z0m3ie
Version 2.4 restructure
TCDPlayer removed (fits not in component structure)
TMP3ToWavConverter removed (fits not in component structure)
Revision 1.4 2005/08/22 20:17:02 z0m3ie
changed Headers to log
changed mail adress
}
unit acs_stdaudio;
{$ifdef fpc}
{$mode delphi}
{$endif}
interface
uses
Classes, SysUtils, ACS_Types, ACS_Classes,ACS_Audio,ACS_Strings
{$IFDEF MSWINDOWS}
, Windows, MMSystem
{$ELSE}
, Soundcard
{$ENDIF}
;
const
LATENCY = 110;
type
{$IFDEF MSWINDOWS}
{$IFDEF FPC}
TWaveInCapsA = WAVEINCAPSA;
TWaveInCaps = TWaveInCapsA;
TWaveHdr = WAVEHDR;
{$ENDIF}
PPWaveHdr = ^PWaveHdr;
{$ENDIF}
{ TStdAudioOut }
TStdAudioOut = class(TACSBaseAudioOut)
private
{$IFDEF MSWINDOWS}
BlockChain : PWaveHdr;
aBlock : Integer;
EOC : PPWaveHdr;
FReadChunks : Integer;
{$ENDIF}
_audio_fd : Integer;
procedure SetDevice(Ch : Integer);override;
function GetDeviceInfo : TACSDeviceInfo;override;
{$IFDEF MSWINDOWS}
procedure WriteBlock(P : Pointer; Len : Integer);
procedure AddBlockToChain(WH : PWaveHdr);
{$ENDIF}
function GetDeviceCount : Integer;override;
protected
procedure Done; override;
function DoOutput(Abort : Boolean):Boolean; override;
procedure Prepare; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
TStdAudioIn = class(TACSBaseAudioIn)
private
{$IFDEF MSWINDOWS}
BlockChain : PWaveHdr;
FBlocksCount : Integer;
aBlock : Integer;
EOC : PPWaveHdr;
{$ENDIF}
_audio_fd : Integer;
FOpened : Integer;
FRecBytes : Integer;
procedure OpenAudio;
procedure CloseAudio;
function GetBPS : Integer; override;
function GetCh : Integer; override;
function GetSR : Integer; override;
procedure SetDevice(Ch : Integer);override;
function GetDeviceInfo : TACSDeviceInfo;override;
function GetTotalTime : real; override;
{$IFDEF MSWINDOWS}
procedure NewBlock;
procedure AddBlockToChain(WH : PWaveHdr);
{$ENDIF}
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function GetData(Buffer : Pointer; oBufferSize : Integer): Integer; override;
procedure Init; override;
procedure Flush; override;
end;
var
InputChannelsCount : Integer;
OutputChannelsCount : Integer;
function GetAudioDeviceInfo(DevID : Integer; OutputDev : Boolean) : TACSDeviceInfo;
implementation
var
CrSecI, CrSecO : TRTLCriticalSection;
{$IFDEF MSWINDOWS}
{$I windows\acs_audio.inc}
{$ELSE}
{$I linux\acs_audio.inc}
{$ENDIF}
function TStdAudioOut.GetDeviceInfo : TACSDeviceInfo;
begin
Result := GetAudioDeviceInfo(FBaseChannel, True);
end;
function TStdAudioIn.GetDeviceInfo : TACSDeviceInfo;
begin
Result := GetAudioDeviceInfo(FBaseChannel, False);
end;
function TStdAudioIn.GetTotalTime : real;
begin
Result := RecTime;
end;
constructor TStdAudioIn.Create;
begin
inherited Create(AOwner);
FBPS := 8;
FChan := 1;
FFreq := 8000;
FSize := -1;
FRecTime := 600;
BufferSize := $1000;
{$IFDEF MSWINDOWS}
FBlocksCount := 4;
{$ENDIF}
end;
function TStdAudioOut.GetDeviceCount : Integer;
begin
Result := OutputChannelsCount;
end;
initialization
{$IFDEF MSWINDOWS}
InitializeCriticalSection(CrSecI);
InitializeCriticalSection(CrSecO);
{$ENDIF}
CountChannels;
RegisterAudioOut('Wavemapper',TStdAudioOut,LATENCY);
RegisterAudioIn('Wavemapper',TStdAudioIn,LATENCY);
finalization
{$IFDEF MSWINDOWS}
DeleteCriticalSection(CrSecI);
DeleteCriticalSection(CrSecO);
{$ENDIF}
end.

View File

@@ -0,0 +1,266 @@
{
$Log
}
const
MAX_CHANNELS = 16; // Maximum number of audio channels/devices
O_RDONLY = 0;
O_WRONLY = 1;
libname = 'libc.so.6';
var
AudioChannels : array[0..MAX_CHANNELS-1] of String;
(* We import libc functions directly to avoid Kylix
Libc unit limitations *)
function __write(fd : Integer; data : Pointer; size : Integer): Integer; cdecl; external libname;
function __read(Handle: Integer; var Buffer; Count: Integer): Integer; cdecl; external libname;
function ioctl(fd : Integer; command : Integer): Integer; varargs; cdecl; external libname;
function open(PathName: PChar; Flags: Integer): Integer; varargs; cdecl; external libname;
function __close(Handle: Integer): Integer; cdecl; external libname;
function GetAudioDeviceInfo(DevID : Integer; OutputDev : Boolean) : TACSDeviceInfo;
begin
Result.DeviceName := '/dev/dsp'+IntToStr(DevID);
Result.DrvVersion := 0;
Result.Formats := [];
Result.Stereo := True;
end;
procedure TStdAudioOut.SetDevice;
begin
if Busy then raise EACSException.Create(strBusy);
if Ch < OutputChannelsCount then FBaseChannel := Ch
else raise EACSException.Create(Format(strChannelnotavailable,[ch]));
end;
procedure TStdAudioOut.Prepare;
var
parm : Integer;
begin
GetMem(FBuffer,FBufferSize);
// No exceptions here!
FInput.Init;
case FInput.BitsPerSample of
8 : parm := AFMT_U8;
16 : parm := AFMT_S16_LE;
end;
_audio_fd := open(PChar(AudioChannels[FBaseChannel]), O_WRONLY);
ioctl(_audio_fd, SNDCTL_DSP_SETFMT, @parm);
parm := FInput.Channels;
ioctl(_audio_fd, SNDCTL_DSP_CHANNELS, @parm);
parm := FInput.SampleRate;
ioctl(_audio_fd, SNDCTL_DSP_SPEED, @parm);
end;
procedure TStdAudioOut.Done;
begin
//TODO:why this raises an exception ?? FreeMem(FBuffer);
__close(_audio_fd);
_audio_fd := -1;
FInput.Flush;
end;
function TStdAudioOut.DoOutput;
var
Len, i, VCoef : Integer;
P : Pointer;
P1 : PACSBuffer8;
P2 : PACSBuffer16;
begin
// No exceptions Here
Result := True;
if not CanOutput then Exit;
Len := 0;
if Abort then
begin
__close(_audio_fd);
Result := False;
Exit;
end;
try
P := @FBuffer[0];
while InputLock do;
InputLock := True;
Len := Finput.GetData(P, FBufferSize);
InputLock := False;
if FVolume < 255 then
begin
VCoef := Round(FVolume/255);
if FInput.BitsPerSample = 16 then
begin
P2 := @FBuffer[0];
for i := 0 to (Len shr 1) -1 do
P2[i] := P2[i]*VCoef;
end else
begin
P1 := @FBuffer[0];
for i := 0 to Len - 1 do
P1[i] := P1[i]*VCoef;
end;
end;
__write(_audio_fd, P, Len);
except
end;
if Len > 0 then Result := True
else Result := False;
end;
constructor TStdAudioOut.Create;
begin
inherited Create(AOwner);
FVolume := 255;
FBufferSize := $8000;
_audio_fd := -1;
end;
destructor TStdAudioOut.Destroy;
begin
if _audio_fd > 0 then __close(_audio_fd);
inherited Destroy;
end;
destructor TStdAudioIn.Destroy;
begin
inherited Destroy;
__close(_audio_fd);
end;
procedure TStdAudioIn.OpenAudio;
begin
if FOpened = 0 then
_audio_fd := open(PChar(AudioChannels[FBaseChannel]), O_RDONLY);
Inc(FOpened);
end;
procedure TStdAudioIn.CloseAudio;
begin
if FOpened = 1 then __close(_audio_fd);
if FOpened > 0 then Dec(FOpened);
end;
function TStdAudioIn.GetBPS;
var
BPS : Integer;
begin
OpenAudio;
BPS := FBPS;
if (BPS in [8, 16]) = False then BPS := 16;
ioctl(_audio_fd, SNDCTL_DSP_SETFMT, @BPS);
FBPS := BPS;
Result := BPS;
CloseAudio;
end;
function TStdAudioIn.GetCh;
var
Ch : Integer;
begin
OpenAudio;
Ch := FChan;
ioctl(_audio_fd, SNDCTL_DSP_CHANNELS, @Ch);
FChan := Ch;
Result := Ch;
CloseAudio;
end;
function TStdAudioIn.GetSR;
var
SR : Integer;
begin
OpenAudio;
SR := FFreq;
ioctl(_audio_fd, SNDCTL_DSP_SPEED, @SR);
FFreq := SR;
Result := SR;
CloseAudio;
end;
procedure TStdAudioIn.Init;
begin
if Busy then raise EACSException.Create(strBusy);
BufEnd := 0;
BufStart := 1;
FPosition := 0;
BufferSize := $8000;
OpenAudio;
FRecBytes := FRecTime * (GetBPS div 8) * GetCh * GetSR;
FBusy := True;
FSize := FRecBytes;
end;
procedure TStdAudioIn.Flush;
begin
CloseAudio;
FBusy := False;
end;
procedure TStdAudioIn.SetDevice;
begin
if Ch > (OutputChannelsCount - 1) then
if not (csDesigning in ComponentState) then
raise EACSException.Create(Format(strChannelnotavailable,[Ch]));
FBaseChannel := Ch;
end;
function TStdAudioIn.GetData;
var
l : Integer;
begin
if not Busy then raise EACSException.Create(strStreamnotOpen);
if FRecBytes >= 0 then
if FPosition >= FRecBytes then
begin
Result := 0;
Exit;
end;
if BufStart > BufEnd then
begin
BufStart := 1;
l := __read(_audio_fd, FBuffer[BufStart], BufferSize);
if l < 1 then
begin
Result := 0;
Exit;
end
else BufEnd := l;
end;
if BufferSize < (BufEnd - BufStart + 1)
then Result := BufferSize
else Result := BufEnd - BufStart + 1;
Move(FBuffer[BufStart], Buffer^, Result);
Inc(BufStart, Result);
Inc(FPosition, Result);
end;
procedure CountChannels;
var
i, fd : Integer;
fname : String;
begin
OutputChannelsCount := 0;
fname := '/dev/dsp0';
fd := open(PChar(fname), O_RDONLY);
if fd < 0 then
begin
// Under ALSA there is no /dev/dsp0 device
fname := '/dev/dsp';
fd := open(PChar(fname), O_RDONLY);
if fd < 0 then Exit;
end;
AudioChannels[OutputChannelsCount] := fname;
__close(fd);
Inc(OutputChannelsCount);
for i := 1 to MAX_CHANNELS - 2 do
begin
fname := '/dev/dsp' + IntToStr(i);
fd := open(PChar(fname), O_RDONLY);
if fd < 0 then Break;
__close(fd);
AudioChannels[OutputChannelsCount] := fname;
Inc(OutputChannelsCount);
end;
end;

View File

@@ -0,0 +1,907 @@
(*
application interface library for the alsa driver
free pascal / kylix import unit
converted from file <alsa/asoundlib.h>
ALSA library is copyrighted by its authors:
Jaroslav Kysela <perex@suse.cz>
Abramo Bagnara <abramo@alsa-project.org>
Takashi Iwai <tiwai@suse.de>
Pascal translation:
Copyright (C) 2002, Pedro Lopez-Cabanillas <plcl@bigfoot.com>
Modified by Andrei Borovsky, 01-06-2003
Note by A.B.: currently only <alsa/pcm.h> translation is included in this file.
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
*)
(* attention! in this unit asoundlib is linked dynamically.
In order to decrease loading time, only the symbols needed by ACS
are actually resolved. *)
{
$Log: alsa.pas,v $
Revision 1.6 2006/08/30 18:59:51 z0m3ie
*** empty log message ***
Revision 1.5 2006/07/04 17:12:45 z0m3ie
ACS 2.4 alt wiederhergestellt (unterschiedliche Sampleformate ...)
Revision 1.3 2005/12/19 18:36:16 z0m3ie
*** empty log message ***
Revision 1.1 2005/09/14 21:19:37 z0m3ie
*** empty log message ***
Revision 1.1 2005/09/12 22:04:52 z0m3ie
modified structure again, fileformats are now in an sperat folder.
all File In/Out classes are capsulated from TFileIn and TFileOut
Revision 1.1 2005/08/25 20:18:00 z0m3ie
Version 2.4 restructure
TCDPlayer removed (fits not in component structure)
TMP3ToWavConverter removed (fits not in component structure)
Revision 1.2 2005/08/22 20:17:01 z0m3ie
changed Headers to log
changed mail adress
}
unit alsa;
interface
uses
baseunix,ACS_Procs;
const
asoundlib_path = 'libasound.so*';
var
AsoundlibLoaded : Boolean = False;
type
Pint16_t = ^int16_t;
{ PCM generic info container }
Psnd_pcm_info_t = pointer;
{ PCM hardware configuration space container }
Psnd_pcm_hw_params_t = pointer;
{ PCM software configuration container }
Psnd_pcm_sw_params_t = pointer;
{ PCM status container }
Psnd_pcm_status_t = pointer;
{ PCM access types mask }
Psnd_pcm_access_mask_t = pointer;
{ PCM formats mask }
Psnd_pcm_format_mask_t = pointer;
{ PCM subformats mask }
Psnd_pcm_subformat_mask_t = pointer;
Psnd_config_t = pointer;
Psnd_async_handler_t = pointer;
Psnd_output_t = Pointer;
{ PCM class }
_snd_pcm_class = Longint;
snd_pcm_class_t = _snd_pcm_class;
const
SND_PCM_CLASS_GENERIC = 0; { standard device }
SND_PCM_CLASS_MULTI = 1; { multichannel device }
SND_PCM_CLASS_MODEM = 2; { software modem device }
SND_PCM_CLASS_DIGITIZER = 3; { digitizer device }
SND_PCM_CLASS_LAST = SND_PCM_CLASS_DIGITIZER;
type
{ PCM subclass }
_snd_pcm_subclass = Longint;
snd_pcm_subclass_t = _snd_pcm_subclass;
const
SND_PCM_SUBCLASS_GENERIC_MIX = 0; { subdevices are mixed together }
SND_PCM_SUBCLASS_MULTI_MIX = 1; { multichannel subdevices are mixed together }
SND_PCM_SUBCLASS_LAST = SND_PCM_SUBCLASS_MULTI_MIX;
type
{ PCM stream (direction) }
_snd_pcm_stream = Longint;
snd_pcm_stream_t = _snd_pcm_stream;
const
SND_PCM_STREAM_PLAYBACK = 0; { Playback stream }
SND_PCM_STREAM_CAPTURE = 1; { Capture stream }
SND_PCM_STREAM_LAST = SND_PCM_STREAM_CAPTURE;
type
{ PCM access type }
_snd_pcm_access = Longint;
snd_pcm_access_t = _snd_pcm_access;
const
SND_PCM_ACCESS_MMAP_INTERLEAVED = 0; { mmap access with simple interleaved channels }
SND_PCM_ACCESS_MMAP_NONINTERLEAVED = 1; { mmap access with simple non interleaved channels }
SND_PCM_ACCESS_MMAP_COMPLEX = 2; { mmap access with complex placement }
SND_PCM_ACCESS_RW_INTERLEAVED = 3; { snd_pcm_readi/snd_pcm_writei access }
SND_PCM_ACCESS_RW_NONINTERLEAVED = 4; { snd_pcm_readn/snd_pcm_writen access }
SND_PCM_ACCESS_LAST = SND_PCM_ACCESS_RW_NONINTERLEAVED;
type
{ PCM sample format }
_snd_pcm_format = Longint;
snd_pcm_format_t = _snd_pcm_format;
const
{ Unknown }
SND_PCM_FORMAT_UNKNOWN = -1;
{ Signed 8 bit }
SND_PCM_FORMAT_S8 = 0;
{ Unsigned 8 bit }
SND_PCM_FORMAT_U8 = 1;
{ Signed 16 bit Little Endian }
SND_PCM_FORMAT_S16_LE = 2;
{ Signed 16 bit Big Endian }
SND_PCM_FORMAT_S16_BE = 3;
{ Unsigned 16 bit Little Endian }
SND_PCM_FORMAT_U16_LE = 4;
{ Unsigned 16 bit Big Endian }
SND_PCM_FORMAT_U16_BE = 5;
{ Signed 24 bit Little Endian }
SND_PCM_FORMAT_S24_LE = 6;
{ Signed 24 bit Big Endian }
SND_PCM_FORMAT_S24_BE = 7;
{ Unsigned 24 bit Little Endian }
SND_PCM_FORMAT_U24_LE = 8;
{ Unsigned 24 bit Big Endian }
SND_PCM_FORMAT_U24_BE = 9;
{ Signed 32 bit Little Endian }
SND_PCM_FORMAT_S32_LE = 10;
{ Signed 32 bit Big Endian }
SND_PCM_FORMAT_S32_BE = 11;
{ Unsigned 32 bit Little Endian }
SND_PCM_FORMAT_U32_LE = 12;
{ Unsigned 32 bit Big Endian }
SND_PCM_FORMAT_U32_BE = 13;
{ Float 32 bit Little Endian, Range -1.0 to 1.0 }
SND_PCM_FORMAT_FLOAT_LE = 14;
{ Float 32 bit Big Endian, Range -1.0 to 1.0 }
SND_PCM_FORMAT_FLOAT_BE = 15;
{ Float 64 bit Little Endian, Range -1.0 to 1.0 }
SND_PCM_FORMAT_FLOAT64_LE = 16;
{ Float 64 bit Big Endian, Range -1.0 to 1.0 }
SND_PCM_FORMAT_FLOAT64_BE = 17;
{ IEC-958 Little Endian }
SND_PCM_FORMAT_IEC958_SUBFRAME_LE = 18;
{ IEC-958 Big Endian }
SND_PCM_FORMAT_IEC958_SUBFRAME_BE = 19;
{ Mu-Law }
SND_PCM_FORMAT_MU_LAW = 20;
{ A-Law }
SND_PCM_FORMAT_A_LAW = 21;
{ Ima-ADPCM }
SND_PCM_FORMAT_IMA_ADPCM = 22;
{ MPEG }
SND_PCM_FORMAT_MPEG = 23;
{ GSM }
SND_PCM_FORMAT_GSM = 24;
{ Special }
SND_PCM_FORMAT_SPECIAL = 31;
{ Signed 24bit Little Endian in 3bytes format }
SND_PCM_FORMAT_S24_3LE = 32;
{ Signed 24bit Big Endian in 3bytes format }
SND_PCM_FORMAT_S24_3BE = 33;
{ Unsigned 24bit Little Endian in 3bytes format }
SND_PCM_FORMAT_U24_3LE = 34;
{ Unsigned 24bit Big Endian in 3bytes format }
SND_PCM_FORMAT_U24_3BE = 35;
{ Signed 20bit Little Endian in 3bytes format }
SND_PCM_FORMAT_S20_3LE = 36;
{ Signed 20bit Big Endian in 3bytes format }
SND_PCM_FORMAT_S20_3BE = 37;
{ Unsigned 20bit Little Endian in 3bytes format }
SND_PCM_FORMAT_U20_3LE = 38;
{ Unsigned 20bit Big Endian in 3bytes format }
SND_PCM_FORMAT_U20_3BE = 39;
{ Signed 18bit Little Endian in 3bytes format }
SND_PCM_FORMAT_S18_3LE = 40;
{ Signed 18bit Big Endian in 3bytes format }
SND_PCM_FORMAT_S18_3BE = 41;
{ Unsigned 18bit Little Endian in 3bytes format }
SND_PCM_FORMAT_U18_3LE = 42;
{ Unsigned 18bit Big Endian in 3bytes format }
SND_PCM_FORMAT_U18_3BE = 43;
SND_PCM_FORMAT_LAST = SND_PCM_FORMAT_U18_3BE;
{$IFDEF ENDIAN_LITTLE}
{ Signed 16 bit CPU endian }
SND_PCM_FORMAT_S16 = SND_PCM_FORMAT_S16_LE;
{ Unsigned 16 bit CPU endian }
SND_PCM_FORMAT_U16 = SND_PCM_FORMAT_U16_LE;
{ Signed 24 bit CPU endian }
SND_PCM_FORMAT_S24 = SND_PCM_FORMAT_S24_LE;
{ Unsigned 24 bit CPU endian }
SND_PCM_FORMAT_U24 = SND_PCM_FORMAT_U24_LE;
{ Signed 32 bit CPU endian }
SND_PCM_FORMAT_S32 = SND_PCM_FORMAT_S32_LE;
{ Unsigned 32 bit CPU endian }
SND_PCM_FORMAT_U32 = SND_PCM_FORMAT_U32_LE;
{ Float 32 bit CPU endian }
SND_PCM_FORMAT_FLOAT = SND_PCM_FORMAT_FLOAT_LE;
{ Float 64 bit CPU endian }
SND_PCM_FORMAT_FLOAT64 = SND_PCM_FORMAT_FLOAT64_LE;
{ IEC-958 CPU Endian }
SND_PCM_FORMAT_IEC958_SUBFRAME = SND_PCM_FORMAT_IEC958_SUBFRAME_LE;
{$ENDIF}
{$IFDEF ENDIAN_BIG}
{ Signed 16 bit CPU endian }
SND_PCM_FORMAT_S16 = SND_PCM_FORMAT_S16_BE;
{ Unsigned 16 bit CPU endian }
SND_PCM_FORMAT_U16 = SND_PCM_FORMAT_U16_BE;
{ Signed 24 bit CPU endian }
SND_PCM_FORMAT_S24 = SND_PCM_FORMAT_S24_BE;
{ Unsigned 24 bit CPU endian }
SND_PCM_FORMAT_U24 = SND_PCM_FORMAT_U24_BE;
{ Signed 32 bit CPU endian }
SND_PCM_FORMAT_S32 = SND_PCM_FORMAT_S32_BE;
{ Unsigned 32 bit CPU endian }
SND_PCM_FORMAT_U32 = SND_PCM_FORMAT_U32_BE;
{ Float 32 bit CPU endian }
SND_PCM_FORMAT_FLOAT = SND_PCM_FORMAT_FLOAT_BE;
{ Float 64 bit CPU endian }
SND_PCM_FORMAT_FLOAT64 = SND_PCM_FORMAT_FLOAT64_BE;
{ IEC-958 CPU Endian }
SND_PCM_FORMAT_IEC958_SUBFRAME = SND_PCM_FORMAT_IEC958_SUBFRAME_BE;
{$ENDIF}
type
{ PCM sample subformat }
_snd_pcm_subformat = Longint;
snd_pcm_subformat_t = _snd_pcm_subformat;
const
SND_PCM_SUBFORMAT_STD = 0; { Standard }
SND_PCM_SUBFORMAT_LAST = SND_PCM_SUBFORMAT_STD;
type
{ PCM state }
_snd_pcm_state = Longint;
snd_pcm_state_t = _snd_pcm_state;
const
SND_PCM_STATE_OPEN = 0; { Open }
SND_PCM_STATE_SETUP = 1; { Setup installed }
SND_PCM_STATE_PREPARED = 2; { Ready to start }
SND_PCM_STATE_RUNNING = 3; { Running }
SND_PCM_STATE_XRUN = 4; { Stopped: underrun (playback) or overrun (capture) detected }
SND_PCM_STATE_DRAINING = 5; { Draining: running (playback) or stopped (capture) }
SND_PCM_STATE_PAUSED = 6; { Paused }
SND_PCM_STATE_SUSPENDED = 7; { Hardware is suspended }
SND_PCM_STATE_LAST = SND_PCM_STATE_SUSPENDED;
type
{ PCM start mode }
_snd_pcm_start = Longint;
snd_pcm_start_t = _snd_pcm_start;
const
SND_PCM_START_DATA = 0; { Automatic start on data read/write }
SND_PCM_START_EXPLICIT = 1; { Explicit start }
SND_PCM_START_LAST = SND_PCM_START_EXPLICIT;
type
{ PCM xrun mode }
_snd_pcm_xrun = Longint;
snd_pcm_xrun_t = _snd_pcm_xrun;
const
SND_PCM_XRUN_NONE = 0; { Xrun detection disabled }
SND_PCM_XRUN_STOP = 1; { Stop on xrun detection }
SND_PCM_XRUN_LAST = SND_PCM_XRUN_STOP;
type
{ PCM timestamp mode }
_snd_pcm_tstamp = Longint;
snd_pcm_tstamp_t = _snd_pcm_tstamp;
const
SND_PCM_TSTAMP_NONE = 0; { No timestamp }
SND_PCM_TSTAMP_MMAP = 1; { Update mmap'ed timestamp }
SND_PCM_TSTAMP_LAST = SND_PCM_TSTAMP_MMAP;
type
{ Unsigned frames quantity }
snd_pcm_uframes_t = LongWord;
Psnd_pcm_uframes_t = ^snd_pcm_uframes_t;
{ Signed frames quantity }
snd_pcm_sframes_t = longint;
Psnd_pcm_sframes_t = ^snd_pcm_sframes_t;
{ Timestamp }
snd_timestamp_t = timeval;
Psnd_timestamp_t = ^snd_timestamp_t;
const
{ Non blocking mode (flag for open mode) \hideinitializer }
SND_PCM_NONBLOCK = $0001;
{ Async notification (flag for open mode) \hideinitializer }
SND_PCM_ASYNC = $0002;
type
{ PCM handle }
Psnd_pcm_t = pointer;
{ PCM type }
_snd_pcm_type = Longint;
snd_pcm_type_t = _snd_pcm_type;
const
{ PCM type }
SND_PCM_TYPE_HW = 0; { Kernel level PCM }
SND_PCM_TYPE_HOOKS = 1; { Hooked PCM }
SND_PCM_TYPE_MULTI = 2; { One ore more linked PCM with exclusive access to selected channels }
SND_PCM_TYPE_FILE = 3; { File writing plugin }
SND_PCM_TYPE_NULL = 4; { Null endpoint PCM }
SND_PCM_TYPE_SHM = 5; { Shared memory client PCM }
SND_PCM_TYPE_INET = 6; { INET client PCM (not yet implemented) }
SND_PCM_TYPE_COPY = 7; { Copying plugin }
SND_PCM_TYPE_LINEAR = 8; { Linear format conversion PCM }
SND_PCM_TYPE_ALAW = 9; { A-Law format conversion PCM }
SND_PCM_TYPE_MULAW = 10; { Mu-Law format conversion PCM }
SND_PCM_TYPE_ADPCM = 11; { IMA-ADPCM format conversion PCM }
SND_PCM_TYPE_RATE = 12; { Rate conversion PCM }
SND_PCM_TYPE_ROUTE = 13; { Attenuated static route PCM }
SND_PCM_TYPE_PLUG = 14; { Format adjusted PCM }
SND_PCM_TYPE_SHARE = 15; { Sharing PCM }
SND_PCM_TYPE_METER = 16; { Meter plugin }
SND_PCM_TYPE_MIX = 17; { Mixing PCM }
SND_PCM_TYPE_DROUTE = 18; { Attenuated dynamic route PCM (not yet implemented) }
SND_PCM_TYPE_LBSERVER = 19; { Loopback server plugin (not yet implemented) }
SND_PCM_TYPE_LINEAR_FLOAT = 20; { Linear Integer <-> Linear Float format conversion PCM }
SND_PCM_TYPE_LADSPA = 21; { LADSPA integration plugin }
type
{ PCM area specification }
_snd_pcm_channel_area = record
addr : pointer; { base address of channel samples }
first : LongWord; { offset to first sample in bits }
step : LongWord; { samples distance in bits }
end;
snd_pcm_channel_area_t = _snd_pcm_channel_area;
Psnd_pcm_channel_area_t = ^snd_pcm_channel_area_t;
{ PCM synchronization ID }
_snd_pcm_sync_id = record
case longint of
0 : ( id : array[0..15] of byte ); { 8-bit ID }
1 : ( id16 : array[0..7] of word ); { 16-bit ID }
2 : ( id32 : array[0..3] of LongWord ); { 32-bit ID }
end;
snd_pcm_sync_id_t = _snd_pcm_sync_id;
{ #SND_PCM_TYPE_METER scope handle }
Psnd_pcm_scope_t = pointer;
type
snd_pcm_open_t = function(var pcm:Psnd_pcm_t; name:Pchar; stream:snd_pcm_stream_t; mode:longint):longint;cdecl;
snd_pcm_open_lconf_t = function(var pcm:Psnd_pcm_t; name:Pchar; stream:snd_pcm_stream_t; mode:longint; lconf:Psnd_config_t):longint;cdecl;
snd_pcm_close_t = function(pcm:Psnd_pcm_t):longint;cdecl;
snd_pcm_name_t = function(pcm:Psnd_pcm_t):Pchar;cdecl;
snd_pcm_type_t_t = function(pcm:Psnd_pcm_t):snd_pcm_type_t;cdecl;
snd_pcm_stream_t_t = function(pcm:Psnd_pcm_t):snd_pcm_stream_t;cdecl;
snd_pcm_poll_descriptors_count_t = function(pcm:Psnd_pcm_t):longint;cdecl;
snd_pcm_poll_descriptors_t = function(pcm:Psnd_pcm_t; var pfds:pollfd; space:LongWord):longint;cdecl;
snd_pcm_poll_descriptors_revents_t = function(pcm:Psnd_pcm_t; var pfds:pollfd; nfds:LongWord; revents:Pword):longint;cdecl;
snd_pcm_set_nonblock_t = function(pcm:Psnd_pcm_t; nonblock:longint):longint;cdecl;
// snd_async_add_pcm_handler_t = function(var handler:Psnd_async_handler_t; pcm:Psnd_pcm_t; callback:snd_async_callback_t; private_data:pointer):longint;cdecl;
snd_async_handler_get_pcm_t = function(handler:Psnd_async_handler_t):Psnd_pcm_t;cdecl;
snd_pcm_info_t = function(pcm:Psnd_pcm_t; info:Psnd_pcm_info_t):longint;cdecl;
snd_pcm_hw_params_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t):longint;cdecl;
snd_pcm_hw_params_current_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t):longint;cdecl;
snd_pcm_hw_free_t = function(pcm:Psnd_pcm_t):longint;cdecl;
snd_pcm_sw_params_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_sw_params_t):longint;cdecl;
snd_pcm_sw_params_current_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_sw_params_t):longint;cdecl;
snd_pcm_prepare_t = function(pcm:Psnd_pcm_t):longint;cdecl;
snd_pcm_reset_t = function(pcm:Psnd_pcm_t):longint;cdecl;
snd_pcm_status_t = function(pcm:Psnd_pcm_t; status:Psnd_pcm_status_t):longint;cdecl;
snd_pcm_start_t_t = function(pcm:Psnd_pcm_t):longint;cdecl;
snd_pcm_drop_t = function(pcm:Psnd_pcm_t):longint;cdecl;
snd_pcm_drain_t = function(pcm:Psnd_pcm_t):longint;cdecl;
snd_pcm_pause_t = function(pcm:Psnd_pcm_t; enable:longint):longint;cdecl;
snd_pcm_state_t_t = function(pcm:Psnd_pcm_t):snd_pcm_state_t;cdecl;
snd_pcm_hwsync_t = function(pcm: Psnd_pcm_t):longint;cdecl;
snd_pcm_delay_t = function(pcm:Psnd_pcm_t; delayp:Psnd_pcm_sframes_t):longint;cdecl;
snd_pcm_resume_t = function(pcm:Psnd_pcm_t):longint;cdecl;
snd_pcm_avail_update_t = function(pcm:Psnd_pcm_t):snd_pcm_sframes_t;cdecl;
snd_pcm_rewind_t = function(pcm:Psnd_pcm_t; frames:snd_pcm_uframes_t):snd_pcm_sframes_t;cdecl;
snd_pcm_writei_t = function(pcm:Psnd_pcm_t; buffer:pointer; size:snd_pcm_uframes_t):snd_pcm_sframes_t;cdecl;
snd_pcm_readi_t = function(pcm:Psnd_pcm_t; buffer:pointer; size:snd_pcm_uframes_t):snd_pcm_sframes_t;cdecl;
snd_pcm_writen_t = function(pcm:Psnd_pcm_t; bufs:Ppointer; size:snd_pcm_uframes_t):snd_pcm_sframes_t;cdecl;
snd_pcm_readn_t = function(pcm:Psnd_pcm_t; bufs:Ppointer; size:snd_pcm_uframes_t):snd_pcm_sframes_t;cdecl;
snd_pcm_wait_t = function(pcm:Psnd_pcm_t; timeout:longint):longint;cdecl;
snd_pcm_link_t = function(pcm1:Psnd_pcm_t; pcm2:Psnd_pcm_t):longint;cdecl;
snd_pcm_unlink_t = function(pcm:Psnd_pcm_t):longint;cdecl;
snd_pcm_info_sizeof_t = function:size_t;cdecl;
snd_pcm_info_malloc_t = function(var obj:Psnd_pcm_info_t):LongInt;cdecl;
snd_pcm_info_free_t = procedure(obj:Psnd_pcm_info_t);cdecl;
snd_pcm_info_copy_t = procedure(dst:Psnd_pcm_info_t; src:Psnd_pcm_info_t);cdecl;
snd_pcm_info_get_device_t = function(obj:Psnd_pcm_info_t):LongWord;cdecl;
snd_pcm_info_get_subdevice_t = function(obj:Psnd_pcm_info_t):LongWord;cdecl;
snd_pcm_info_get_stream_t = function(obj:Psnd_pcm_info_t):snd_pcm_stream_t;cdecl;
snd_pcm_info_get_card_t = function(obj:Psnd_pcm_info_t):longint;cdecl;
snd_pcm_info_get_id_t = function(obj:Psnd_pcm_info_t):Pchar;cdecl;
snd_pcm_info_get_name_t = function(obj:Psnd_pcm_info_t):Pchar;cdecl;
snd_pcm_info_get_subdevice_name_t = function(obj:Psnd_pcm_info_t):Pchar;cdecl;
snd_pcm_info_get_class_t = function(obj:Psnd_pcm_info_t):snd_pcm_class_t;cdecl;
snd_pcm_info_get_subclass_t = function(obj:Psnd_pcm_info_t):snd_pcm_subclass_t;cdecl;
snd_pcm_info_get_subdevices_count_t = function(obj:Psnd_pcm_info_t):LongWord;cdecl;
snd_pcm_info_get_subdevices_avail_t = function(obj:Psnd_pcm_info_t):LongWord;cdecl;
snd_pcm_info_get_sync_t = function(obj:Psnd_pcm_info_t):snd_pcm_sync_id_t;cdecl;
snd_pcm_info_set_device_t = procedure(obj:Psnd_pcm_info_t; val:LongWord);cdecl;
snd_pcm_info_set_subdevice_t = procedure(obj:Psnd_pcm_info_t; val:LongWord);cdecl;
snd_pcm_info_set_stream_t = procedure(obj:Psnd_pcm_info_t; val:snd_pcm_stream_t);cdecl;
{
Hardware Parameters
See the \ref pcm page for more details.
}
snd_pcm_hw_params_any_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t):longint;cdecl;
snd_pcm_hw_params_can_mmap_sample_resolution_t = function(params:Psnd_pcm_hw_params_t):longint;cdecl;
snd_pcm_hw_params_is_double_t = function(params:Psnd_pcm_hw_params_t):longint;cdecl;
snd_pcm_hw_params_is_batch_t = function(params:Psnd_pcm_hw_params_t):longint;cdecl;
snd_pcm_hw_params_is_block_transfer_t = function(params:Psnd_pcm_hw_params_t):longint;cdecl;
snd_pcm_hw_params_can_overrange_t = function(params:Psnd_pcm_hw_params_t):longint;cdecl;
snd_pcm_hw_params_can_pause_t = function(params:Psnd_pcm_hw_params_t):longint;cdecl;
snd_pcm_hw_params_can_resume_t = function(params:Psnd_pcm_hw_params_t):longint;cdecl;
snd_pcm_hw_params_is_half_duplex_t = function(params:Psnd_pcm_hw_params_t):longint;cdecl;
snd_pcm_hw_params_is_joint_duplex_t = function(params:Psnd_pcm_hw_params_t):longint;cdecl;
snd_pcm_hw_params_can_sync_start_t = function(params:Psnd_pcm_hw_params_t):longint;cdecl;
snd_pcm_hw_params_get_rate_numden_t = function(params:Psnd_pcm_hw_params_t; rate_num:PLongWord; rate_den:PLongWord):longint;cdecl;
snd_pcm_hw_params_get_sbits_t = function(params:Psnd_pcm_hw_params_t):longint;cdecl;
snd_pcm_hw_params_get_fifo_size_t = function(params:Psnd_pcm_hw_params_t):longint;cdecl;
snd_pcm_hw_params_sizeof_t = function:size_t;cdecl;
snd_pcm_hw_params_malloc_t = function(var obj:Psnd_pcm_hw_params_t):LongInt;cdecl;
snd_pcm_hw_params_free_t = procedure(obj:Psnd_pcm_hw_params_t);cdecl;
snd_pcm_hw_params_copy_t = procedure(dst:Psnd_pcm_hw_params_t; src:Psnd_pcm_hw_params_t);cdecl;
snd_pcm_hw_params_get_access_t = function(params:Psnd_pcm_hw_params_t):longint;cdecl;
snd_pcm_hw_params_test_access_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:snd_pcm_access_t):longint;cdecl;
snd_pcm_hw_params_set_access_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:snd_pcm_access_t):longint;cdecl;
snd_pcm_hw_params_set_access_first_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t):snd_pcm_access_t;cdecl;
snd_pcm_hw_params_set_access_last_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t):snd_pcm_access_t;cdecl;
snd_pcm_hw_params_set_access_mask_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; mask:Psnd_pcm_access_mask_t):longint;cdecl;
snd_pcm_hw_params_get_access_mask_t = procedure(params:Psnd_pcm_hw_params_t; mask:Psnd_pcm_access_mask_t);cdecl;
snd_pcm_hw_params_get_format_t = function(params:Psnd_pcm_hw_params_t):longint;cdecl;
snd_pcm_hw_params_test_format_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:snd_pcm_format_t):longint;cdecl;
snd_pcm_hw_params_set_format_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:snd_pcm_format_t):longint;cdecl;
snd_pcm_hw_params_set_format_first_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t):snd_pcm_format_t;cdecl;
snd_pcm_hw_params_set_format_last_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t):snd_pcm_format_t;cdecl;
snd_pcm_hw_params_set_format_mask_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; mask:Psnd_pcm_format_mask_t):longint;cdecl;
snd_pcm_hw_params_get_format_mask_t = procedure(params:Psnd_pcm_hw_params_t; mask:Psnd_pcm_format_mask_t);cdecl;
snd_pcm_hw_params_test_subformat_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:snd_pcm_subformat_t):longint;cdecl;
snd_pcm_hw_params_get_subformat_t = function(params:Psnd_pcm_hw_params_t):longint;cdecl;
snd_pcm_hw_params_set_subformat_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:snd_pcm_subformat_t):longint;cdecl;
snd_pcm_hw_params_set_subformat_first_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t):snd_pcm_subformat_t;cdecl;
snd_pcm_hw_params_set_subformat_last_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t):snd_pcm_subformat_t;cdecl;
snd_pcm_hw_params_set_subformat_mask_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; mask:Psnd_pcm_subformat_mask_t):longint;cdecl;
snd_pcm_hw_params_get_subformat_mask_t = procedure(params:Psnd_pcm_hw_params_t; mask:Psnd_pcm_subformat_mask_t);cdecl;
snd_pcm_hw_params_get_channels_t = function(params:Psnd_pcm_hw_params_t):longint;cdecl;
snd_pcm_hw_params_get_channels_min_t = function(params:Psnd_pcm_hw_params_t):LongWord;cdecl;
snd_pcm_hw_params_get_channels_max_t = function(params:Psnd_pcm_hw_params_t):LongWord;cdecl;
snd_pcm_hw_params_test_channels_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:LongWord):longint;cdecl;
snd_pcm_hw_params_set_channels_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:LongWord):longint;cdecl;
snd_pcm_hw_params_set_channels_min_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:PLongWord):longint;cdecl;
snd_pcm_hw_params_set_channels_max_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:PLongWord):longint;cdecl;
snd_pcm_hw_params_set_channels_minmax_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; min:PLongWord; max:PLongWord):longint;cdecl;
snd_pcm_hw_params_set_channels_near_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:LongWord):LongWord;cdecl;
snd_pcm_hw_params_set_channels_first_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t):LongWord;cdecl;
snd_pcm_hw_params_set_channels_last_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t):LongWord;cdecl;
snd_pcm_hw_params_get_rate_t = function(params:Psnd_pcm_hw_params_t; dir:Plongint):longint;cdecl;
snd_pcm_hw_params_get_rate_min_t = function(params:Psnd_pcm_hw_params_t; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_get_rate_max_t = function(params:Psnd_pcm_hw_params_t; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_test_rate_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:LongWord; dir:longint):longint;cdecl;
snd_pcm_hw_params_set_rate_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:LongWord; dir:longint):longint;cdecl;
snd_pcm_hw_params_set_rate_min_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:PLongWord; dir:Plongint):longint;cdecl;
snd_pcm_hw_params_set_rate_max_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:PLongWord; dir:Plongint):longint;cdecl;
snd_pcm_hw_params_set_rate_minmax_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; min:PLongWord; mindir:Plongint; max:PLongWord;
maxdir:Plongint):longint;cdecl;
snd_pcm_hw_params_set_rate_near_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:LongWord; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_set_rate_first_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_set_rate_last_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_get_period_time_t = function(params:Psnd_pcm_hw_params_t; dir:Plongint):longint;cdecl;
snd_pcm_hw_params_get_period_time_min_t = function(params:Psnd_pcm_hw_params_t; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_get_period_time_max_t = function(params:Psnd_pcm_hw_params_t; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_test_period_time_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:LongWord; dir:longint):longint;cdecl;
snd_pcm_hw_params_set_period_time_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:LongWord; dir:longint):longint;cdecl;
snd_pcm_hw_params_set_period_time_min_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:PLongWord; dir:Plongint):longint;cdecl;
snd_pcm_hw_params_set_period_time_max_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:PLongWord; dir:Plongint):longint;cdecl;
snd_pcm_hw_params_set_period_time_minmax_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; min:PLongWord; mindir:Plongint; max:PLongWord;
maxdir:Plongint):longint;cdecl;
snd_pcm_hw_params_set_period_time_near_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:LongWord; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_set_period_time_first_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_set_period_time_last_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_get_period_size_t = function(params:Psnd_pcm_hw_params_t; dir:Plongint):snd_pcm_sframes_t;cdecl;
snd_pcm_hw_params_get_period_size_min_t = function(params:Psnd_pcm_hw_params_t; dir:Plongint):snd_pcm_uframes_t;cdecl;
snd_pcm_hw_params_get_period_size_max_t = function(params:Psnd_pcm_hw_params_t; dir:Plongint):snd_pcm_uframes_t;cdecl;
snd_pcm_hw_params_test_period_size_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:snd_pcm_uframes_t; dir:longint):longint;cdecl;
snd_pcm_hw_params_set_period_size_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:snd_pcm_uframes_t; dir:longint):longint;cdecl;
snd_pcm_hw_params_set_period_size_min_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:Psnd_pcm_uframes_t; dir:Plongint):longint;cdecl;
snd_pcm_hw_params_set_period_size_max_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:Psnd_pcm_uframes_t; dir:Plongint):longint;cdecl;
snd_pcm_hw_params_set_period_size_minmax_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; min:Psnd_pcm_uframes_t; mindir:Plongint; max:Psnd_pcm_uframes_t;
maxdir:Plongint):longint;cdecl;
snd_pcm_hw_params_set_period_size_near_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:snd_pcm_uframes_t; dir:Plongint):snd_pcm_uframes_t;cdecl;
snd_pcm_hw_params_set_period_size_first_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; dir:Plongint):snd_pcm_uframes_t;cdecl;
snd_pcm_hw_params_set_period_size_last_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; dir:Plongint):snd_pcm_uframes_t;cdecl;
snd_pcm_hw_params_set_period_size_integer_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t):longint;cdecl;
snd_pcm_hw_params_get_periods_t = function(params:Psnd_pcm_hw_params_t; dir:Plongint):longint;cdecl;
snd_pcm_hw_params_get_periods_min_t = function(params:Psnd_pcm_hw_params_t; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_get_periods_max_t = function(params:Psnd_pcm_hw_params_t; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_test_periods_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:LongWord; dir:longint):longint;cdecl;
snd_pcm_hw_params_set_periods_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:LongWord; dir:longint):longint;cdecl;
snd_pcm_hw_params_set_periods_min_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:PLongWord; dir:Plongint):longint;cdecl;
snd_pcm_hw_params_set_periods_max_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:PLongWord; dir:Plongint):longint;cdecl;
snd_pcm_hw_params_set_periods_minmax_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; min:PLongWord; mindir:Plongint; max:PLongWord;
maxdir:Plongint):longint;cdecl;
snd_pcm_hw_params_set_periods_near_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:LongWord; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_set_periods_first_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_set_periods_last_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_set_periods_integer_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t):longint;cdecl;
snd_pcm_hw_params_get_buffer_time_t = function(params:Psnd_pcm_hw_params_t; dir:Plongint):longint;cdecl;
snd_pcm_hw_params_get_buffer_time_min_t = function(params:Psnd_pcm_hw_params_t; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_get_buffer_time_max_t = function(params:Psnd_pcm_hw_params_t; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_test_buffer_time_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:LongWord; dir:longint):longint;cdecl;
snd_pcm_hw_params_set_buffer_time_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:LongWord; dir:longint):longint;cdecl;
snd_pcm_hw_params_set_buffer_time_min_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:PLongWord; dir:Plongint):longint;cdecl;
snd_pcm_hw_params_set_buffer_time_max_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:PLongWord; dir:Plongint):longint;cdecl;
snd_pcm_hw_params_set_buffer_time_minmax_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; min:PLongWord; mindir:Plongint; max:PLongWord;
maxdir:Plongint):longint;cdecl;
snd_pcm_hw_params_set_buffer_time_near_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:LongWord; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_set_buffer_time_first_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_set_buffer_time_last_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_get_buffer_size_t = function(params:Psnd_pcm_hw_params_t):snd_pcm_sframes_t;cdecl;
snd_pcm_hw_params_get_buffer_size_min_t = function(params:Psnd_pcm_hw_params_t):snd_pcm_uframes_t;cdecl;
snd_pcm_hw_params_get_buffer_size_max_t = function(params:Psnd_pcm_hw_params_t):snd_pcm_uframes_t;cdecl;
snd_pcm_hw_params_test_buffer_size_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:snd_pcm_uframes_t):longint;cdecl;
snd_pcm_hw_params_set_buffer_size_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:snd_pcm_uframes_t):longint;cdecl;
snd_pcm_hw_params_set_buffer_size_min_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:Psnd_pcm_uframes_t):longint;cdecl;
snd_pcm_hw_params_set_buffer_size_max_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:Psnd_pcm_uframes_t):longint;cdecl;
snd_pcm_hw_params_set_buffer_size_minmax_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; min:Psnd_pcm_uframes_t; max:Psnd_pcm_uframes_t):longint;cdecl;
snd_pcm_hw_params_set_buffer_size_near_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:snd_pcm_uframes_t):snd_pcm_uframes_t;cdecl;
snd_pcm_hw_params_set_buffer_size_first_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t):snd_pcm_uframes_t;cdecl;
snd_pcm_hw_params_set_buffer_size_last_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t):snd_pcm_uframes_t;cdecl;
snd_pcm_hw_params_get_tick_time_t = function(params:Psnd_pcm_hw_params_t; dir:Plongint):longint;cdecl;
snd_pcm_hw_params_get_tick_time_min_t = function(params:Psnd_pcm_hw_params_t; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_get_tick_time_max_t = function(params:Psnd_pcm_hw_params_t; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_test_tick_time_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:LongWord; dir:longint):longint;cdecl;
snd_pcm_hw_params_set_tick_time_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:LongWord; dir:longint):longint;cdecl;
snd_pcm_hw_params_set_tick_time_min_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:PLongWord; dir:Plongint):longint;cdecl;
snd_pcm_hw_params_set_tick_time_max_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:PLongWord; dir:Plongint):longint;cdecl;
snd_pcm_hw_params_set_tick_time_minmax_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; min:PLongWord; mindir:Plongint; max:PLongWord;
maxdir:Plongint):longint;cdecl;
snd_pcm_hw_params_set_tick_time_near_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; val:LongWord; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_set_tick_time_first_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; dir:Plongint):LongWord;cdecl;
snd_pcm_hw_params_set_tick_time_last_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_hw_params_t; dir:Plongint):LongWord;cdecl;
{ New function added in alsa-lib-0.9.0-rc5 }
snd_pcm_hw_params_get_min_align_t = function(params: Psnd_pcm_hw_params_t; var val: snd_pcm_uframes_t):longint;cdecl;
{
Software Parameters
}
// function snd_pcm_sw_params_current(pcm:Psnd_pcm_t; params:Psnd_pcm_sw_params_t):longint;cdecl;external asoundlib_name;
snd_pcm_sw_params_sizeof_t = function:size_t;cdecl;
snd_pcm_sw_params_malloc_t = function(var obj:Psnd_pcm_sw_params_t):LongInt;cdecl;
snd_pcm_sw_params_free_t = procedure(obj:Psnd_pcm_sw_params_t);cdecl;
snd_pcm_sw_params_copy_t = procedure(dst:Psnd_pcm_sw_params_t; src:Psnd_pcm_sw_params_t);cdecl;
snd_pcm_sw_params_set_tstamp_mode_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_sw_params_t; val:snd_pcm_tstamp_t):longint;cdecl;
snd_pcm_sw_params_get_tstamp_mode_t = function(params:Psnd_pcm_sw_params_t):snd_pcm_tstamp_t;cdecl;
snd_pcm_sw_params_set_sleep_min_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_sw_params_t; val:LongWord):longint;cdecl;
snd_pcm_sw_params_get_sleep_min_t = function(params:Psnd_pcm_sw_params_t):LongWord;cdecl;
snd_pcm_sw_params_set_avail_min_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_sw_params_t; val:snd_pcm_uframes_t):longint;cdecl;
snd_pcm_sw_params_get_avail_min_t = function(params:Psnd_pcm_sw_params_t):snd_pcm_uframes_t;cdecl;
snd_pcm_sw_params_set_xfer_align_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_sw_params_t; val:snd_pcm_uframes_t):longint;cdecl;
snd_pcm_sw_params_get_xfer_align_t = function(params:Psnd_pcm_sw_params_t):snd_pcm_uframes_t;cdecl;
snd_pcm_sw_params_set_start_threshold_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_sw_params_t; val:snd_pcm_uframes_t):longint;cdecl;
snd_pcm_sw_params_get_start_threshold_t = function(params:Psnd_pcm_sw_params_t):snd_pcm_uframes_t;cdecl;
snd_pcm_sw_params_set_stop_threshold_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_sw_params_t; val:snd_pcm_uframes_t):longint;cdecl;
snd_pcm_sw_params_get_stop_threshold_t = function(params:Psnd_pcm_sw_params_t):snd_pcm_uframes_t;cdecl;
snd_pcm_sw_params_set_silence_threshold_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_sw_params_t; val:snd_pcm_uframes_t):longint;cdecl;
snd_pcm_sw_params_get_silence_threshold_t = function(params:Psnd_pcm_sw_params_t):snd_pcm_uframes_t;cdecl;
snd_pcm_sw_params_set_silence_size_t = function(pcm:Psnd_pcm_t; params:Psnd_pcm_sw_params_t; val:snd_pcm_uframes_t):longint;cdecl;
snd_pcm_sw_params_get_silence_size_t = function(params:Psnd_pcm_sw_params_t):snd_pcm_uframes_t;cdecl;
{
Access Mask Functions
}
snd_pcm_access_mask_sizeof_t = function:size_t;cdecl;
snd_pcm_access_mask_malloc_t = function(var obj:Psnd_pcm_access_mask_t):LongInt;cdecl;
snd_pcm_access_mask_free_t = procedure(obj:Psnd_pcm_access_mask_t);cdecl;
snd_pcm_access_mask_copy_t = procedure(dst:Psnd_pcm_access_mask_t; src:Psnd_pcm_access_mask_t);cdecl;
snd_pcm_access_mask_none_t = procedure(mask:Psnd_pcm_access_mask_t);cdecl;
snd_pcm_access_mask_any_t = procedure(mask:Psnd_pcm_access_mask_t);cdecl;
snd_pcm_access_mask_test_t = function(mask:Psnd_pcm_access_mask_t; val:snd_pcm_access_t):longint;cdecl;
snd_pcm_access_mask_empty_t = function(mask:Psnd_pcm_access_mask_t):longint;cdecl;
snd_pcm_access_mask_set_t = procedure(mask:Psnd_pcm_access_mask_t; val:snd_pcm_access_t);cdecl;
snd_pcm_access_mask_reset_t = procedure(mask:Psnd_pcm_access_mask_t; val:snd_pcm_access_t);cdecl;
{
Format Mask Functions
}
snd_pcm_format_mask_sizeof_t = function:size_t;cdecl;
snd_pcm_format_mask_malloc_t = function(var obj:Psnd_pcm_format_mask_t):LongInt;cdecl;
snd_pcm_format_mask_free_t = procedure(obj:Psnd_pcm_format_mask_t);cdecl;
snd_pcm_format_mask_copy_t = procedure(dst:Psnd_pcm_format_mask_t; src:Psnd_pcm_format_mask_t);cdecl;
snd_pcm_format_mask_none_t = procedure(mask:Psnd_pcm_format_mask_t);cdecl;
snd_pcm_format_mask_any_t = procedure(mask:Psnd_pcm_format_mask_t);cdecl;
snd_pcm_format_mask_test_t = function(mask:Psnd_pcm_format_mask_t; val:snd_pcm_format_t):longint;cdecl;
snd_pcm_format_mask_empty_t = function(mask:Psnd_pcm_format_mask_t):longint;cdecl;
snd_pcm_format_mask_set_t = procedure(mask:Psnd_pcm_format_mask_t; val:snd_pcm_format_t);cdecl;
snd_pcm_format_mask_reset_t = procedure(mask:Psnd_pcm_format_mask_t; val:snd_pcm_format_t);cdecl;
{
Subformat Mask Functions
}
snd_pcm_subformat_mask_sizeof_t = function:size_t;cdecl;
snd_pcm_subformat_mask_malloc_t = function(var obj:Psnd_pcm_subformat_mask_t):LongInt;cdecl;
snd_pcm_subformat_mask_free_t = procedure(obj:Psnd_pcm_subformat_mask_t);cdecl;
snd_pcm_subformat_mask_copy_t = procedure(dst:Psnd_pcm_subformat_mask_t; src:Psnd_pcm_subformat_mask_t);cdecl;
snd_pcm_subformat_mask_none_t = procedure(mask:Psnd_pcm_subformat_mask_t);cdecl;
snd_pcm_subformat_mask_any_t = procedure(mask:Psnd_pcm_subformat_mask_t);cdecl;
snd_pcm_subformat_mask_test_t = function(mask:Psnd_pcm_subformat_mask_t; val:snd_pcm_subformat_t):longint;cdecl;
snd_pcm_subformat_mask_empty_t = function(mask:Psnd_pcm_subformat_mask_t):longint;cdecl;
snd_pcm_subformat_mask_set_t = procedure(mask:Psnd_pcm_subformat_mask_t; val:snd_pcm_subformat_t);cdecl;
snd_pcm_subformat_mask_reset_t = procedure(mask:Psnd_pcm_subformat_mask_t; val:snd_pcm_subformat_t);cdecl;
{
Status Functions
}
snd_pcm_status_sizeof_t = function:size_t;cdecl;
snd_pcm_status_malloc_t = function(var obj:Psnd_pcm_status_t):LongInt;cdecl;
snd_pcm_status_free_t = procedure(obj:Psnd_pcm_status_t);cdecl;
snd_pcm_status_copy_t = procedure(dst:Psnd_pcm_status_t; src:Psnd_pcm_status_t);cdecl;
snd_pcm_status_get_state_t = function(obj:Psnd_pcm_status_t):snd_pcm_state_t;cdecl;
snd_pcm_status_get_trigger_tstamp_t = procedure(obj:Psnd_pcm_status_t; ptr:Psnd_timestamp_t);cdecl;
snd_pcm_status_get_tstamp_t = procedure(obj:Psnd_pcm_status_t; ptr:Psnd_timestamp_t);cdecl;
snd_pcm_status_get_delay_t = function(obj:Psnd_pcm_status_t):snd_pcm_sframes_t;cdecl;
snd_pcm_status_get_avail_t = function(obj:Psnd_pcm_status_t):snd_pcm_uframes_t;cdecl;
snd_pcm_status_get_avail_max_t = function(obj:Psnd_pcm_status_t):snd_pcm_uframes_t;cdecl;
snd_pcm_status_get_overrange_t = function(obj:Psnd_pcm_status_t):snd_pcm_uframes_t;cdecl;
{
Description Functions
}
snd_pcm_stream_name_t = function(stream:snd_pcm_stream_t):Pchar;cdecl;
snd_pcm_access_name_t = function(_access:snd_pcm_access_t):Pchar;cdecl;
snd_pcm_format_name_t = function(format:snd_pcm_format_t):Pchar;cdecl;
snd_pcm_format_description_t = function(format:snd_pcm_format_t):Pchar;cdecl;
snd_pcm_subformat_name_t = function(subformat:snd_pcm_subformat_t):Pchar;cdecl;
snd_pcm_subformat_description_t = function(subformat:snd_pcm_subformat_t):Pchar;cdecl;
snd_pcm_format_value_t = function(name:Pchar):snd_pcm_format_t;cdecl;
snd_pcm_tstamp_mode_name_t = function(mode:snd_pcm_tstamp_t):Pchar;cdecl;
snd_pcm_state_name_t = function(state:snd_pcm_state_t):Pchar;cdecl;
{
Debug Functions
}
snd_pcm_dump_t = function(pcm:Psnd_pcm_t; mout:Psnd_output_t):longint;cdecl;
snd_pcm_dump_hw_setup_t = function(pcm:Psnd_pcm_t; mout:Psnd_output_t):longint;cdecl;
snd_pcm_dump_sw_setup_t = function(pcm:Psnd_pcm_t; mout:Psnd_output_t):longint;cdecl;
snd_pcm_dump_setup_t = function(pcm:Psnd_pcm_t; mout:Psnd_output_t):longint;cdecl;
snd_pcm_hw_params_dump_t = function(params:Psnd_pcm_hw_params_t; mout:Psnd_output_t):longint;cdecl;
snd_pcm_sw_params_dump_t = function(params:Psnd_pcm_sw_params_t; mout:Psnd_output_t):longint;cdecl;
snd_pcm_status_dump_t = function(status:Psnd_pcm_status_t; mout:Psnd_output_t):longint;cdecl;
{
Direct Access (MMAP) Functions
}
snd_pcm_mmap_begin_t = function(pcm:Psnd_pcm_t; var areas:Psnd_pcm_channel_area_t; offset:Psnd_pcm_uframes_t; frames:Psnd_pcm_uframes_t):longint;cdecl;
snd_pcm_mmap_commit_t = function(pcm:Psnd_pcm_t; offset:snd_pcm_uframes_t; frames:snd_pcm_uframes_t):snd_pcm_sframes_t;cdecl;
snd_pcm_mmap_writei_t = function(pcm:Psnd_pcm_t; buffer:pointer; size:snd_pcm_uframes_t):snd_pcm_sframes_t;cdecl;
snd_pcm_mmap_readi_t = function(pcm:Psnd_pcm_t; buffer:pointer; size:snd_pcm_uframes_t):snd_pcm_sframes_t;cdecl;
snd_pcm_mmap_writen_t = function(pcm:Psnd_pcm_t; bufs:Ppointer; size:snd_pcm_uframes_t):snd_pcm_sframes_t;cdecl;
snd_pcm_mmap_readn_t = function(pcm:Psnd_pcm_t; bufs:Ppointer; size:snd_pcm_uframes_t):snd_pcm_sframes_t;cdecl;
{
Helper Functions
}
snd_pcm_format_signed_t = function(format:snd_pcm_format_t):longint;cdecl;
snd_pcm_format_unsigned_t = function(format:snd_pcm_format_t):longint;cdecl;
snd_pcm_format_linear_t = function(format:snd_pcm_format_t):longint;cdecl;
snd_pcm_format_is_float_t = function(format:snd_pcm_format_t):longint;cdecl;
snd_pcm_format_little_endian_t = function(format:snd_pcm_format_t):longint;cdecl;
snd_pcm_format_big_endian_t = function(format:snd_pcm_format_t):longint;cdecl;
snd_pcm_format_cpu_endian_t = function(format:snd_pcm_format_t):longint;cdecl;
snd_pcm_format_width_t = function(format:snd_pcm_format_t):longint;cdecl;
{ in bits }
snd_pcm_format_physical_width_t = function(format:snd_pcm_format_t):longint;cdecl;
{ in bits }
snd_pcm_build_linear_format_t = function(width:longint; pwidth:longint; unsignd:longint; big_endian:longint):snd_pcm_format_t;cdecl;
snd_pcm_format_size_t = function(format:snd_pcm_format_t; samples:size_t):ssize_t;cdecl;
snd_pcm_format_silence_t = function(format:snd_pcm_format_t):u_int8_t;cdecl;
snd_pcm_format_silence_16_t = function(format:snd_pcm_format_t):u_int16_t;cdecl;
snd_pcm_format_silence_32_t = function(format:snd_pcm_format_t):u_int32_t;cdecl;
// snd_pcm_format_silence_64_t = function(format:snd_pcm_format_t):u_int64_t;cdecl;
snd_pcm_format_set_silence_t = function(format:snd_pcm_format_t; buf:pointer; samples:LongWord):longint;cdecl;
snd_pcm_bytes_to_frames_t = function(pcm:Psnd_pcm_t; bytes:ssize_t):snd_pcm_sframes_t;cdecl;
snd_pcm_frames_to_bytes_t = function(pcm:Psnd_pcm_t; frames:snd_pcm_sframes_t):ssize_t;cdecl;
snd_pcm_bytes_to_samples_t = function(pcm:Psnd_pcm_t; bytes:ssize_t):longint;cdecl;
snd_pcm_samples_to_bytes_t = function(pcm:Psnd_pcm_t; samples:longint):ssize_t;cdecl;
snd_pcm_area_silence_t = function(dst_channel:Psnd_pcm_channel_area_t; dst_offset:snd_pcm_uframes_t; samples:LongWord; format:snd_pcm_format_t):longint;cdecl;
snd_pcm_areas_silence_t = function(dst_channels:Psnd_pcm_channel_area_t; dst_offset:snd_pcm_uframes_t; channels:LongWord; frames:snd_pcm_uframes_t; format:snd_pcm_format_t):longint;cdecl;
snd_pcm_area_copy_t = function(dst_channel:Psnd_pcm_channel_area_t; dst_offset:snd_pcm_uframes_t; src_channel:Psnd_pcm_channel_area_t; src_offset:snd_pcm_uframes_t; samples:LongWord;
format:snd_pcm_format_t):longint;cdecl;
snd_pcm_areas_copy_t = function(dst_channels:Psnd_pcm_channel_area_t; dst_offset:snd_pcm_uframes_t; src_channels:Psnd_pcm_channel_area_t; src_offset:snd_pcm_uframes_t; channels:LongWord;
frames:snd_pcm_uframes_t; format:snd_pcm_format_t):longint;cdecl;
{
Hook Extension
}
type
{ type of pcm hook }
_snd_pcm_hook_type = Longint;
snd_pcm_hook_type_t = _snd_pcm_hook_type;
const
SND_PCM_HOOK_TYPE_HW_PARAMS = 0;
SND_PCM_HOOK_TYPE_HW_FREE = 1;
SND_PCM_HOOK_TYPE_CLOSE = 2;
SND_PCM_HOOK_TYPE_LAST = SND_PCM_HOOK_TYPE_CLOSE;
type
{ PCM hook container }
Psnd_pcm_hook_t = pointer;
{ PCM hook callback function }
snd_pcm_hook_func_t = function (hook:Psnd_pcm_hook_t):longint;cdecl;
type
snd_pcm_hook_get_pcm_t = function(hook:Psnd_pcm_hook_t):Psnd_pcm_t;cdecl;
snd_pcm_hook_get_private_t = function(hook:Psnd_pcm_hook_t):pointer;cdecl;
snd_pcm_hook_set_private_t = procedure(hook:Psnd_pcm_hook_t; private_data:pointer);cdecl;
snd_pcm_hook_add_t = function(var hookp:Psnd_pcm_hook_t; pcm:Psnd_pcm_t; _type:snd_pcm_hook_type_t; func:snd_pcm_hook_func_t; private_data:pointer):longint;cdecl;
snd_pcm_hook_remove_t = function(hook:Psnd_pcm_hook_t):longint;cdecl;
{
Scope Plugin Extension
}
type
{ #SND_PCM_TYPE_METER scope functions }
_snd_pcm_scope_ops = record
enable : function (scope:Psnd_pcm_scope_t):longint;cdecl; { Enable and prepare it using current params }
disable : procedure (scope:Psnd_pcm_scope_t); { Disable }
start : procedure (scope:Psnd_pcm_scope_t); { PCM has been started }
stop : procedure (scope:Psnd_pcm_scope_t); { PCM has been stopped }
update : procedure (scope:Psnd_pcm_scope_t); { New frames are present }
reset : procedure (scope:Psnd_pcm_scope_t); { Reset status }
close : procedure (scope:Psnd_pcm_scope_t); { PCM is closing }
end;
snd_pcm_scope_ops_t = _snd_pcm_scope_ops;
Psnd_pcm_scope_ops_t = ^snd_pcm_scope_ops_t;
snd_pcm_meter_get_bufsize_t = function(pcm:Psnd_pcm_t):snd_pcm_uframes_t;cdecl;
snd_pcm_meter_get_channels_t = function(pcm:Psnd_pcm_t):LongWord;cdecl;
snd_pcm_meter_get_rate_t = function(pcm:Psnd_pcm_t):LongWord;cdecl;
snd_pcm_meter_get_now_t = function(pcm:Psnd_pcm_t):snd_pcm_uframes_t;cdecl;
snd_pcm_meter_get_boundary_t = function(pcm:Psnd_pcm_t):snd_pcm_uframes_t;cdecl;
snd_pcm_meter_add_scope_t = function(pcm:Psnd_pcm_t; scope:Psnd_pcm_scope_t):longint;cdecl;
snd_pcm_meter_search_scope_t = function(pcm:Psnd_pcm_t; name:Pchar):Psnd_pcm_scope_t;cdecl;
snd_pcm_scope_malloc_t = function(var ptr:Psnd_pcm_scope_t):longint;cdecl;
snd_pcm_scope_set_ops_t = procedure(scope:Psnd_pcm_scope_t; val:Psnd_pcm_scope_ops_t);cdecl;
snd_pcm_scope_set_name_t = procedure(scope:Psnd_pcm_scope_t; val:Pchar);cdecl;
snd_pcm_scope_get_name_t = function(scope:Psnd_pcm_scope_t):Pchar;cdecl;
snd_pcm_scope_get_callback_private_t = function(scope:Psnd_pcm_scope_t):pointer;cdecl;
snd_pcm_scope_set_callback_private_t = procedure(scope:Psnd_pcm_scope_t; val:pointer);cdecl;
snd_pcm_scope_s16_open_t = function(pcm:Psnd_pcm_t; name:Pchar; var scopep:Psnd_pcm_scope_t):longint;cdecl;
snd_pcm_scope_s16_get_channel_buffer_t = function(scope:Psnd_pcm_scope_t; channel:LongWord):Pint16_t;cdecl;
var
snd_pcm_close : snd_pcm_close_t;
snd_pcm_drop : snd_pcm_drop_t;
snd_pcm_drain : snd_pcm_drain_t;
snd_pcm_hw_params_malloc : snd_pcm_hw_params_malloc_t;
snd_pcm_hw_params_any : snd_pcm_hw_params_any_t;
snd_pcm_hw_params_get_periods : snd_pcm_hw_params_get_periods_t;
snd_pcm_hw_params_get_period_size : snd_pcm_hw_params_get_period_size_t;
snd_pcm_hw_params_get_rate : snd_pcm_hw_params_get_rate_t;
snd_pcm_hw_params_set_access : snd_pcm_hw_params_set_access_t;
snd_pcm_hw_params_set_buffer_size : snd_pcm_hw_params_set_buffer_size_t;
snd_pcm_hw_params_set_buffer_size_near : snd_pcm_hw_params_set_buffer_size_near_t;
snd_pcm_hw_params_set_channels : snd_pcm_hw_params_set_channels_t;
snd_pcm_hw_params_set_format : snd_pcm_hw_params_set_format_t;
snd_pcm_hw_params_set_period_size_near : snd_pcm_hw_params_set_period_size_near_t;
snd_pcm_hw_params_set_periods_near : snd_pcm_hw_params_set_periods_near_t;
snd_pcm_hw_params_set_rate_near : snd_pcm_hw_params_set_rate_near_t;
snd_pcm_hw_params : snd_pcm_hw_params_t;
snd_pcm_hw_params_free : snd_pcm_hw_params_free_t;
snd_pcm_info_get_device : snd_pcm_info_get_device_t;
snd_pcm_info_get_name : snd_pcm_info_get_name_t;
snd_pcm_info_set_device : snd_pcm_info_set_device_t;
snd_pcm_mmap_readi : snd_pcm_mmap_readi_t;
snd_pcm_mmap_writei : snd_pcm_mmap_writei_t;
snd_pcm_open : snd_pcm_open_t;
snd_pcm_pause : snd_pcm_pause_t;
snd_pcm_prepare : snd_pcm_prepare_t;
snd_pcm_readi : snd_pcm_readi_t;
snd_pcm_reset : snd_pcm_reset_t;
snd_pcm_resume : snd_pcm_resume_t;
snd_pcm_state : snd_pcm_state_t_t;
snd_pcm_stream : snd_pcm_stream_t_t;
snd_pcm_writei : snd_pcm_writei_t;
// Mixer types
type
psnd_ctl_card_info_t = Pointer;
ppsnd_ctl_card_info_t = ^psnd_ctl_card_info_t;
psnd_ctl_t = Pointer;
ppsnd_ctl_t = ^psnd_ctl_t;
type
snd_ctl_card_info_sizeof_t = function : Integer; cdecl;
snd_ctl_card_info_malloc_t = function(ptr : ppsnd_ctl_card_info_t) : Integer; cdecl;
snd_ctl_card_info_free_t = procedure(obj : psnd_ctl_card_info_t); cdecl;
snd_ctl_card_info_clear_t = procedure(obj : psnd_ctl_card_info_t); cdecl;
snd_ctl_card_info_copy_t = procedure(dst, src : psnd_ctl_card_info_t); cdecl;
snd_ctl_card_info_get_card_t = function(obj : psnd_ctl_card_info_t) : Integer; cdecl;
snd_ctl_card_info_get_id_t = function(obj : psnd_ctl_card_info_t) : PChar; cdecl;
snd_ctl_card_info_get_driver_t = function(obj : psnd_ctl_card_info_t) : PChar; cdecl;
snd_ctl_card_info_get_name_t = function(obj : psnd_ctl_card_info_t) : PChar; cdecl;
snd_ctl_card_info_get_longname_t = function(obj : psnd_ctl_card_info_t) : PChar; cdecl;
snd_ctl_card_info_get_mixername_t = function(obj : psnd_ctl_card_info_t) : PChar; cdecl;
snd_ctl_card_info_get_components_t = function(obj : psnd_ctl_card_info_t) : PChar; cdecl;
implementation
var
Path : string;
Libhandle : Pointer;
initialization
Path := FindLibs(asoundlib_path);
if Path <> '' then Libhandle := dlopen(@Path[1], RTLD_NOW or RTLD_GLOBAL);
if Libhandle <> nil then
begin
AsoundlibLoaded := True;
snd_pcm_close := dlsym(Libhandle, 'snd_pcm_close');
snd_pcm_drop := dlsym(Libhandle, 'snd_pcm_drop');
snd_pcm_drain := dlsym(Libhandle, 'snd_pcm_drain');
snd_pcm_hw_params_malloc := dlsym(Libhandle, 'snd_pcm_hw_params_malloc');
snd_pcm_hw_params_any := dlsym(Libhandle, 'snd_pcm_hw_params_any');
snd_pcm_hw_params_get_periods := dlsym(Libhandle, 'snd_pcm_hw_params_get_periods');
snd_pcm_hw_params_get_period_size := dlsym(Libhandle, 'snd_pcm_hw_params_get_period_size');
snd_pcm_hw_params_get_rate := dlsym(Libhandle, 'snd_pcm_hw_params_get_rate');
snd_pcm_hw_params_set_access := dlsym(Libhandle, 'snd_pcm_hw_params_set_access');
snd_pcm_hw_params_set_buffer_size := dlsym(Libhandle, 'snd_pcm_hw_params_set_buffer_size');
snd_pcm_hw_params_set_buffer_size_near := dlsym(Libhandle, 'snd_pcm_hw_params_set_buffer_size_near');
snd_pcm_hw_params_set_channels := dlsym(Libhandle, 'snd_pcm_hw_params_set_channels');
snd_pcm_hw_params_set_format := dlsym(Libhandle, 'snd_pcm_hw_params_set_format');
snd_pcm_hw_params_set_period_size_near := dlsym(Libhandle, 'snd_pcm_hw_params_set_period_size_near');
snd_pcm_hw_params_set_periods_near := dlsym(Libhandle, 'snd_pcm_hw_params_set_periods_near');
snd_pcm_hw_params_set_rate_near := dlsym(Libhandle, 'snd_pcm_hw_params_set_rate_near');
snd_pcm_hw_params := dlsym(Libhandle, 'snd_pcm_hw_params');
snd_pcm_hw_params_free := dlsym(Libhandle, 'snd_pcm_hw_params_free');
snd_pcm_info_get_device := dlsym(Libhandle, 'snd_pcm_info_get_device');
snd_pcm_info_get_name := dlsym(Libhandle, 'snd_pcm_info_get_name');
snd_pcm_info_set_device := dlsym(Libhandle, 'snd_pcm_info_set_device');
snd_pcm_mmap_readi := dlsym(Libhandle, 'snd_pcm_mmap_readi');
snd_pcm_mmap_writei := dlsym(Libhandle, 'snd_pcm_mmap_writei');
snd_pcm_open := dlsym(Libhandle, 'snd_pcm_open');
snd_pcm_pause := dlsym(Libhandle, 'snd_pcm_pause');
snd_pcm_prepare := dlsym(Libhandle, 'snd_pcm_prepare');
snd_pcm_readi := dlsym(Libhandle, 'snd_pcm_readi');
snd_pcm_reset := dlsym(Libhandle, 'snd_pcm_reset');
snd_pcm_resume := dlsym(Libhandle, 'snd_pcm_resume');
snd_pcm_state := dlsym(Libhandle, 'snd_pcm_state');
snd_pcm_stream := dlsym(Libhandle, 'snd_pcm_stream');
snd_pcm_writei := dlsym(Libhandle, 'snd_pcm_writei');
end;
finalization
if Libhandle <> nil then dlclose(Libhandle);
end.

View File

@@ -0,0 +1,256 @@
(*
kylix header for libao library.
translated from ao.h header file
by andrei borovsky, aborovsky@mtu-net.ru
the original header is
original copyright (c) aaron holtzman - may 1999
modifications copyright (c) stan seibert - july 2000, july 2001
more modifications copyright (c) jack moffitt - october 2000
*)
{
$Log: libao.pas,v $
Revision 1.2 2006/01/01 18:46:40 z0m3ie
*** empty log message ***
Revision 1.1 2005/12/19 18:36:16 z0m3ie
*** empty log message ***
Revision 1.1 2005/09/14 21:19:37 z0m3ie
*** empty log message ***
Revision 1.1 2005/09/12 22:04:52 z0m3ie
modified structure again, fileformats are now in an sperat folder.
all File In/Out classes are capsulated from TFileIn and TFileOut
Revision 1.1 2005/08/25 20:18:00 z0m3ie
Version 2.4 restructure
TCDPlayer removed (fits not in component structure)
TMP3ToWavConverter removed (fits not in component structure)
Revision 1.2 2005/08/22 20:17:01 z0m3ie
changed Headers to log
changed mail adress
}
unit libao;
{$ifdef fpc}
{$mode delphi}
{$endif}
interface
uses
baseunix,dl, ACS_Procs;
var
LibaoLoaded : Boolean = False;
const
LibaoPath = 'libao.so*'; // '/usr/lib/libao.so';
{$DEFINE SEARCH_LIBS}
AO_TYPE_LIVE = 1;
AO_TYPE_FILE = 2;
AO_ENODRIVER = 1;
AO_ENOTFILE = 2;
AO_ENOTLIVE = 3;
AO_EBADOPTION = 4;
AO_EOPENDEVICE = 5;
AO_EOPENFILE = 6;
AO_EFILEEXISTS = 7;
AO_EFAIL = 100;
AO_FMT_LITTLE = 1;
AO_FMT_BIG = 2;
AO_FMT_NATIVE = 4;
type
PPChar = array[0..0] of PChar;
PAOInfo = ^ao_info;
PPAOInfo = ^PAOInfo;
ao_info = record
_type : Integer; // live output or file output?
name : PChar; // full name of driver
short_name : PChar; // short name of driver */
author : PChar; // driver author
comment : PChar; // driver comment
preferred_byte_format : Integer;
priority : Integer;
options : PPChar;
option_count : Integer;
end;
PAOFunctions = ^ao_functions;
PAODevice = ^ao_device;
ao_device = packed record
_type : Integer; // live output or file output?
driver_id : Integer;
funcs : PAOFunctions;
_file : Pointer; // File for output if this is a file driver
client_byte_format : Integer;
machine_byte_format : Integer;
driver_byte_format : Integer;
swap_buffer : PChar;
swap_buffer_size : Integer; // Bytes allocated to swap_buffer
internal : Pointer; // Pointer to driver-specific data
end;
PAOSampleFormat = ^ao_sample_format;
ao_sample_format = record
bits : Integer; // bits per sample
rate : Integer; // samples per second (in a single channel)
channels : Integer; // number of audio channels
byte_format : Integer; // Byte ordering in sample, see constants below
end;
f_test = function : Integer; cdecl;
f_driver_info = function : PAOInfo; cdecl;
f_device_init = function(device : PAODevice) : Integer; cdecl;
f_set_option = function(device : PAODevice; const key, value : PChar) : Integer; cdecl;
f_open = function(device : PAODevice) : Integer; cdecl;
f_play = function(device : PAODevice; const output_samples : PChar; num_bytes : LongWord) : Integer; cdecl;
f_close = function(device : PAODevice) : Integer; cdecl;
f_device_clear = procedure(device : PAODevice); cdecl;
f_file_extension = function : PChar; cdecl;
ao_functions = packed record
test : f_test;
driver_info : f_driver_info;
device_init : f_device_init;
set_option : f_set_option;
open : f_open;
play : f_play;
close : f_close;
device_clear : f_device_clear;
file_extension : f_file_extension;
end;
PPAOOption = ^PAOOption;
PAOOption = ^ao_option;
ao_option = record
key : PChar;
value : PChar;
next : PAOOption;
end;
(* --- Functions --- *)
(* library setup/teardown *)
ao_initialize_t = procedure; cdecl;
ao_shutdown_t = procedure; cdecl;
(* device setup/playback/teardown *)
ao_append_option_t = function(options : PPAOOption; const key, value : PChar) : Integer; cdecl;
ao_free_options_t = procedure(options : PAOOption); cdecl;
ao_open_live_t = function(driver_id : Integer; format : PAOSampleFormat; option : PAOOption) : PAODevice; cdecl;
ao_open_file_t = function(driver_id : Integer; const filename : PChar; overwrite : Integer; format : PAOSampleFormat; option : PAOOption) : PAODevice; cdecl;
ao_play_t = function(device : PAODevice; output_samples : PChar; num_bytes : LongWord) : Integer; cdecl;
ao_close_t = function(device : PAODevice) : Integer; cdecl;
(* driver information *)
ao_driver_id_t = function(const short_name : PChar) : Integer; cdecl;
ao_default_driver_id_t = function : Integer; cdecl;
ao_driver_info_t = function(driver_id : Integer) : PAOInfo; cdecl;
ao_driver_info_list_t = function(var driver_count : Integer) : PPAOInfo; cdecl;
// The following function is declared in ao.h but not exported by libao.
//ao_file_extension_t = function(driver_id : Integer) : PChar; cdecl;
(* miscellaneous *)
ao_is_big_endian_t = function : Integer; cdecl;
var
ao_initialize : ao_initialize_t;
ao_shutdown : ao_shutdown_t;
ao_append_option : ao_append_option_t;
ao_free_options : ao_free_options_t;
ao_open_live : ao_open_live_t;
ao_open_file : ao_open_file_t;
ao_play : ao_play_t;
ao_close : ao_close_t;
ao_driver_id : ao_driver_id_t;
ao_default_driver_id : ao_default_driver_id_t;
ao_driver_info : ao_driver_info_t;
ao_driver_info_list : ao_driver_info_list_t;
//ao_file_extension : ao_file_extension_t;
ao_is_big_endian : ao_is_big_endian_t;
AOInitialized : Integer = 0;
procedure FreeOptionsList(var OL : PAOOption);
implementation
var
Libhandle : Pointer;
{$IFDEF SEARCH_LIBS}
Path : String;
{$ENDIF}
procedure FreeOptionsList(var OL : PAOOption);
var
NextOpt, tmp : PAOOption;
begin
if OL = nil then Exit;
NextOpt := OL;
repeat
tmp := NextOpt;
NextOpt := NextOpt.next;
FreeMem(tmp);
until NextOpt = nil;
end;
initialization
{$IFDEF SEARCH_LIBS}
Libhandle := nil;
Path := FindLibs(LibaoPath);
if Path <> '' then Libhandle := dlopen(@Path[1], RTLD_NOW or RTLD_GLOBAL);
{$ELSE}
Libhandle := dlopen(LibaoPath, RTLD_NOW or RTLD_GLOBAL);
{$ENDIF}
if Libhandle <> nil then
begin
LibaoLoaded := True;
ao_initialize := dlsym(Libhandle, 'ao_initialize');
ao_shutdown := dlsym(Libhandle, 'ao_shutdown');
ao_append_option := dlsym(Libhandle, 'ao_append_option');
ao_free_options := dlsym(Libhandle, 'ao_free_options');
ao_open_live := dlsym(Libhandle, 'ao_open_live');
ao_open_file := dlsym(Libhandle, 'ao_open_file');
ao_play := dlsym(Libhandle, 'ao_play');
ao_close := dlsym(Libhandle, 'ao_close');
ao_driver_id := dlsym(Libhandle, 'ao_driver_id');
ao_default_driver_id := dlsym(Libhandle, 'ao_default_driver_id');
ao_driver_info := dlsym(Libhandle, 'ao_driver_info');
ao_driver_info_list := dlsym(Libhandle, 'ao_driver_info_list');
//ao_file_extension := dlsym(Libhandle, 'ao_file_extension');
ao_is_big_endian := dlsym(Libhandle, 'ao_is_big_endian');
end;
finalization
if Libhandle <> nil then
begin
dlclose(Libhandle);
end;
end.

View File

@@ -0,0 +1,515 @@
(*
this file is a part of audio components suite v 2.3.
copyright (c) 2002-2005 andrei borovsky. all rights reserved.
see the license file for more details.
you can contact me at mail@z0m3ie.de
*)
{
$Log: soundcard.pas,v $
Revision 1.1 2005/12/19 18:36:16 z0m3ie
*** empty log message ***
Revision 1.1 2005/09/14 21:19:37 z0m3ie
*** empty log message ***
Revision 1.1 2005/09/12 22:04:52 z0m3ie
modified structure again, fileformats are now in an sperat folder.
all File In/Out classes are capsulated from TFileIn and TFileOut
Revision 1.1 2005/08/25 20:18:00 z0m3ie
Version 2.4 restructure
TCDPlayer removed (fits not in component structure)
TMP3ToWavConverter removed (fits not in component structure)
Revision 1.2 2005/08/22 20:17:01 z0m3ie
changed Headers to log
changed mail adress
}
unit soundcard;
interface
// Supported card ID numbers (OBSOLETE. NOT USED ANY MORE)
const
SNDCARD_ADLIB = 1;
SNDCARD_SB = 2;
SNDCARD_PAS = 3;
SNDCARD_GUS = 4;
SNDCARD_MPU401 = 5;
SNDCARD_SB16 = 6;
SNDCARD_SB16MIDI = 7;
SNDCARD_UART6850 = 8;
SNDCARD_GUS16 = 9;
SNDCARD_MSS = 10;
SNDCARD_PSS = 11;
SNDCARD_SSCAPE = 12;
SNDCARD_PSS_MPU = 13;
SNDCARD_PSS_MSS = 14;
SNDCARD_SSCAPE_MSS = 15;
SNDCARD_TRXPRO = 16;
SNDCARD_TRXPRO_SB = 17;
SNDCARD_TRXPRO_MPU = 18;
SNDCARD_MAD16 = 19;
SNDCARD_MAD16_MPU = 20;
SNDCARD_CS4232 = 21;
SNDCARD_CS4232_MPU = 22;
SNDCARD_MAUI = 23;
SNDCARD_PSEUDO_MSS = 24;
SNDCARD_GUSPNP = 25;
SNDCARD_UART401 = 26;
// Sound card numbers 27 to N are reserved. Don't add more numbers here
//**********************************
// IOCTL commands for /dev/dsp and /dev/audio
const
SNDCTL_DSP_RESET = $5000;
SNDCTL_DSP_SPEED = $c0045002;
SNDCTL_DSP_STEREO = $c0045003;
SNDCTL_DSP_GETBLKSIZE = $c0045004;
SNDCTL_DSP_SAMPLESIZE = $c0045005;
SNDCTL_DSP_CHANNELS = $c0045006;
SOUND_PCM_WRITE_CHANNELS = $c0045006;
SOUND_PCM_WRITE_FILTER = $c0045007;
SNDCTL_DSP_POST = $5008;
SNDCTL_DSP_SUBDIVIDE = $c0045009;
SNDCTL_DSP_SETFRAGMENT = $c004500a;
// Audio data formats (Note! U8=8 and S16_LE=16 for compatibility)*/ }
SNDCTL_DSP_GETFMTS = $8004500b;
SNDCTL_DSP_SETFMT = $c0045005;
AFMT_QUERY = 0;
AFMT_MU_LAW = 1;
AFMT_A_LAW = 2;
AFMT_IMA_ADPCM = 4;
AFMT_U8 = 8;
AFMT_S16_LE = $10;
AFMT_S16_BE = $20;
AFMT_S8 = $40;
AFMT_U16_LE = $80;
AFMT_U16_BE = $100;
AFMT_MPEG = $200;
// 32 bit formats (MSB aligned) formats
AFMT_S32_LE = $1000;
AFMT_S32_BE = $2000;
// AC3 _compressed_ bitstreams (See Programmer's Guide for details).
AFMT_AC3 = $4000;
// 24 bit formats (LSB aligned in 32 bit word) formats*/ }
AFMT_S24_LE = $8000;
AFMT_S24_BE = $10000;
(* S/PDIF raw format. In this format the S/PDIF frames (including all
control and user bits) are included in the data stream. Each sample
is stored in a 32 bit frame (see IEC-958 for more info). This format
is supported by very few devices and it's only usable for purposes
where full access to the control/user bits is required (real time control).
*)
AFMT_SPDIF_RAW = $20000;
type
audio_buf_info = record
fragments: Integer; // of available fragments (partially usend ones not counted)
fragstotal: Integer; // Total # of fragments allocated
fragsize: Integer; // Size of a fragment in bytes
bytes: Integer; // Available space in bytes (includes partially used fragments)
// Note! 'bytes' could be more than fragments*fragsize*/
end;
const
SNDCTL_DSP_GETOSPACE = $8010500c;
SNDCTL_DSP_GETISPACE = $8010500d;
SNDCTL_DSP_NONBLOCK = $500e;
SNDCTL_DSP_GETCAPS = $8004500f;
DSP_CAP_REVISION = $ff; // Bits for revision level (0 to 255)
DSP_CAP_DUPLEX = $100; // Full duplex record/playback
DSP_CAP_REALTIME = $200; // Not in use
DSP_CAP_BATCH = $400; (* Device has some kind of
internal buffers which may
cause some delays and
decrease precision of timing *)
DSP_CAP_COPROC = $800; // Has a coprocessor
(* Sometimes it's a DSP
but usually not *)
DSP_CAP_TRIGGER = $1000; // Supports SETTRIGGER
DSP_CAP_MMAP = $2000; // Supports mmap()
DSP_CAP_MULTI = $4000; // Supports multiple open
DSP_CAP_BIND = $8000; // Supports binding to front/rear/center/lfe
DSP_CAP_INPUT = $10000; // Supports recording
DSP_CAP_OUTPUT = $20000; // Supports playback
DSP_CAP_VIRTUAL = $40000; // Virtuial device
// Analog/digital control capabilities
DSP_CAP_ANALOGOUT = $100000;
DSP_CAP_ANALOGIN = $200000;
DSP_CAP_DIGITALOUT = $400000;
DSP_CAP_DIGITALIN = $800000;
DSP_CAP_ADMASK = $f00000;
(* NOTE! (capabilities & DSP_CAP_ADMASK)==0 means just that the
digital/analog interface control features are not supported by the
device/driver. However the device still supports analog, digital or
both inputs/outputs (depending on the device). See the OSS Programmer's
Guide for full details. *)
SNDCTL_DSP_GETTRIGGER = $80045010;
SNDCTL_DSP_SETTRIGGER = $40045010;
PCM_ENABLE_INPUT = 1;
PCM_ENABLE_OUTPUT = 2;
type
count_info = record
bytes: Integer; // Total # of bytes processed
blocks : Integer; // # of fragment transitions since last time
ptr: Integer; // Current DMA pointer value }
end;
const
SNDCTL_DSP_GETIPTR = $800c5011;
SNDCTL_DSP_GETOPTR = $800c5012;
type
buffmem_desc = record
buffer: PWord;
size: Integer;
end;
const
SNDCTL_DSP_MAPINBUF = $80085013;
SNDCTL_DSP_MAPOUTBUF = $80085014;
SNDCTL_DSP_SETSYNCRO = $5015;
SNDCTL_DSP_SETDUPLEX = $5016;
// Application's profile defines the way how playback underrun situations should be handled.
(* APF_NORMAL (the default) and APF_NETWORK make the driver to cleanup the
playback buffer whenever an underrun occurs. This consumes some time
prevents looping the existing buffer.
APF_CPUINTENS is intended to be set by CPU intensive applications which
are likely to run out of time occasionally. In this mode the buffer cleanup is
disabled which saves CPU time but also let's the previous buffer content to
be played during the "pause" after the underrun. *)
const
SNDCTL_DSP_PROFILE = $40045017;
APF_NORMAL = 0; // Normal applications
APF_NETWORK = 1; // Underruns probably caused by an 'external' delay
APF_CPUINTENS = 2; // Underruns probably caused by 'overheating' the CPU
SNDCTL_DSP_GETODELAY = $80045017;
type
audio_errinfo = record
play_underruns: Integer;
rec_overruns: Integer;
play_ptradjust: Word;
rec_ptradjust: Word;
play_errorcount: Integer;
rec_errorcount: Integer;
play_lasterror: Integer;
rec_lasterror: Integer;
play_errorparm: LongInt;
rec_errorparm: LongInt;
filler: array[0..15] of Integer;
end;
type
oss_digital_control = record
caps: LongWord; // To be defined }
valid : LongWord;
cbitin: array[0..23] of Byte;
ubitin: array[0..23] of Byte;
cbitout: array[0..23] of Byte;
ubitout: array[0..23] of Byte;
outsel: LongWord;
in_data: Integer; // Audio/data if autodetectable by the receiver
in_locked: Integer; // Receiver locked
in_quality: Integer; // Input signal quality
in_vbit, out_vbit: Integer; // V bits
in_errors: LongWord; // Various input errro conditions
end;
const
DIG_CBITIN_LIMITED = $00000001;
DIG_CBITIN_DATA = $00000002;
DIG_CBITIN_BYTE0 = $00000004;
DIG_CBITIN_FULL = $00000008;
DIG_CBITIN_MASK = $0000000;
DIG_CBITOUT_LIMITED = $00000010;
DIG_CBITOUT_BYTE0 = $00000020;
DIG_CBITOUT_FULL = $00000040;
DIG_CBITOUT_DATA = $00000080;
DIG_CBITOUT_MASK = $000000f0;
DIG_UBITIN = $00000100;
DIG_UBITOUT = $00000200;
VAL_CBITIN = $01;
VAL_UBITIN = $02;
VAL_CBITOUT = $04;
VAL_UBITOUT = $08;
VAL_ISTATUS = $10;
OUTSEL_DIGITAL = 1;
OUTSEL_ANALOG = 2;
OUTSEL_BOTH = (OUTSEL_DIGITAL or OUTSEL_ANALOG);
IND_UNKNOWN = 0;
IND_AUDIO = 1;
IND_DATA = 2;
LOCK_NOT_INDICATED = 0;
LOCK_UNLOCKED = 1;
LOCK_LOCKED = 2;
IN_QUAL_NOT_INDICATED = 0;
IN_QUAL_POOR = 1;
IN_QUAL_GOOD = 2;
VBIT_NOT_INDICATED = 0;
VBIT_OFF = 1;
VBIT_ON = 2;
INERR_CRC = $0001;
INERR_QCODE_CRC = $0002;
INERR_PARITY = $0004;
INERR_BIPHASE = $0008;
type
oss_syncgroup = record
id: Integer;
mode: Integer;
end;
const
SNDCTL_DSP_GETCHANNELMASK = $c0045040;
SNDCTL_DSP_BIND_CHANNEL = $c0045041;
DSP_BIND_QUERY = 0;
DSP_BIND_FRONT = 1;
DSP_BIND_SURR = 2;
DSP_BIND_CENTER_LFE = 4;
DSP_BIND_HANDSET = 8;
DSP_BIND_MIC = $10;
DSP_BIND_MODEM1 = $20;
DSP_BIND_MODEM2 = $40;
DSP_BIND_I2S = $80;
DSP_BIND_SPDIF = $100;
// Mixer devices
(* There can be up to 20 different analog mixer channels. The }
SOUND_MIXER_NRDEVICES gives the currently supported maximum.
The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells
the devices supported by the particular mixer.
*)
const
SOUND_MIXER_NRDEVICES = 28;
SOUND_MIXER_VOLUME = 0;
SOUND_MIXER_BASS = 1;
SOUND_MIXER_TREBLE = 2;
SOUND_MIXER_SYNTH = 3;
SOUND_MIXER_PCM = 4;
SOUND_MIXER_SPEAKER = 5;
SOUND_MIXER_LINE = 6;
SOUND_MIXER_MIC = 7;
SOUND_MIXER_CD = 8;
SOUND_MIXER_IMIX = 9; // Recording monitor
SOUND_MIXER_ALTPCM = 10;
SOUND_MIXER_RECLEV = 11; // Recording level
SOUND_MIXER_IGAIN = 12; // Input gain
SOUND_MIXER_OGAIN = 13; // Output gain
(* The AD1848 codec and compatibles have three line level inputs
(line, aux1 and aux2). Since each card manufacturer have assigned
different meanings to these inputs, it's inpractical to assign
specific meanings (line, cd, synth etc.) to them. *)
SOUND_MIXER_LINE1 = 14; // Input source 1 (aux1)
SOUND_MIXER_LINE2 = 15; // Input source 2 (aux2)
SOUND_MIXER_LINE3 = 16; // Input source 3 (line)
SOUND_MIXER_DIGITAL1 = 17; // Digital (input)
SOUND_MIXER_DIGITAL2 = 18; // Digital (input) 2
SOUND_MIXER_DIGITAL3 = 19; // Digital (input) 3
SOUND_MIXER_PHONEIN = 20; // Phone input
SOUND_MIXER_PHONEOUT = 21; // Phone output
SOUND_MIXER_VIDEO = 22; // Video/TV (audio) in
SOUND_MIXER_RADIO = 23; // Radio in
SOUND_MIXER_MONITOR = 24; // Monitor (usually mic) volume
SOUND_MIXER_DEPTH = 25; // 3D 'depth'/'space' parameter
SOUND_MIXER_CENTER = 26; // 3D 'center' parameter
SOUND_MIXER_MIDI = 27; // Alternative for 'synth'
(* Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX)
Not counted to SOUND_MIXER_NRDEVICES, but use the same number space *)
SOUND_ONOFF_MIN = 28;
SOUND_ONOFF_MAX = 30;
// Note! Number 31 cannot be used since the sign bit is reserved
SOUND_MIXER_NONE = 31;
(* The following unsupported macros are no longer functional.
Use SOUND_MIXER_PRIVATE# macros in future. *)
SOUND_MIXER_ENHANCE = SOUND_MIXER_NONE;
SOUND_MIXER_MUTE = SOUND_MIXER_NONE;
SOUND_MIXER_LOUD = SOUND_MIXER_NONE;
SOUND_DEVICE_LABELS : array[0..27] of PChar = ('Vol ', 'Bass ', 'Trebl', 'Synth', 'Pcm ', 'Spkr ', 'Line ',
'Mic ', 'CD ', 'Mix ', 'Pcm2 ', 'Rec ', 'IGain', 'OGain',
'Line1', 'Line2', 'Line3', 'Digital1', 'Digital2', 'Digital3',
'PhoneIn', 'PhoneOut', 'Video', 'Radio', 'Monitor',
'Depth', 'Center', 'MIDI');
SOUND_DEVICE_NAMES : array[0..27] of PChar = ('vol', 'bass', 'treble', 'synth', 'pcm', 'speaker', 'line',
'mic', 'cd', 'mix', 'pcm2', 'rec', 'igain', 'ogain',
'line1', 'line2', 'line3', 'dig1', 'dig2', 'dig3',
'phin', 'phout', 'video', 'radio', 'monitor',
'depth', 'center', 'midi');
// Device bitmask identifiers
SOUND_MIXER_RECSRC = $ff; // Arg contains a bit for each recording source
SOUND_MIXER_DEVMASK = $fe; // Arg contains a bit for each supported device
SOUND_MIXER_RECMASK = $fd; // Arg contains a bit for each supported recording source
SOUND_MIXER_CAPS = $fc;
SOUND_CAP_EXCL_INPUT = $1; // Only one recording source at a time
SOUND_MIXER_STEREODEVS = $fb; // Mixer channels supporting stereo
// OSS/Free ONLY
SOUND_MIXER_OUTSRC = $fa; // Arg contains a bit for each input source to output
SOUND_MIXER_OUTMASK = $f9; // Arg contains a bit for each supported input source to output
// OSS/Free ONLY
// Device mask bits
SOUND_MASK_VOLUME = 1 shl SOUND_MIXER_VOLUME;
SOUND_MASK_BASS = 1 shl SOUND_MIXER_BASS;
SOUND_MASK_TREBLE = 1 shl SOUND_MIXER_TREBLE;
SOUND_MASK_SYNTH = 1 shl SOUND_MIXER_SYNTH;
SOUND_MASK_PCM = 1 shl SOUND_MIXER_PCM;
SOUND_MASK_SPEAKER = 1 shl SOUND_MIXER_SPEAKER;
SOUND_MASK_LINE = 1 shl SOUND_MIXER_LINE;
SOUND_MASK_MIC = 1 shl SOUND_MIXER_MIC;
SOUND_MASK_CD = 1 shl SOUND_MIXER_CD;
SOUND_MASK_IMIX = 1 shl SOUND_MIXER_IMIX;
SOUND_MASK_ALTPCM = 1 shl SOUND_MIXER_ALTPCM;
SOUND_MASK_RECLEV = 1 shl SOUND_MIXER_RECLEV;
SOUND_MASK_IGAIN = 1 shl SOUND_MIXER_IGAIN;
SOUND_MASK_OGAIN = 1 shl SOUND_MIXER_OGAIN;
SOUND_MASK_LINE1 = 1 shl SOUND_MIXER_LINE1;
SOUND_MASK_LINE2 = 1 shl SOUND_MIXER_LINE2;
SOUND_MASK_LINE3 = 1 shl SOUND_MIXER_LINE3;
SOUND_MASK_DIGITAL1 = 1 shl SOUND_MIXER_DIGITAL1;
SOUND_MASK_DIGITAL2 = 1 shl SOUND_MIXER_DIGITAL2;
SOUND_MASK_DIGITAL3 = 1 shl SOUND_MIXER_DIGITAL3;
SOUND_MASK_PHONEIN = 1 shl SOUND_MIXER_PHONEIN;
SOUND_MASK_PHONEOUT = 1 shl SOUND_MIXER_PHONEOUT;
SOUND_MASK_RADIO = 1 shl SOUND_MIXER_RADIO;
SOUND_MASK_VIDEO = 1 shl SOUND_MIXER_VIDEO;
SOUND_MASK_MONITOR = 1 shl SOUND_MIXER_MONITOR;
SOUND_MASK_DEPTH = 1 shl SOUND_MIXER_DEPTH;
SOUND_MASK_CENTER = 1 shl SOUND_MIXER_CENTER;
SOUND_MASK_MIDI = 1 shl SOUND_MIXER_MIDI;
SOUND_MIXER_READ_VOLUME = $80044d00;
SOUND_MIXER_READ_BASS = $80044d01;
SOUND_MIXER_READ_TREBLE = $80044d02;
SOUND_MIXER_READ_SYNTH = $80044d03;
SOUND_MIXER_READ_PCM = $80044d04;
SOUND_MIXER_READ_SPEAKER = $80044d05;
SOUND_MIXER_READ_LINE = $80044d06;
SOUND_MIXER_READ_MIC = $80044d07;
SOUND_MIXER_READ_CD = $80044d08;
SOUND_MIXER_READ_IMIX = $80044d09;
SOUND_MIXER_READ_ALTPCM = $80044d0a;
SOUND_MIXER_READ_RECLEV = $80044d0b;
SOUND_MIXER_READ_IGAIN = $80044d0c;
SOUND_MIXER_READ_OGAIN = $80044d0d;
SOUND_MIXER_READ_LINE1 = $80044d0e;
SOUND_MIXER_READ_LINE2 = $80044d0f;
SOUND_MIXER_READ_LINE3 = $80044d10;
SOUND_MIXER_READ_RECSRC = $80044dff;
SOUND_MIXER_READ_RECMASK = $80044dfd;
SOUND_MIXER_READ_DEVMASK = $80044dfe;
SOUND_MIXER_READ_STEREODEVS = $80044dfb;
SOUND_MIXER_READ_CAPS = $80044dfc;
SOUND_MIXER_WRITE_VOLUME = $c0044d00;
SOUND_MIXER_WRITE_BASS = $c0044d01;
SOUND_MIXER_WRITE_TREBLE = $c0044d02;
SOUND_MIXER_WRITE_SYNTH = $c0044d03;
SOUND_MIXER_WRITE_PCM = $c0044d04;
SOUND_MIXER_WRITE_SPEAKER = $c0044d05;
SOUND_MIXER_WRITE_LINE = $c0044d06;
SOUND_MIXER_WRITE_MIC = $c0044d07;
SOUND_MIXER_WRITE_CD = $c0044d08;
SOUND_MIXER_WRITE_IMIX = $c0044d09;
SOUND_MIXER_WRITE_ALTPCM = $c0044d0a;
SOUND_MIXER_WRITE_RECLEV = $c0044d0b;
SOUND_MIXER_WRITE_IGAIN = $c0044d0c;
SOUND_MIXER_WRITE_OGAIN = $c0044d0d;
SOUND_MIXER_WRITE_LINE1 = $c0044d0e;
SOUND_MIXER_WRITE_LINE2 = $c0044d0f;
SOUND_MIXER_WRITE_LINE3 = $c0044d10;
SOUND_MIXER_WRITE_RECSRC = $c0044dff;
SOUND_MIXER_INFO = $805c4d65;
type
mixer_info = record
id: array[0..15] of Char;
name: array[0..31] of Char;
modify_counter: Integer;
fillers: array[0..9] of Integer;
end;
const
SOUND_MIXER_ACCESS = $c0804d66;
SOUND_MIXER_GETLEVELS = $c0a44d74;
SOUND_MIXER_SETLEVELS = $c0a44d75;
(* SOUND_MIXER_GETLEVELS and SOUND_MIXER_SETLEVELS calls can be used
for querying current mixer settings from the driver and for loading
default volume settings _prior_ activating the mixer (loading
doesn't affect current state of the mixer hardware). These calls
are for internal use only. *)
type
mixer_vol_table = record
num: Integer; // Index to volume table
name: array[0..31] of Char;
levels: array[0..31] of Integer;
end;
implementation
end.

View File

@@ -0,0 +1,408 @@
{
$Log: acs_audio.inc,v $
Revision 1.7 2006/08/31 20:10:56 z0m3ie
*** empty log message ***
Revision 1.6 2006/07/04 17:12:45 z0m3ie
ACS 2.4 alt wiederhergestellt (unterschiedliche Sampleformate ...)
Revision 1.3 2006/01/01 18:46:40 z0m3ie
*** empty log message ***
Revision 1.2 2005/12/26 17:31:39 z0m3ie
fixed some problems in acs_dsfiles
fixed some problems in acs_vorbis
reworked all buffers
Revision 1.1 2005/12/19 18:36:26 z0m3ie
*** empty log message ***
Revision 1.6 2005/12/18 17:01:54 z0m3ie
delphi compatibility
Revision 1.5 2005/12/04 16:54:34 z0m3ie
All classes are renamed, Style TACS... than T... to avoid conflicts with other components (eg TMixer is TACSMixer now)
Revision 1.4 2005/11/27 16:50:34 z0m3ie
add ACS VolumeQuerry
make ACS_VolumeQuerry localizeable
some little errorfixes (buffersize for linuxdrivers was initially 0)
make TAudioIn workable
Revision 1.3 2005/10/02 16:51:31 z0m3ie
*** empty log message ***
Revision 1.2 2005/09/18 19:29:00 z0m3ie
more progress on driver handling
}
function GetAudioDeviceInfo(DevID : Integer; OutputDev : Boolean) : TACSDeviceInfo;
var
WIC : TWaveInCaps;
i : Integer;
begin
if OutputDev then
begin
if DevID >= OutputChannelsCount then
raise EACSException.Create(Format(strChannelnotavailable,[DevId]));
end else
begin
if DevID >= InputChannelsCount then
raise EACSException.Create(Format(strChannelnotavailable,[DevId]));
end;
if OutputDev then waveOutGetDevCaps(DevID, @WIC, SizeOf(WIC))
else waveInGetDevCaps(DevID, @WIC, SizeOf(WIC));
i := 0;
while WIC.szPname[i] <> #0 do Inc(i);
SetLength(Result.DeviceName, i);
Move(WIC.szPname[0], Result.DeviceName[1], i);
Result.Formats := [];
if (WIC.dwFormats and WAVE_FORMAT_1M08) <> 0 then Result.Formats := Result.Formats + [af1M08];
if (WIC.dwFormats and WAVE_FORMAT_1M16) <> 0 then Result.Formats := Result.Formats + [af1M16];
if (WIC.dwFormats and WAVE_FORMAT_1S08) <> 0 then Result.Formats := Result.Formats + [af1S08];
if (WIC.dwFormats and WAVE_FORMAT_1S16) <> 0 then Result.Formats := Result.Formats + [af1S16];
if (WIC.dwFormats and WAVE_FORMAT_2M08) <> 0 then Result.Formats := Result.Formats + [af2M08];
if (WIC.dwFormats and WAVE_FORMAT_2M16) <> 0 then Result.Formats := Result.Formats + [af2M16];
if (WIC.dwFormats and WAVE_FORMAT_2S08) <> 0 then Result.Formats := Result.Formats + [af2S08];
if (WIC.dwFormats and WAVE_FORMAT_2S16) <> 0 then Result.Formats := Result.Formats + [af2S16];
if (WIC.dwFormats and WAVE_FORMAT_4M08) <> 0 then Result.Formats := Result.Formats + [af4M08];
if (WIC.dwFormats and WAVE_FORMAT_4M16) <> 0 then Result.Formats := Result.Formats + [af4M16];
if (WIC.dwFormats and WAVE_FORMAT_4S08) <> 0 then Result.Formats := Result.Formats + [af4S08];
if (WIC.dwFormats and WAVE_FORMAT_4S16) <> 0 then Result.Formats := Result.Formats + [af4S16];
Result.DrvVersion := WIC.vDriverVersion;
if WIC.wChannels = 1 then Result.Stereo := False else Result.Stereo := True;
end;
procedure WaveOutProc(hwo, Msg : LongWord; Instance : Pointer; Param1, Param2 : LongWord); stdcall;
var
Audio : TStdAudioOut;
begin
EnterCriticalSection(CrSecO);
if Msg = WOM_DONE then
begin
Audio := TStdAudioOut(Instance);
Audio.AddBlockToChain(PWaveHdr(Param1));
end;
LeaveCriticalSection(CrSecO);
end;
procedure WaveInProc(hwi, Msg : LongWord; Instance : Pointer; Param1, Param2 : LongWord); stdcall;
var
Audio : TStdAudioIn;
begin
EnterCriticalSection(CrSecI);
if Msg = WIM_DATA then
begin
Audio := TStdAudioIn(Instance);
Audio.AddBlockToChain(PWaveHdr(Param1));
end;
LeaveCriticalSection(CrSecI);
end;
procedure TStdAudioOut.AddBlockToChain(WH : PWaveHdr);
begin
WH.lpNext := nil;
EOC^ := WH;
EOC := @WH.lpNext;
Dec(aBlock);
end;
procedure TStdAudioOut.SetDevice;
begin
if Busy then raise EACSException.Create(strBusy);
if OutputChannelsCount = 0 then FBaseChannel := 0 else
if Ch < OutputChannelsCount then FBaseChannel := Ch
else raise EACSException.Create(Format(strChannelnotavailable,[Ch]));
end;
procedure TStdAudioOut.Prepare;
var
WF : TPCMWaveFormat;
begin
// No exceptions here!
FInput.Init;
WF.wf.wFormatTag := WAVE_FORMAT_PCM;
WF.wf.nChannels := FInput.Channels;
WF.wf.nSamplesPerSec := FInput.SampleRate;
WF.wBitsPerSample := FInput.BitsPerSample;
WF.wf.nAvgBytesPerSec := WF.wf.nSamplesPerSec*WF.wBitsPerSample div 8;
WF.wf.nBlockAlign := WF.wf.nChannels * WF.wBitsPerSample div 8;
waveOutOpen(@_audio_fd, FBaseChannel, @WF, DWORD(@WaveOutProc), DWORD(Self), CALLBACK_FUNCTION or WAVE_MAPPED);
aBlock := 0;
FBuffer := AllocMem(FBufferSize);
EOC := @BlockChain;
end;
procedure TStdAudioOut.Done;
var
Tmp : PWaveHdr;
begin
if _audio_fd <> -1 then
begin
while aBlock > 0 do;
Tmp := BlockChain;
while Tmp <> nil do
begin
BlockChain := Tmp.lpNext;
waveOutUnprepareHeader(_audio_fd, Tmp, SizeOf(TWaveHdr));
FreeMem(Tmp.lpData);
Dispose(Tmp);
Tmp := BlockChain;
end;
EOC := @BlockChain;
waveOutClose(_audio_fd);
FreeMem(FBuffer);
_audio_fd := -1;
end;
FInput.Flush;
end;
function TStdAudioOut.DoOutput(Abort : Boolean):Boolean;
var
Len, i, k, vCoef : Integer;
P : Pointer;
P1 : PACSBuffer8;
P2 : PACSBuffer16;
Tmp : PWaveHdr;
begin
// No exceptions Here
Result := True;
if not Busy then Exit;
if Abort or (not CanOutput) then
begin
Result := False;
Exit;
end;
Tmp := BlockChain; // clear pending data blocks
while Tmp <> nil do
begin
BlockChain := Tmp.lpNext;
waveOutUnprepareHeader(_audio_fd, Tmp, SizeOf(TWaveHdr));
FreeMem(Tmp.lpData);
Dispose(Tmp);
Tmp := BlockChain;
end;
EOC := @BlockChain;
(* Write more than one block. This is needed for audio sources like
Vorbis codec that return data in small chunks. *)
for k := aBlock to FReadChunks do
begin
GetMem(P, FBufferSize div FReadChunks);
while InputLock do;
InputLock := True;
Len := Finput.GetData(P, FBufferSize div FReadChunks);
InputLock := False;
if Len > 0 then Result := True
else
begin
Result := False;
FreeMem(P);
Exit;
end;
if FVolume < 255 then
begin
vCoef := Round(FVolume/255);
if FInput.BitsPerSample = 16 then
begin
P2 := P;
for i := 0 to (Len shr 1) -1 do
P2[i] := P2[i]*vCoef;
end else
begin
P1 := P;
for i := 0 to Len - 1 do
P1[i] := P1[i]*vCoef;
end;
end;
WriteBlock(P, Len);
end;
end;
constructor TStdAudioOut.Create;
begin
inherited Create(AOwner);
FBaseChannel := 0;
FVolume := 255;
_audio_fd := -1;
Delay := 6;
FReadChunks := 8;
FBufferSize := $8000;
end;
destructor TStdAudioOut.Destroy;
begin
if _audio_fd <> -1 then WaveOutClose(_audio_fd);
inherited Destroy;
end;
destructor TStdAudioIn.Destroy;
begin
waveInClose(_audio_fd);
inherited Destroy;
end;
procedure TStdAudioIn.OpenAudio;
var
WF : TPCMWaveFormat;
begin
WF.wf.wFormatTag := WAVE_FORMAT_PCM;
WF.wf.nChannels := FChan;
WF.wf.nSamplesPerSec := FFreq;
WF.wBitsPerSample := FBPS;
WF.wf.nAvgBytesPerSec := WF.wf.nSamplesPerSec*WF.wBitsPerSample div 8;
WF.wf.nBlockAlign := WF.wf.nChannels * WF.wBitsPerSample div 8;
if FOpened = 0 then
begin
waveInOpen(@_audio_fd, FBaseChannel, @WF, DWORD(@WaveInProc), DWORD(Self), CALLBACK_FUNCTION or WAVE_MAPPED);
end;
Inc(FOpened);
end;
procedure TStdAudioIn.CloseAudio;
begin
if FOpened = 1 then
begin
waveInClose(_audio_fd);
FreeMem(FBuffer);
end;
if FOpened > 0 then Dec(FOpened);
end;
function TStdAudioIn.GetBPS : Integer;
begin
Result := FBPS;
end;
function TStdAudioIn.GetCh : Integer;
begin
Result := FChan;
end;
function TStdAudioIn.GetSR : Integer;
begin
Result := FFreq;
end;
procedure TStdAudioIn.Init;
begin
if Busy then raise EACSException.Create(strBusy);
BufEnd := 0;
BufStart := 1;
FPosition := 0;
FRecBytes := FRecTime * (GetBPS div 8) * GetCh * GetSR;
FBusy := True;
OpenAudio;
waveInStart(_audio_fd);
BlockChain := nil;
FSize := FRecBytes;
aBlock := 0;
EOC := @BlockChain;
end;
procedure TStdAudioIn.Flush;
var
Tmp : PWaveHdr;
begin
while aBlock > 0 do; // wait until pending data blocks are put to the chain
waveInReset(_audio_fd); // return all pending data blocks
sleep(10);
Tmp := BlockChain; // clear pending data blocks
while Tmp <> nil do
begin
BlockChain := Tmp.lpNext;
waveInUnprepareHeader(_audio_fd, Tmp, SizeOf(TWaveHdr));
FreeMem(Tmp.lpData);
Dispose(Tmp);
Tmp := BlockChain;
end;
CloseAudio;
FBusy := False;
end;
procedure TStdAudioIn.SetDevice;
begin
if Busy then raise EACSException.Create(strBusy);
if Ch < InputChannelsCount then FBaseChannel := Ch
else raise EACSException.Create(Format(strChannelnotavailable,[Ch]));
end;
function TStdAudioIn.GetData(Buffer : Pointer; oBufferSize : Integer): Integer;
var
Tmp : PWaveHdr;
begin
if not Busy then raise EACSException.Create(strStreamnotopen);
if FRecBytes >= 0 then
if (FPosition >= FRecBytes) then
begin
Result := 0;
Exit;
end;
while aBlock < FBlocksCount do
NewBlock;
if BufStart > BufEnd then
begin
BufStart := 1;
while BlockChain = nil do
sleep(10);
TMP := BlockChain;
BlockChain := BlockChain.lpNext;
if BlockChain = nil then
EOC := @BlockChain;
Move(Tmp.lpData[0], FBuffer[1], Tmp.dwBytesRecorded);
BufEnd := Tmp.dwBytesRecorded;
waveInUnprepareHeader(_audio_fd, Tmp, SizeOf(TWaveHdr));
FreeMem(Tmp.lpData);
Dispose(Tmp);
end;
if BufferSize < (BufEnd - BufStart + 1) then
Result := BufferSize
else
Result := BufEnd - BufStart + 1;
Move(FBuffer[BufStart], Buffer^, Result);
Inc(BufStart, Result);
Inc(FPosition, Result);
end;
procedure TStdAudioOut.WriteBlock;
var
WH : PWaveHdr;
begin
Inc(aBlock);
New(WH);
WH.lpData := P;
WH.dwBufferLength := Len;
WH.dwLoops := 0;
WH.dwFlags := 0;
waveOutPrepareHeader(_audio_fd, WH, SizeOf(TWaveHdr));
waveOutWrite(_audio_fd, WH, SizeOf(TWaveHdr));
end;
procedure TStdAudioIn.NewBlock;
var
WH : PWaveHdr;
begin
New(WH);
GetMem(WH.lpData, BufferSize div FBlocksCount);
WH.dwBufferLength := BufferSize div FBlocksCount;
WH.dwFlags := 0;
waveInPrepareHeader(_audio_fd, WH, SizeOf(TWaveHdr));
waveInAddBuffer(_audio_fd, WH, SizeOf(TWaveHdr));
Inc(aBlock);
end;
function CountChannels : Integer;
begin
OutputChannelsCount := waveOutGetNumDevs;
InputChannelsCount := waveInGetNumDevs;
end;
procedure TStdAudioIn.AddBlockToChain(WH : PWaveHdr);
begin
WH.lpNext := nil;
EOC^ := WH;
EOC := @WH.lpNext;
Dec(aBlock);
end;