Repository navigation
Expand file tree
/
Copy pathsink_source_utils.h
More file actions
61 lines (53 loc) · 1.69 KB
/
Copy pathsink_source_utils.h
File metadata and controls
61 lines (53 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2023 Intel Corporation. All rights reserved.
*
*/
#ifndef SINK_SOURCE_UTILS_H
#define SINK_SOURCE_UTILS_H
#include <sof/audio/sink_api.h>
#include <sof/audio/source_api.h>
#include <sof/math/numbers.h>
/**
* copy bytes from source to sink
*
* @param source the data source
* @param sink the data target
* @param free if true, data from source will be freed
* if false, data will remain in the source
* @param size number of bytes to be copied
*/
int source_to_sink_copy(struct sof_source *source,
struct sof_sink *sink, bool free, size_t size);
/**
* fill sink with silence (zeros)
*
* @param sink the target to be filled with silence
* @param size number of bytes to be filled
*/
int sink_fill_with_silence(struct sof_sink *sink, size_t size);
/**
* drop data from source
*
* @param source the source of data to be dropped
* @param size number of bytes to be dropped
*/
int source_drop_data(struct sof_source *source, size_t size);
/**
* Computes maximum number of frames aligned with the source align criteria
* that can be copied from source to sink, verifying the number of available
* source frames vs. free space available in sink.
*
* @param source the data source
* @param sink the data sink
* @return Number of aligned frames available for processing.
*/
static inline size_t source_sink_avail_frames_aligned(struct sof_source *source,
struct sof_sink *sink)
{
size_t src_frames = source_get_data_frames_available(source);
size_t sink_frames = sink_get_free_frames(sink);
size_t n = MIN(src_frames, sink_frames);
return source_align_frames_round_down(source, n);
}
#endif /* SINK_SOURCE_UTILS_H */