mirror of
https://git.h3cjp.net/H3cJP/citra.git
synced 2024-11-27 06:22:49 +00:00
Merge pull request #9297 from Kelebek1/sink_oob
[audio_core] Fix an OoB with sample sinking
This commit is contained in:
commit
e16d1b85f1
|
@ -460,21 +460,23 @@ void CommandBuffer::GenerateDeviceSinkCommand(const s32 node_id, const s16 buffe
|
||||||
|
|
||||||
cmd.session_id = session_id;
|
cmd.session_id = session_id;
|
||||||
|
|
||||||
|
cmd.input_count = parameter.input_count;
|
||||||
|
s16 max_input{0};
|
||||||
|
for (u32 i = 0; i < parameter.input_count; i++) {
|
||||||
|
cmd.inputs[i] = buffer_offset + parameter.inputs[i];
|
||||||
|
max_input = std::max(max_input, cmd.inputs[i]);
|
||||||
|
}
|
||||||
|
|
||||||
if (state.upsampler_info != nullptr) {
|
if (state.upsampler_info != nullptr) {
|
||||||
const auto size_{state.upsampler_info->sample_count * parameter.input_count};
|
const auto size_{state.upsampler_info->sample_count * parameter.input_count};
|
||||||
const auto size_bytes{size_ * sizeof(s32)};
|
const auto size_bytes{size_ * sizeof(s32)};
|
||||||
const auto addr{memory_pool->Translate(state.upsampler_info->samples_pos, size_bytes)};
|
const auto addr{memory_pool->Translate(state.upsampler_info->samples_pos, size_bytes)};
|
||||||
cmd.sample_buffer = {reinterpret_cast<s32*>(addr),
|
cmd.sample_buffer = {reinterpret_cast<s32*>(addr),
|
||||||
parameter.input_count * state.upsampler_info->sample_count};
|
(max_input + 1) * state.upsampler_info->sample_count};
|
||||||
} else {
|
} else {
|
||||||
cmd.sample_buffer = samples_buffer;
|
cmd.sample_buffer = samples_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.input_count = parameter.input_count;
|
|
||||||
for (u32 i = 0; i < parameter.input_count; i++) {
|
|
||||||
cmd.inputs[i] = buffer_offset + parameter.inputs[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
GenerateEnd<DeviceSinkCommand>(cmd);
|
GenerateEnd<DeviceSinkCommand>(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue