Save small change

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2331 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
yangjixian
2012-03-03 09:28:11 +00:00
parent d5190ae858
commit 96d0c1deb9
3 changed files with 15 additions and 20 deletions

View File

@ -38,6 +38,7 @@
* the terms of any one of the MPL, the GPL or the LGPL. * the terms of any one of the MPL, the GPL or the LGPL.
*) *)
//The original file name is openal.pas
unit OpenAL_NT; unit OpenAL_NT;
{$IFDEF FPC} {$IFDEF FPC}
@ -2341,7 +2342,6 @@ begin
stream.Position := stream.Position + readint; stream.Position := stream.Position + readint;
end; end;
until stream.Position >= stream.size; until stream.Position >= stream.size;
end; end;
procedure alutLoadWAVFile(fname: string; var format: TALenum; var data: TALvoid; procedure alutLoadWAVFile(fname: string; var format: TALenum; var data: TALvoid;

View File

@ -79,12 +79,12 @@ type
TSoundDocument = class TSoundDocument = class
private private
AStream: TMemoryStream;
FPlayer: TSoundPlayer; FPlayer: TSoundPlayer;
FPlayerKind: TSoundPlayerKind; FPlayerKind: TSoundPlayerKind;
FCurElementIndex: Integer; FCurElementIndex: Integer;
FSoundData: TFPList; // of TSoundElement FSoundData: TFPList; // of TSoundElement
public public
SoundDocStream: TMemoryStream;
constructor Create; virtual; constructor Create; virtual;
destructor Destroy; override; destructor Destroy; override;
// Document read/save methods // Document read/save methods
@ -104,7 +104,6 @@ type
procedure Stop; procedure Stop;
procedure Seek(ANewPos: Double); procedure Seek(ANewPos: Double);
procedure SetSoundPlayer(AKind: TSoundPlayerKind); procedure SetSoundPlayer(AKind: TSoundPlayerKind);
function GetSoundDocStream: TStream;
end; end;
var var
@ -170,13 +169,13 @@ begin
inherited Create; inherited Create;
FSoundData := TFPList.Create; FSoundData := TFPList.Create;
aStream := TMemoryStream.Create; SoundDocStream := TMemoryStream.Create;
end; end;
destructor TSoundDocument.Destroy; destructor TSoundDocument.Destroy;
begin begin
FSoundData.Free; FSoundData.Free;
aStream.Free; SoundDocStream.Free;
if FPlayer <> nil then FPlayer.Finalize; if FPlayer <> nil then FPlayer.Finalize;
inherited Destroy; inherited Destroy;
end; end;
@ -200,8 +199,8 @@ begin
Clear(); Clear();
lReader.ReadFromStream(lStream, Self); lReader.ReadFromStream(lStream, Self);
lStream.Position := 0; lStream.Position := 0;
aStream.Clear; SoundDocStream.Clear;
aStream.LoadFromStream(lStream); SoundDocStream.LoadFromStream(lStream);
finally finally
lStream.Free; lStream.Free;
end; end;
@ -291,14 +290,6 @@ begin
FPlayer := GSoundPlayers[AKind]; FPlayer := GSoundPlayers[AKind];
end; end;
function TSoundDocument.GetSoundDocStream: TStream;
begin
{aStream.Position := 0;
getmem(Result, aStream.Size);
aStream.Read(Result^, aStream.Size); }
Result := aStream;
end;
var var
lReaderIndex: TSoundFormat; lReaderIndex: TSoundFormat;
lPlayerIndex: TSoundPlayerKind; lPlayerIndex: TSoundPlayerKind;

View File

@ -28,7 +28,7 @@ type
codec_bs: longword; codec_bs: longword;
al_source: TALuint; al_source: TALuint;
al_format: integer; al_format: integer;
al_buffers: array[0..0] of TALuint; al_buffers: TALuint;
al_bufsize: longword; al_bufsize: longword;
al_readbuf: Pointer; al_readbuf: Pointer;
al_rate: longword; al_rate: longword;
@ -99,7 +99,7 @@ var
lReadCount: integer = 0; lReadCount: integer = 0;
lBufferBytePtr: PByte; lBufferBytePtr: PByte;
lBufferWordPtr: PWord; lBufferWordPtr: PWord;
loop: TALInt; loop: TALInt; aaa: TStringList;
begin begin
GetMem(al_readbuf, al_bufsize); GetMem(al_readbuf, al_bufsize);
Result := 0; Result := 0;
@ -129,7 +129,11 @@ begin
end; end;
//AlutLoadWavFile('T:\fpsound\testsounds\test.wav', al_format, al_readbuf, al_bufsize, al_rate, loop); //AlutLoadWavFile('T:\fpsound\testsounds\test.wav', al_format, al_readbuf, al_bufsize, al_rate, loop);
//alutLoadWAVMemory(ASound.GetSoundDocPtr, al_format, al_readbuf, al_bufsize, al_rate, loop); //alutLoadWAVMemory(ASound.GetSoundDocPtr, al_format, al_readbuf, al_bufsize, al_rate, loop);
LoadWavStream(ASound.GetSoundDocStream, al_format, al_readbuf, al_bufsize, al_rate, loop); LoadWavStream(ASound.SoundDocStream, al_format, al_readbuf, al_bufsize, al_rate, loop);
aaa := TStringList.Create;
aaa.Add(IntToStr(ASound.SoundDocStream.Size));
aaa.SaveToFile(IntToStr(ASound.SoundDocStream.Size) + '.txt');
end; end;
procedure TOpenALPlayer.Initialize; procedure TOpenALPlayer.Initialize;
@ -201,8 +205,8 @@ begin
// Fill the buffer // Fill the buffer
alFillBuffer(ASound, lKeyElement); alFillBuffer(ASound, lKeyElement);
alBufferData(al_buffers[0], al_format, al_readbuf, al_bufsize, al_rate); alBufferData(al_buffers, al_format, al_readbuf, al_bufsize, al_rate);
alSourceQueueBuffers(al_source, 1, @al_buffers[0]); alSourceQueueBuffers(al_source, 1, @al_buffers);
// Play the sound // Play the sound
alSourcePlay(al_source); alSourcePlay(al_source);