Use cached offset
All checks were successful
eden-license / license-header (pull_request) Successful in 21s
All checks were successful
eden-license / license-header (pull_request) Successful in 21s
This commit is contained in:
parent
e9ff13fe34
commit
8b48f5cf29
1 changed files with 13 additions and 7 deletions
|
@ -36,14 +36,20 @@ void DeviceSinkCommand::Process(const AudioRenderer::CommandListProcessor& proce
|
|||
.consumed{false},
|
||||
};
|
||||
|
||||
std::array<s16, TargetSampleCount * MaxChannels> samples{};
|
||||
for (u32 channel = 0; channel < input_count; channel++) {
|
||||
//const auto offset{inputs[channel] * out_buffer.frames};
|
||||
const auto offset{channel * out_buffer.frames};
|
||||
static bool initialized = false;
|
||||
static std::array<s32, MaxChannels> cached_offsets{};
|
||||
if (!initialized) {
|
||||
for (u32 channel = 0; channel < input_count; channel++) {
|
||||
cached_offsets[channel] = static_cast<s16>(inputs[channel] * out_buffer.frames);
|
||||
}
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
for (u32 index = 0; index < out_buffer.frames; index++) {
|
||||
samples[index * input_count + channel] =
|
||||
static_cast<s16>(std::clamp(sample_buffer[offset + index], min, max));
|
||||
std::array<s16, TargetSampleCount * MaxChannels> samples{};
|
||||
for (u32 channel = 0; channel < input_count; ++channel) {
|
||||
const s32 offset = cached_offsets[channel];
|
||||
for (u32 index = 0; index < out_buffer.frames; ++index) {
|
||||
samples[index * input_count + channel] = static_cast<s16>(std::clamp(sample_buffer[offset + index], min, max));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue