Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 367
buffer: Create audio stream buffer#2283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
444c7e9
fir: Mark source buffer as const in processing functions
ktrzcinx 550b6c7
ASRC: Define processing function typedef
ktrzcinx 61deda6
ASRC: Mark source buffer as const in processing functions
ktrzcinx 79810ec
mux: Mark source buffer as const in processing functions
ktrzcinx 8fa2339
DAI: Simplify dai_dma_cb by adding temporary sink_bytes variables
ktrzcinx a2e7fa9
DAI: Use local variable holding frame format in dai playback and capt…
ktrzcinx 41ecf6d
detect_test: Mark source buffer as const in processing functions
ktrzcinx 2558945
kpb: Mark source buffer as const in processing functions
ktrzcinx a9a1a23
mixer: Mark source buffer as const in processing functions
ktrzcinx dddc773
selector: Define processing function typedef
ktrzcinx 3fa8eb6
selector: Mark input device pointer as const in processing functions
ktrzcinx 7f06d47
src: Mark input buffer input buffers with const in src_get_copy_limits
ktrzcinx c13584d
src: Mark input device pointer as const in processing functions
ktrzcinx bf023fd
volume: Define processing function typedef
ktrzcinx d8a0547
volume: Mark input device pointer as const in processing functions
ktrzcinx 08d0477
dma: Define processing function typedef
ktrzcinx 865b5a1
dma: Mark source buffer as const in processing functions
ktrzcinx 287de6b
buffer: Remove unused alloc_size
ktrzcinx b989e70
buffer: Introduce local variable to short function call arg list
ktrzcinx 0b45888
buffer: Create audio stream buffer
ktrzcinx 140a063
audio_stream: Create wrapping function
ktrzcinx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -45,6 +45,12 @@ | ||
| trace_error_comp(TRACE_CLASS_SRC, comp_ptr, \ | ||
| __e, ##__VA_ARGS__) | ||
| typedef void (*asrc_proc_func)(struct comp_dev *dev, | ||
| const struct audio_stream *source, | ||
| struct audio_stream *sink, | ||
| int *consumed, | ||
| int *produced); | ||
| /* asrc component private data */ | ||
| struct comp_data { | ||
| struct asrc_farrow *asrc_obj; /* ASRC core data */ | ||
| @@ -65,11 +71,7 @@ struct comp_data { | ||
| uint8_t *buf; /* Samples buffer for input and output */ | ||
| uint8_t *ibuf[PLATFORM_MAX_CHANNELS]; /* Input channels pointers */ | ||
| uint8_t *obuf[PLATFORM_MAX_CHANNELS]; /* Output channels pointers */ | ||
| void (*asrc_func)(struct comp_dev *dev, | ||
| struct comp_buffer *source, | ||
| struct comp_buffer *sink, | ||
| int *consumed, | ||
| int *produced); | ||
| asrc_proc_func asrc_func; /* ASRC processing function */ | ||
| }; | ||
ktrzcinx marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| /* In-line functions */ | ||
| @@ -88,7 +90,8 @@ static inline void src_inc_wrap_s16(int16_t **ptr, int16_t *end, size_t size) | ||
| /* A fast copy function for same in and out rate */ | ||
| static void src_copy_s32(struct comp_dev *dev, | ||
| struct comp_buffer *source, struct comp_buffer *sink, | ||
| const struct audio_stream *source, | ||
| struct audio_stream *sink, | ||
| int *n_read, int *n_written) | ||
| { | ||
| struct comp_data *cd = comp_get_drvdata(dev); | ||
| @@ -145,7 +148,8 @@ static void src_copy_s32(struct comp_dev *dev, | ||
| } | ||
| static void src_copy_s16(struct comp_dev *dev, | ||
| struct comp_buffer *source, struct comp_buffer *sink, | ||
| const struct audio_stream *source, | ||
| struct audio_stream *sink, | ||
| int *n_read, int *n_written) | ||
| { | ||
| struct comp_data *cd = comp_get_drvdata(dev); | ||
| @@ -385,17 +389,19 @@ static int asrc_prepare(struct comp_dev *dev) | ||
| struct comp_buffer, source_list); | ||
| /* get source data format and period bytes */ | ||
| cd->source_format = sourceb->frame_fmt; | ||
| source_period_bytes = buffer_period_bytes(sourceb, cd->source_frames); | ||
| cd->source_format = sourceb->stream.frame_fmt; | ||
| source_period_bytes = audio_stream_period_bytes(&sourceb->stream, | ||
| cd->source_frames); | ||
| /* get sink data format and period bytes */ | ||
| cd->sink_format = sinkb->frame_fmt; | ||
| sink_period_bytes = buffer_period_bytes(sinkb, cd->sink_frames); | ||
| if (sinkb->size < config->periods_sink * sink_period_bytes) { | ||
| trace_asrc_error_with_ids(dev, "asrc_prepare(), sink size=%d" | ||
| " is insufficient, when periods=%d" | ||
| ", period_bytes=%d", sinkb->size, | ||
| cd->sink_format = sinkb->stream.frame_fmt; | ||
| sink_period_bytes = audio_stream_period_bytes(&sinkb->stream, | ||
| cd->sink_frames); | ||
| if (sinkb->stream.size < config->periods_sink * sink_period_bytes) { | ||
| trace_asrc_error_with_ids(dev, | ||
| "asrc_prepare(), sink size=%d is insufficient, when periods=%d, period_bytes=%d", | ||
| sinkb->stream.size, | ||
| config->periods_sink, | ||
| sink_period_bytes); | ||
| ret = -ENOMEM; | ||
| @@ -415,7 +421,7 @@ static int asrc_prepare(struct comp_dev *dev) | ||
| } | ||
| /* ASRC supports S16_LE, S24_4LE and S32_LE formats */ | ||
| switch (sourceb->frame_fmt) { | ||
| switch (sourceb->stream.frame_fmt) { | ||
| case SOF_IPC_FRAME_S16_LE: | ||
| cd->asrc_func = src_copy_s16; | ||
| break; | ||
| @@ -435,7 +441,7 @@ static int asrc_prepare(struct comp_dev *dev) | ||
| /* | ||
| * Allocate input and output data buffer | ||
| */ | ||
| frame_bytes = buffer_frame_bytes(sourceb); | ||
| frame_bytes = audio_stream_frame_bytes(&sourceb->stream); | ||
| cd->buf_size = (cd->source_frames_max + cd->sink_frames_max) * | ||
| frame_bytes; | ||
| @@ -449,8 +455,8 @@ static int asrc_prepare(struct comp_dev *dev) | ||
| goto err; | ||
| } | ||
| sample_bytes = frame_bytes / sourceb->channels; | ||
| for (i = 0; i < sourceb->channels; i++) { | ||
| sample_bytes = frame_bytes / sourceb->stream.channels; | ||
| for (i = 0; i < sourceb->stream.channels; i++) { | ||
| cd->ibuf[i] = cd->buf + i * sample_bytes; | ||
| cd->obuf[i] = cd->ibuf[i] + cd->source_frames_max * frame_bytes; | ||
| } | ||
| @@ -459,7 +465,7 @@ static int asrc_prepare(struct comp_dev *dev) | ||
| * Get required size and allocate memory for ASRC | ||
| */ | ||
| sample_bits = sample_bytes * 8; | ||
| ret = asrc_get_required_size(&cd->asrc_size, sourceb->channels, | ||
| ret = asrc_get_required_size(&cd->asrc_size, sourceb->stream.channels, | ||
| sample_bits); | ||
| if (ret) { | ||
| trace_asrc_error_with_ids(dev, "asrc_prepare(), get_required_size_bytes failed"); | ||
| @@ -479,7 +485,7 @@ static int asrc_prepare(struct comp_dev *dev) | ||
| /* | ||
| * Initialize ASRC | ||
| */ | ||
| ret = asrc_initialise(cd->asrc_obj, sourceb->channels, | ||
| ret = asrc_initialise(cd->asrc_obj, sourceb->stream.channels, | ||
| cd->source_rate, cd->sink_rate, | ||
| ASRC_IOF_INTERLEAVED, ASRC_IOF_INTERLEAVED, | ||
| ASRC_BM_LINEAR, cd->frames, sample_bits, | ||
| @@ -529,8 +535,10 @@ static int asrc_copy(struct comp_dev *dev) | ||
| sink = list_first_item(&dev->bsink_list, struct comp_buffer, | ||
| source_list); | ||
| frames_src = source->avail / buffer_frame_bytes(source); | ||
| frames_snk = sink->free / buffer_frame_bytes(sink); | ||
| frames_src = source->stream.avail / | ||
| audio_stream_frame_bytes(&source->stream); | ||
| frames_snk = sink->stream.free / | ||
| audio_stream_frame_bytes(&sink->stream); | ||
| cd->source_frames = MIN(frames_src, cd->source_frames_max); | ||
| cd->sink_frames = ceil_divide(cd->source_frames * cd->sink_rate, | ||
| @@ -549,7 +557,8 @@ static int asrc_copy(struct comp_dev *dev) | ||
| } | ||
| if (cd->source_frames && cd->sink_frames) | ||
| cd->asrc_func(dev, source, sink, &consumed, &produced); | ||
| cd->asrc_func(dev, &source->stream, &sink->stream, &consumed, | ||
| &produced); | ||
| tracev_asrc_with_ids(dev, "asrc_copy(), consumed = %u, produced = %u", | ||
| consumed, produced); | ||
| @@ -559,11 +568,11 @@ static int asrc_copy(struct comp_dev *dev) | ||
| */ | ||
| if (consumed > 0) | ||
| comp_update_buffer_consume(source, consumed * | ||
| buffer_frame_bytes(source)); | ||
| audio_stream_frame_bytes(&source->stream)); | ||
| if (produced > 0) | ||
| comp_update_buffer_produce(sink, produced * | ||
| buffer_frame_bytes(sink)); | ||
| audio_stream_frame_bytes(&sink->stream)); | ||
| return 0; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.