Pipeline Module
- class sudio.pipeline.Pipeline(max_size=0, io_buffer_size=10, on_busy=PipelineOnBusyType.BLOCK, list_dispatch=False)
Bases:
Thread
Pipeline class for audio processing.
- Raises:
ValueError – If an unsupported value is provided for ‘on_busy’.
BufferError – If the pipeline is empty during a delay operation.
ConnectionError – If the pipeline is not started during a delay operation.
Initializes the Pipeline instance with the specified parameters.
- Parameters:
max_size (int) – Maximum size of the pipeline.
io_buffer_size (int) – Size of the I/O buffer.
on_busy (Union[float, PipelineOnBusyType]) – Action to take when the pipeline is busy. DROP or BLOCK, float for timeout
list_dispatch (bool) – Flag indicating whether to use list dispatch mode.
- clear()
Clears the input and output queues of the pipeline.
- Parameters:
None
- Returns:
None
- run()
The main execution loop of the pipeline. Handles dispatching to either _run_dispatched or _run_norm based on the pipeline mode (list dispatch or normal).
- Parameters:
None
- Returns:
None
- refresh()
Refreshes the pipeline, handling initialization, appending, inserting, and other operations.
- Parameters:
None
- Returns:
None
- insert(index, *func, args=(), init=())
Inserts functions into the pipeline at the specified index.
- Parameters:
index (int) – The index at which to insert the functions.
*func (callable) – The functions to insert.
args (Union[list, tuple, object]) – Arguments to be passed to the functions.
init (Union[list, tuple, callable]) – Initialization functions or arguments.
- Returns:
The modified pipeline instance.
- Return type:
- append(*func, args=(), init=())
Appends functions to the end of the pipeline.
- Parameters:
*func (callable) – The functions to append.
args (Union[list, tuple, object]) – Arguments to be passed to the functions.
init (Union[list, tuple, callable]) – Initialization functions or arguments.
- Returns:
The modified pipeline instance.
- Return type:
- sync(barrier)
Sets a synchronization barrier for the pipeline.
- Parameters:
barrier (threading.Barrier) – The synchronization barrier.
- Returns:
None
- aasync()
Disables synchronization for the pipeline.
- Parameters:
None
- Returns:
None
- delay()
Delays the pipeline and returns the execution time.
- Parameters:
None
- Returns:
The execution time in seconds.
- Return type:
float
- set_timeout(t)
Sets the timeout value for blocking operations.
- Parameters:
t (Union[float, int]) – The timeout value in seconds.
- Returns:
None
- get_timeout()
Retrieves the current timeout value.
- Parameters:
None
- Returns:
The current timeout value in seconds.
- Return type:
Union[float, int]
- index(func)
Returns the index of the first occurrence of the specified function in the pipeline.
- Parameters:
func (callable) – The function to search for in the pipeline.
- Returns:
The index of the function if found, -1 otherwise.
- Return type:
int
- Raises:
ValueError – If the function is not found in the pipeline.
- update_args(func_or_index, *new_args)
Updates the arguments of a function in the pipeline.
- Parameters:
func_or_index (Union[callable, int]) – The function or its index in the pipeline.
*new_args – The new arguments to be used for the function.
- Returns:
None
- Raises:
ValueError – If the function is not found in the pipeline.
IndexError – If the provided index is out of range.