⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmsplitt.pas

📁 一套及时通讯的原码
💻 PAS
📖 第 1 页 / 共 2 页
字号:
{-- TMMOutputSplitter ---------------------------------------------------------}
procedure TMMOutputSplitter.Opened;
var
   i: integer;
   Current: TMMDSPComponent;
begin
   if not IsOpen then
   begin
      FTempBuffer := GlobalAllocMem(Max(QUEUE_WRITE_SIZE,BufferSize));

      for i := 0 to MAXPORTS-1 do
      begin
         if (FPorts[i] <> nil) then
         begin
            Current := FPorts[i];
            { 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);
         end;
      end;

      inherited Opened;
   end;
end;

{-- TMMOutputSplitter ---------------------------------------------------------}
procedure TMMOutputSplitter.Closed;
var
   i: integer;
   Current: TMMDSPComponent;
begin
   if IsOpen then
   begin
      for i := 0 to MAXPORTS-1 do
      begin
         if (FPorts[i] <> nil) then
         begin
            Current := FPorts[i];

            { search the last component }
            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;

            Current := FPorts[i];

            { 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);
         end;
      end;

      GlobalFreeMem(Pointer(FTempBuffer));

      inherited Closed;
   end;
end;

{-- TMMOutputSplitter ---------------------------------------------------------}
procedure TMMOutputSplitter.Started;
var
   i: integer;
   Current: TMMDSPComponent;
begin
   if IsOpen and not IsStarted then
   begin
      for i := 0 to MAXPORTS-1 do
      begin
         if (FPorts[i] <> nil) then
         begin
            Current := FPorts[i];
            { 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);
         end;
      end;

      inherited Started;
   end;
end;

{-- TMMOutputSplitter ---------------------------------------------------------}
procedure TMMOutputSplitter.Stopped;
var
   i: integer;
   Current: TMMDSPComponent;
begin
   if IsStarted then
   begin
      for i := 0 to MAXPORTS-1 do
      begin
         if (FPorts[i] <> nil) then
         begin
            Current := FPorts[i];

            { search the last component }
            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;

            Current := FPorts[i];

            { now 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);
         end;
      end;

      inherited Stopped;
   end;
end;

{-- TMMOutputSplitter ---------------------------------------------------------}
procedure TMMOutputSplitter.Paused;
var
   i: integer;
   Current: TMMDSPComponent;
begin
   if IsOpen and not IsPaused then
   begin
      for i := 0 to MAXPORTS-1 do
      begin
         if (FPorts[i] <> nil) then
         begin
           Current := FPorts[i];
           { 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);
         end;
      end;

      inherited Paused;
   end;
end;

{-- TMMOutputSplitter ---------------------------------------------------------}
procedure TMMOutputSplitter.Restarted;
var
   i: integer;
   Current: TMMDSPComponent;
begin
   if IsPaused then
   begin
      for i := 0 to MAXPORTS-1 do
      begin
         if (FPorts[i] <> nil) then
         begin
            Current := FPorts[i];

            { 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);
         end;
      end;

      inherited Paused;
   end;
end;

{-- TMMOutputSplitter ---------------------------------------------------------}
procedure TMMOutputSplitter.Reseting;
var
   i: integer;
   Current: TMMDSPComponent;
begin
   for i := 0 to MAXPORTS-1 do
   begin
      if (FPorts[i] <> nil) then
      begin
         Current := FPorts[i];
         { 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);
      end;
   end;

   inherited Reseting;
end;

{-- TMMOutputSplitter ---------------------------------------------------------}
procedure TMMOutputSplitter.Looped;
var
   i: integer;
   Current: TMMDSPComponent;
begin
   for i := 0 to MAXPORTS-1 do
   begin
      if (FPorts[i] <> nil) then
      begin
         Current := FPorts[i];
         { 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);
      end;
   end;

   inherited Looped;
end;

{-- TMMOutputSplitter ---------------------------------------------------------}
procedure TMMOutputSplitter.BufferReady(lpwh: PWaveHdr);
var
   i: integer;
   Current: TMMDSPComponent;
   lpdata: PChar;
begin
   inherited BufferReady(lpwh);

   lpData := lpwh.lpData;
   lpwh.lpData := FTempBuffer;

   for i := 0 to MAXPORTS-1 do
   begin
      if (FPorts[i] <> nil) then
      begin
         // we need to make a copy of the data because some filters might change the buffer data
         GlobalMoveMem(lpData^,lpwh.lpData^,lpwh.dwBytesRecorded);
         FPorts[i].BufferReady(lpwh);
      end;
   end;

   lpwh.lpData := lpData;
end;

{-- TMMOutputSplitter ---------------------------------------------------------}
procedure TMMOutputSplitter.BufferLoad(lpwh: PWaveHdr; var MoreBuffers: Boolean);
begin
   raise EMMSplitterError.Create('You can not load data from a splitter !');
end;

end.

⌨️ 快捷键说明

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