Skip to content
Back to top

# Pipeline

Generated pipeline interface. Use the source and sink functions defined here to send samples to the generated DSP and receive processed samples back.

Functions

static inline void adsp_pipeline_source(adsp_pipeline_t *adsp, int32_t **data)

  Pass samples into the DSP pipeline.

  These samples are sent by value to the other thread, therefore the data buffer can be reused immediately after this function returns. This function copies the data to a shared buffer where the DSP pipeline will read them. If called again before the DSP pipeline has emptied the buffer then this will block. If called when the buffer is empty then it will not block.

  If this is called on the same thread as `adsp_pipeline_sink` then it will be most efficient to call sink first followed by source. This allows the channel transactions internal to the pipeline to be completed while the app is copying the input data to the buffer.

  Parameters:

    - adsp – The initialised pipeline.

    - data – An array of arrays of samples. The length of the array shall be the number of pipeline input channels. Each array contained within shall be contain a frame of samples large enough to pass to the stage that it is connected to.

static inline void adsp_pipeline_sink(adsp_pipeline_t *adsp, int32_t **data)

  Receive samples from the DSP pipeline.

  Sink is implemented via a blocking channel transaction with the DSP thread and therefore will block until the output threads are available to send the processed data. It should also be noted that if `adsp_pipeline_sink` is called late then the DSP pipeline will block waiting for the application to read the processed data. The application author must take care to ensure that data is being read in a timely fashion.

  Parameters:

    - adsp – The initialised pipeline.

    - data – An array of arrays that will be filled with processed samples from the pipeline. The length of the array shall be the number of pipeline input channels. Each array contained within shall be contain a frame of samples large enough to pass to the stage that it is connected to.

static inline bool adsp_pipeline_sink_nowait(

  adsp_pipeline_t *adsp,
  int32_t **data,

)

  Non-blocking receive from the pipeline. It is risky to use this API in an isochronous application as the sink thread can lose synchronisation with the source thread which can cause the source thread to block.

  Parameters:

    - adsp – The initialised pipeline.

    - data – See adsp_pipeline_sink for details of same named param.

  Return values:

    - true – The data buffer has been filled with new values from the pipeline.

    - false – The pipeline has not produced any more data. The data buffer was untouched.

struct adsp_pipeline_t
  #include <adsp_pipeline.h>

  The DSP pipeline.

  The generated pipeline will contain an init function that returns a pointer to one of these. It can be used to send data in and out of the pipeline, and also execute control commands.

  Public Members

  module_instance_t *modules

    Array of DSP stage states, must be used when calling one of the control functions.

  size_t n_modules

    Number of modules in the adsp_pipeline_t::modules array.

  Private Members

  adsp_fifo_t *p_in
  size_t n_in
  channel_t *p_out
  size_t n_out
  channel_t *p_link
  size_t n_link
  adsp_mux_t input_mux
  adsp_mux_t output_mux