Package com.vivoka.vsdk.audio.producers
Class BufferStreamer
java.lang.Object
com.vivoka.vsdk.audio.ProducerModule
com.vivoka.vsdk.audio.producers.BufferStreamer
BufferStreamer is a producer module that allows the user to dispatch audio buffers
to a pipeline consumers. It operates in a threaded mode, processing buffers asynchronously.
The module can handle acceleration rates, allowing for faster processing of audio data.
It is designed to work with a specified buffer size.
The BufferStreamer can be used only in an asynchronous pipeline (pipeline.start())
and it supports pausing and resuming operations.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vivoka.vsdk.audio.ProducerModule
ProducerModule.State -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a BufferStreamer with the default acceleration rate of 1.0.BufferStreamer(double accelerationRate) Constructs a BufferStreamer with the specified acceleration rate. -
Method Summary
Modifier and TypeMethodDescriptiondoubleGets the current acceleration rate of the BufferStreamer.voidPauses the producer module.voidResumes the producer module.voidsetAccelerationRate(double rate) Sets the acceleration rate for the BufferStreamer.voidStarts the producer module in a non-blocking manner.voidstopImpl()Stops the producer module.voidStreams the audio buffer to the pipeline consumers.Methods inherited from class com.vivoka.vsdk.audio.ProducerModule
closeImpl, dispatchAudio, dispatchBuffer, getLastError, getState, isBusy, isClosed, isIdle, isOpened, isPaused, isRunning, isStarted, openImpl, runImpl, setLastError, setState, setStateChanedCallback, subscribeFirst, subscribeLast, unsubscribe
-
Constructor Details
-
BufferStreamer
public BufferStreamer()Constructs a BufferStreamer with the default acceleration rate of 1.0. This means that the audio processing will not be accelerated. -
BufferStreamer
Constructs a BufferStreamer with the specified acceleration rate. The acceleration rate must be greater than or equal to 1.0.- Parameters:
accelerationRate- The rate at which the audio processing is accelerated.- Throws:
Exception- If the acceleration rate is less than 1.0.
-
-
Method Details
-
setAccelerationRate
Sets the acceleration rate for the BufferStreamer. The acceleration rate must be greater than or equal to 1.0.- Parameters:
rate- The acceleration rate to set.- Throws:
Exception- If the acceleration rate is less than 1.0.
-
getAccelerationRate
public double getAccelerationRate()Gets the current acceleration rate of the BufferStreamer. This rate determines how fast the audio processing is accelerated.- Returns:
- The current acceleration rate.
-
stream
Streams the audio buffer to the pipeline consumers.- Parameters:
buffer- The audio buffer to be streamed.last- Indicates whether this is the last buffer to be streamed.bufferSize- The size of the buffer to be processed.- Throws:
Exception- Occurs if the buffer is null, or if the channel count or sample rate of the buffer does not match the values of the first buffer received after start.
-
startImpl
Description copied from class:ProducerModuleStarts the producer module in a non-blocking manner. The producer state must beOPENED. When calling start pipeline, this method will be called after theopenmethod. 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:
startImplin classProducerModule- Throws:
Exception- If an error occurs during starting.
-
stopImpl
Description copied from class:ProducerModuleStops the producer module. The producer state must beSTARTED. 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:
stopImplin classProducerModule- Throws:
Exception- If an error occurs during stopping.
-
pauseImpl
Description copied from class:ProducerModulePauses the producer module. The producer state must beSTARTED. 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:
pauseImplin classProducerModule- Throws:
Exception- If an error occurs during pausing.
-
resumeImpl
Description copied from class:ProducerModuleResumes the producer module. The producer state must bePAUSED. 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:
resumeImplin classProducerModule- Throws:
Exception- If an error occurs during resuming.
-