forked from thesofproject/sof
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsource_api.c
More file actions
58 lines (43 loc) · 1.46 KB
/
source_api.c
File metadata and controls
58 lines (43 loc) · 1.46 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
// SPDX-License-Identifier: BSD-3-Clause
/*
* Copyright(c) 2023 Intel Corporation. All rights reserved.
*/
#include <sof/audio/source_api.h>
#include <sof/audio/audio_stream.h>
/* This file contains public source API functions that were too large to mark is as inline. */
int source_get_data(struct sof_source *source, size_t req_size,
void const **data_ptr, void const **buffer_start, size_t *buffer_size)
{
int ret;
if (source->requested_read_frag_size)
return -EBUSY;
ret = source->ops->get_data(source, req_size, data_ptr, buffer_start, buffer_size);
if (!ret)
source->requested_read_frag_size = req_size;
return ret;
}
int source_release_data(struct sof_source *source, size_t free_size)
{
int ret;
/* Check if anything was obtained before for reading by source_get_data */
if (!source->requested_read_frag_size)
return -ENODATA;
/* limit size of data to be freed to previously obtained size */
if (free_size > source->requested_read_frag_size)
free_size = source->requested_read_frag_size;
ret = source->ops->release_data(source, free_size);
if (!ret)
source->requested_read_frag_size = 0;
source->num_of_bytes_processed += free_size;
return ret;
}
size_t source_get_frame_bytes(struct sof_source *source)
{
return get_frame_bytes(source_get_frm_fmt(source),
source_get_channels(source));
}
size_t source_get_data_frames_available(struct sof_source *source)
{
return source_get_data_available(source) /
source_get_frame_bytes(source);
}