Hello, I'm doing an audio input analysis service. I run it in a graphical application, Loop Proc is triggered. I try to run the same thing in the console, Loop Proc does not work. Please tell me what am I doing wrong?
(Lazarus 2.0.2 Linux Debian)
Text function
//My LoopProc
procedure TApp.InLoopMemRs;
var
aBufLen: Integer;
FBufRcFromUos: TDArFloat; // My buffer
begin
FBufRcFromUos:=uos_InputGetBuffer(FPlayerRs, FInputIndexRs);
aBufLen:=Length(FBufRcFromUos);
{My Work}
end;
procedure TApp.StartPlay;
var
aAllBad: Boolean = False;
begin
//
FPlayerRs:=0;
//
if uos_CreatePlayer(FPlayerRs) then
begin
FInputIndexRs := uos_AddFromDevIn(FPlayerRs, DefaultDeviceIn, -1, cSampleRate,
cChannels, cSampleFormat, cFramesCount, cChunkCount);
if FInputIndexRs<>-1 then
uos_LoopProcIn(FPlayerRs, FInputIndexRs, @InLoopMemRs);
end else
aAllBad:=True;
aAllBad:=aAllBad or (FInputIndexRs=-1);
if aAllBad then
begin
Exit;
end;
{Create My Class for Math}
//Start Play
uos_Play(FPlayerRs);
end;
procedure TApp.StopPlay;
begin
uos_Stop(FPlayerRs);
sleep(300);
end;
Re: The LoopProc does not work in the console program
Administrator
This post was updated on .
Hello.
Could you try adding some sleep() time after uos_play()?
//Start Play
uos_Play(FPlayerRs);
sleep(3000); // add this with the estimated time of the process
Is the loop done with this?
If yes, I fear that you will need to use a sleep(x) for console app + loopproc.
And for the duration of the sleep(x) it should be the minimum duration of all the process.
It could be done with something like this:
// var process_terminated : boolean = false;
// create a uos_EndProc() ----> process_terminated := true;
//Start Play
uos_Play(FPlayerRs);
while process_terminated = false do
sleep(300); // add this
- --------------
Re: The LoopProc does not work in the console program
Administrator
Hello.
Nice that you found a solution.
May I ask you what kind of loop do you have in the main console program?
Usually checksynchronize() is used in graphic application where a main loop is used.
Did you use a main loop also in your console program?