Connections

You form connections between components' ports by connecting their port surrogates. Surrogates are used in place of actual ports to prevent clients and media components from simultaneously writing data to the same port; the actual ports transfer data over the connection. To connect two components, you:

  1. Create port surrogates for the input and output ports that you want to connect.
  2. Call ConnectTo on the output port surrogate with the surrogate for the input port you're forming a connection with.
For example, the following code connects a microphone to an audio player for recording:

      // Create surrogates
      TAudioOutputPortSurrogate* micOut;
      TAudioInputPortSurrogate* playerIn;
      micOut = microphone->CreateOutput();
      recIn = audioPlayer->CreateLeftInput();
      
      // Connect ports using surrogates
      microOut->ConnectTo( recIn );
Surrogates are lightweight and can easily be passed across address spaces--with surrogates, you can connect media components that reside in different tasks.

For example, to make a connection between an output port in one task and an input port in another task, surrogates are constructed for both ports.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker