1 /* Copyright 2018 The Chromium OS Authors. All rights reserved. 2 * Use of this source code is governed by a BSD-style license that can be 3 * found in the LICENSE file. 4 */ 5 6 #ifndef INPUT_DATA_H_ 7 #define INPUT_DATA_H_ 8 9 #include "cras_dsp_pipeline.h" 10 #include "float_buffer.h" 11 12 /* 13 * Structure holding the information used when a chunk of input buffer 14 * is accessed by multiple streams with different properties and 15 * processing requirements. 16 * Member: 17 * ext - Provides interface to read and process buffer in dsp pipeline. 18 * dev_ptr - Pointer to the associated input iodev. 19 * area - The audio area used for deinterleaved data copy. 20 * fbuffer - Floating point buffer from input device. 21 */ 22 struct input_data { 23 struct ext_dsp_module ext; 24 void *dev_ptr; 25 struct cras_audio_area *area; 26 struct float_buffer *fbuffer; 27 }; 28 29 /* 30 * Creates an input_data instance for input iodev. 31 * Args: 32 * dev_ptr - Pointer to the associated input device. 33 */ 34 struct input_data *input_data_create(void *dev_ptr); 35 36 /* Destroys an input_data instance. */ 37 void input_data_destroy(struct input_data **data); 38 39 /* Sets how many frames in buffer has been read by all input streams. */ 40 void input_data_set_all_streams_read(struct input_data *data, 41 unsigned int nframes); 42 43 /* 44 * Gets an audio area for |stream| to read data from. An input_data may be 45 * accessed by multiple streams while some requires processing, the 46 * |offsets| arguments helps track the offset value each stream has read 47 * into |data|. 48 * Args: 49 * data - The input data to get audio area from. 50 * stream - The stream that reads data. 51 * offsets - Structure holding the mapping from stream to the offset value 52 * of how many frames each stream has read into input buffer. 53 * area - To be filled with a pointer to an audio area struct for stream to 54 * read data. 55 * offset - To be filled with the samples offset in |area| that |stream| 56 * should start reading. 57 */ 58 int input_data_get_for_stream( 59 struct input_data *data, 60 struct cras_rstream *stream, 61 struct buffer_share *offsets, 62 struct cras_audio_area **area, 63 unsigned int *offset); 64 65 /* 66 * Marks |frames| of audio data as read by |stream|. 67 * Args: 68 * data - The input_data to mark frames has been read by |stream|. 69 * stream - The stream that has read audio data. 70 * offsets - Structure holding the mapping from stream to the offset value 71 * of how many frames each stream has read into input buffer. 72 * frames - Number of frames |stream| has read. 73 */ 74 int input_data_put_for_stream(struct input_data *data, 75 struct cras_rstream *stream, 76 struct buffer_share *offsets, 77 unsigned int frames); 78 79 #endif /* INPUT_DATA_H_ */ 80