Class BufferModule

java.lang.Object
com.vivoka.vsdk.audio.ProducerModule
com.vivoka.vsdk.audio.BufferModule
All Implemented Interfaces:
IConsumerModule

public class BufferModule extends ProducerModule implements IConsumerModule
The BufferModule acts as both a consumer and a producer, enabling the forwarding of buffers from a source pipeline to a target pipeline. The BufferModule supports both synchronous (Pipeline.run()) and asynchronous (Pipeline.start()) pipeline execution modes, as well as the ability to pause and resume. When the target pipeline is stopped or paused, incoming buffers from the source pipeline are temporarily stored. These stored buffers are dispatched when the target pipeline is started or resumed. - Asynchronous mode: Buffer dispatching occurs in a dedicated thread. - Synchronous mode: Pending buffers are dispatched in the same thread that invokes targetPipeline.run().
  • Constructor Details

    • BufferModule

      public BufferModule()
  • Method Details

    • clearPendingData

      public void clearPendingData()
      Clears all pending data in the queue.
    • startImpl

      public void startImpl() throws Exception
      Description copied from class: ProducerModule
      Starts the producer module in a non-blocking manner. The producer state must be OPENED. When calling start pipeline, this method will be called after the open method. startImpl() should initiate the producer and return immediately without waiting for processing to complete and update the state to STARTED when it is done.
      Overrides:
      startImpl in class ProducerModule
      Throws:
      Exception - If an error occurs during starting.
    • stopImpl

      public void stopImpl()
      Description copied from class: ProducerModule
      Stops the producer module. The producer state must be STARTED. When calling stop pipeline, this method will be called. It should initiate the stopping process and return immediately without waiting for it to complete. It should make sure that the state is updated to OPENED when it is done.
      Overrides:
      stopImpl in class ProducerModule
    • pauseImpl

      public void pauseImpl()
      Description copied from class: ProducerModule
      Pauses the producer module. The producer state must be STARTED. When calling pause pipeline, this method will be called. It should initiate the pausing process and return immediately without waiting for it to complete. It should make sure that the state is updated to PAUSED when it is done.
      Overrides:
      pauseImpl in class ProducerModule
    • resumeImpl

      public void resumeImpl()
      Description copied from class: ProducerModule
      Resumes the producer module. The producer state must be PAUSED. When the producer is resumed, the child class needs to update the state to STARTED. When calling resume pipeline, this method will be called. It should initiate the resuming process and return immediately without waiting for it to complete. It should make sure that the state is updated to OPENED when it is done.
      Overrides:
      resumeImpl in class ProducerModule
    • runImpl

      public void runImpl() throws Exception
      Description copied from class: ProducerModule
      Runs the producer module in a blocking manner. The producer state must be OPENED. When calling run pipeline, this method will be called after the open method. The state remains RUNNING until the end and then becomes OPENED.
      Overrides:
      runImpl in class ProducerModule
      Throws:
      Exception - If the producer is not opened or an error occurs during running.
    • process

      public void process(Buffer buffer, boolean last) throws Exception
      Description copied from interface: IConsumerModule
      Processes the given audio buffer.
      Specified by:
      process in interface IConsumerModule
      Parameters:
      buffer - The audio buffer to process.
      last - Indicates if this is the last buffer in the stream.
      Throws:
      Exception - If an error occurs during processing.