mmdspobj.pas

来自「P2P即时通讯源码(DELPHI编写)」· PAS 代码 · 共 1,105 行 · 第 1/3 页

PAS
1,105
字号
begin
   inherited Paused;

   if assigned(FOnPause) then FOnPause(Self);
end;

{-- TMMDSPInterface -----------------------------------------------------------}
procedure TMMDSPInterface.Restarted;
begin
   inherited Restarted;

   if assigned(FOnRestart) then FOnRestart(Self);
end;

{-- TMMDSPInterface -----------------------------------------------------------}
procedure TMMDSPInterface.Stopped;
begin
   if FStarted then
   begin
      inherited Stopped;

      if assigned(FOnStop) then FOnStop(Self);
   end;
end;

{== TMMCustomSoundComponent ===================================================}
constructor TMMCustomSoundComponent.Create(AOwner: TComponent);
begin
   inherited Create(AOwner);

   FFullDuplex := False;
end;

{-- TMMCustomSoundComponent ---------------------------------------------------}
destructor TMMCustomSoundComponent.Destroy;
begin
   inherited Destroy;
end;

{-- TMMCustomSoundComponent ---------------------------------------------------}
procedure TMMCustomSoundComponent.Opened;
var
   Current: TMMDSPComponent;

begin
   FFullDuplex := False;
   { search the first valid component }
   Current := Self;
   while (Current.Input <> nil) do
   begin
      Current := Current.Input;

      { if we have a preloader it is the first component for us }
      if Current.FPreloaded then break;

      if (Current is TMMCustomSoundComponent) and (Current <> Self) then
      begin
         { there is another sound component on the left side }
         FFullDuplex := True;
         Current := Self;
         break;
      end;
   end;

   { no go trough all components and notify }
   repeat
      if not (Current is TMMCustomSoundComponent) then
      begin
         Current.BufferSize := BufferSize;
         Current.Opened;
      end
      else if (Current <> Self) then
      begin       { there is another sound component on the right side }
         Current.BufferSize := BufferSize;
         Current.Opened;
         break;
      end;
      Current := Current.Output;
   until (Current = nil);

   inherited Opened;
end;

{-- TMMCustomSoundComponent ---------------------------------------------------}
procedure TMMCustomSoundComponent.Closed;
var
   Current: TMMDSPComponent;

begin
   { search the last component }
   Current := Self;
   while (Current.Output <> nil) do
   begin
      Current := Current.Output;
      if (Current is TMMCustomSoundComponent) and (Current <> Self) then
      begin
         { there is another sound component on the right side }
         Current.Closed;
         break;
      end;
   end;

   { search the first component }
   Current := Self;
   while (Current.Input <> nil) do
   begin
      Current := Current.Input;
      if (Current is TMMCustomSoundComponent) and (Current <> Self) then
      begin
         { there is another sound component on the left side }
         Current := Self;
         break;
      end;
   end;

   { no go trough all components and notify }
   repeat
      if not (Current is TMMCustomSoundComponent) then
      begin
         Current.Closed;
      end
      else if (Current <> Self) then
      begin
         { there is another sound component on the right side }
         break;
      end;
      Current := Current.Output;
   until (Current = nil);

   inherited Closed;
end;

{-- TMMCustomSoundComponent ---------------------------------------------------}
procedure TMMCustomSoundComponent.Started;
var
   Current: TMMDSPComponent;

begin
   { search the first component }
   Current := Self;
   while (Current.Input <> nil) do
   begin
      Current := Current.Input;

      { if we have a preloader it is the first component for us }
      if Current.FPreloaded then break;

      if (Current is TMMCustomSoundComponent) and (Current <> Self) then
      begin
         { there is another sound component on the left side }
         Current := Self;
         break;
      end;
   end;

   { no go trough all components and notify }
   repeat
      if not (Current is TMMCustomSoundComponent) then
      begin
         Current.Started;
      end
      else if (Current <> Self) then
      begin
         Current.Started;
         break;   { there is another sound component on the right side }
      end;
      Current := Current.Output;
   until (Current = nil);

   inherited Started;
end;

{-- TMMCustomSoundComponent ---------------------------------------------------}
procedure TMMCustomSoundComponent.Paused;
var
   Current: TMMDSPComponent;

begin
   { search the first component }
   Current := Self;
   while (Current.Input <> nil) do
   begin
      Current := Current.Input;
      if (Current is TMMCustomSoundComponent) and (Current <> Self) then
      begin
         { there is another sound component on the left side }
         Current := Self;
         break;
      end;
   end;

   { no go trough all components and notify }
   repeat
      if not (Current is TMMCustomSoundComponent) then
      begin
         Current.Paused;
      end
      else if (Current <> Self) then
      begin
         Current.Paused;
         break;   { there is another sound component on the right side }
      end;
      Current := Current.Output;
   until (Current = nil);

   inherited Paused;
end;

{-- TMMCustomSoundComponent ---------------------------------------------------}
procedure TMMCustomSoundComponent.Restarted;
var
   Current: TMMDSPComponent;

begin
   { search the first component }
   Current := Self;
   while (Current.Input <> nil) do
   begin
      Current := Current.Input;
      if (Current is TMMCustomSoundComponent) and (Current <> Self) then
      begin
         { there is another sound component on the left side }
         Current := Self;
         break;
      end;
   end;

   { no go trough all components and notify }
   repeat
      if not (Current is TMMCustomSoundComponent) then
      begin
         Current.Restarted;
      end
      else if (Current <> Self) then
      begin
         Current.Restarted;
         break;   { there is another sound component on the right side }
      end;
      Current := Current.Output;
   until (Current = nil);

   inherited Restarted;
end;

{-- TMMCustomSoundComponent ---------------------------------------------------}
procedure TMMCustomSoundComponent.Stopped;
var
   Current: TMMDSPComponent;

begin
   { search the last component }
   Current := Self;
   while (Current.Output <> nil) do
   begin
      Current := Current.Output;
      if (Current is TMMCustomSoundComponent) and (Current <> Self) then
      begin
         { there is another sound component on the right side }
         Current.Stopped;
         break;
      end;
   end;

   { search the first component }
   Current := Self;
   while (Current.Input <> nil) do
   begin
      Current := Current.Input;
      if (Current is TMMCustomSoundComponent) and (Current <> Self) then
      begin
         { there is another sound component on the left side }
         Current := Self;
         break;
      end;
   end;

   { no go trough all components and notify }
   repeat
      if not (Current is TMMCustomSoundComponent) then
      begin
         Current.Stopped;
      end
      else if (Current <> Self) then
      begin
         { there is another sound component on the right side }
         break;
      end;
      Current := Current.Output;
   until (Current = nil);

   inherited Stopped;
end;

{-- TMMCustomSoundComponent ---------------------------------------------------}
procedure TMMCustomSoundComponent.Reseting;
var
   Current: TMMDSPComponent;

begin
   { search the first component }
   Current := Self;
   while (Current.Input <> nil) do
   begin
      Current := Current.Input;
      if (Current is TMMCustomSoundComponent) and (Current <> Self) then
      begin
         { there is another sound component on the left side }
         Current := Self;
         break;
      end;
   end;

   { no go trough all components and notify }
   repeat
      if not (Current is TMMCustomSoundComponent) then
      begin
         Current.Reseting;
      end
      else if (Current <> Self) then
      begin
         Current.Reseting;
         break;   { there is another sound component on the right side }
      end;
      Current := Current.Output;
   until (Current = nil);

   inherited Reseting;
end;

{-- TMMCustomSoundComponent ---------------------------------------------------}
procedure TMMCustomSoundComponent.Looped;
var
   Current: TMMDSPComponent;

begin
   { search the first component }
   Current := Self;
   while (Current.Input <> nil) do
   begin
      Current := Current.Input;
      if (Current is TMMCustomSoundComponent) and (Current <> Self) then
      begin
         { there is another sound component on the left side }
         Current := Self;
         break;
      end;
   end;

   { no go trough all components and notify }
   repeat
      if not (Current is TMMCustomSoundComponent) then
      begin
         Current.Looped;
      end
      else if (Current <> Self) then
      begin
         Current.Looped;
         break;   { there is another sound component on the right side }
      end;
      Current := Current.Output;
   until (Current = nil);

   inherited Looped;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?