2020-07-12 04:59:14 -07:00
|
|
|
// Copyright 2020 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "audio_core/sink_context.h"
|
|
|
|
|
|
|
|
namespace AudioCore {
|
2020-11-25 12:21:03 -08:00
|
|
|
SinkContext::SinkContext(std::size_t sink_count_) : sink_count{sink_count_} {}
|
2020-07-12 04:59:14 -07:00
|
|
|
SinkContext::~SinkContext() = default;
|
|
|
|
|
|
|
|
std::size_t SinkContext::GetCount() const {
|
|
|
|
return sink_count;
|
|
|
|
}
|
|
|
|
|
2020-11-16 19:14:29 -08:00
|
|
|
void SinkContext::UpdateMainSink(const SinkInfo::InParams& in) {
|
|
|
|
ASSERT(in.type == SinkTypes::Device);
|
|
|
|
|
2021-07-07 06:56:23 -07:00
|
|
|
if (in.device.down_matrix_enabled) {
|
2020-11-16 19:14:29 -08:00
|
|
|
downmix_coefficients = in.device.down_matrix_coef;
|
2021-07-07 06:56:23 -07:00
|
|
|
} else {
|
|
|
|
downmix_coefficients = {
|
|
|
|
1.0f, // front
|
|
|
|
0.707f, // center
|
|
|
|
0.0f, // lfe
|
|
|
|
0.707f, // back
|
|
|
|
};
|
2020-11-16 19:14:29 -08:00
|
|
|
}
|
2021-07-07 06:56:23 -07:00
|
|
|
|
2020-07-12 04:59:14 -07:00
|
|
|
in_use = in.in_use;
|
|
|
|
use_count = in.device.input_count;
|
2020-11-16 19:14:29 -08:00
|
|
|
buffers = in.device.input;
|
2020-07-12 04:59:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SinkContext::InUse() const {
|
|
|
|
return in_use;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<u8> SinkContext::OutputBuffers() const {
|
2020-10-20 19:07:39 -07:00
|
|
|
std::vector<u8> buffer_ret(use_count);
|
|
|
|
std::memcpy(buffer_ret.data(), buffers.data(), use_count);
|
2020-07-12 04:59:14 -07:00
|
|
|
return buffer_ret;
|
|
|
|
}
|
|
|
|
|
2020-11-16 20:40:19 -08:00
|
|
|
const DownmixCoefficients& SinkContext::GetDownmixCoefficients() const {
|
2020-11-16 19:14:29 -08:00
|
|
|
return downmix_coefficients;
|
|
|
|
}
|
|
|
|
|
2020-07-12 04:59:14 -07:00
|
|
|
} // namespace AudioCore
|