Hello guys,
I'm having problems on developing a Service Application.
My code is the following:
type
TReconhecimentoVoz = class(TService)
Timer: TTimer;
Gravador: TStockAudioRecorder;
procedure GravadorLevel(Sender: TObject; Level: Integer);
procedure ServiceExecute(Sender: TService);
procedure TimerTimer(Sender: TObject);
private
iCont : Integer;
stArquivo : TMemoryStream;
{ Private declarations }
public
function GetServiceController: TServiceController; override;
{ Public declarations }
end;
var
ReconhecimentoVoz: TReconhecimentoVoz;
implementation
{$R *.DFM}
procedure ServiceController(CtrlCode: DWord); stdcall;
begin
ReconhecimentoVoz.Controller(CtrlCode);
end;
function TReconhecimentoVoz.GetServiceController: TServiceController;
begin
Result := ServiceController;
end;
procedure TReconhecimentoVoz.GravadorLevel(Sender: TObject;
Level: Integer);
begin
if Level> 10 then
iCont := 0;
end;
procedure TReconhecimentoVoz.ServiceExecute(Sender: TService);
begin
stArquivo := TMemoryStream.Create;
Timer.Enabled := True;
Gravador.RecordToStream( stArquivo );
while not Terminated do begin
ServiceThread.ProcessRequests(False);
Sleep( 1000 );
end;
Timer.Enabled := False;
stArquivo.Free;
end;
procedure TReconhecimentoVoz.TimerTimer(Sender: TObject);
begin
if iCont = 5 then begin
iCont := 0;
end
else begin
iCont := iCont + 1;
end;
end;
Gravador is a component responsible for recording a Wave in a Memory Stream.
It gets the sound from a microphone.
If the microphone is in silence for too long (5 seconds), the recording
should stop. That's why I'm using a TTimer.
The level of the microphone sound is detected by the Eventhandler OnLevel of
the Gravador.
My Service enters the event TimerTimer a few times and shuts down
automatically apparently with no reason. I've checked the logs and it says
that it couldn't find the DLL or something like that.
What am I doing wrong ?
Can somebody help me ?
Diego
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi