summaryrefslogtreecommitdiffstats
path: root/src/audio_core/sink/sink_stream.cpp
diff options
context:
space:
mode:
authorKelebek1 <eeeedddccc@hotmail.co.uk>2023-05-23 15:45:54 +0200
committerKelebek1 <eeeedddccc@hotmail.co.uk>2023-06-22 09:05:10 +0200
commit5da70f719703084482933e103e561cc98163f370 (patch)
tree1926842ed2b90bf92b89cec6a314bb28c7287fe9 /src/audio_core/sink/sink_stream.cpp
parentMerge pull request #10086 from Morph1984/coretiming-ng-1 (diff)
downloadyuzu-5da70f719703084482933e103e561cc98163f370.tar
yuzu-5da70f719703084482933e103e561cc98163f370.tar.gz
yuzu-5da70f719703084482933e103e561cc98163f370.tar.bz2
yuzu-5da70f719703084482933e103e561cc98163f370.tar.lz
yuzu-5da70f719703084482933e103e561cc98163f370.tar.xz
yuzu-5da70f719703084482933e103e561cc98163f370.tar.zst
yuzu-5da70f719703084482933e103e561cc98163f370.zip
Diffstat (limited to 'src/audio_core/sink/sink_stream.cpp')
-rw-r--r--src/audio_core/sink/sink_stream.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/audio_core/sink/sink_stream.cpp b/src/audio_core/sink/sink_stream.cpp
index 9a718a9cc..404dcd0e9 100644
--- a/src/audio_core/sink/sink_stream.cpp
+++ b/src/audio_core/sink/sink_stream.cpp
@@ -18,7 +18,7 @@
namespace AudioCore::Sink {
-void SinkStream::AppendBuffer(SinkBuffer& buffer, std::vector<s16>& samples) {
+void SinkStream::AppendBuffer(SinkBuffer& buffer, std::span<s16> samples) {
if (type == StreamType::In) {
queue.enqueue(buffer);
queued_buffers++;
@@ -66,15 +66,16 @@ void SinkStream::AppendBuffer(SinkBuffer& buffer, std::vector<s16>& samples) {
static_cast<s16>(std::clamp(right_sample, min, max));
}
- samples.resize(samples.size() / system_channels * device_channels);
+ samples = samples.subspan(0, samples.size() / system_channels * device_channels);
} else if (system_channels == 2 && device_channels == 6) {
// We need moar samples! Not all games will provide 6 channel audio.
// TODO: Implement some upmixing here. Currently just passthrough, with other
// channels left as silence.
- std::vector<s16> new_samples(samples.size() / system_channels * device_channels, 0);
+ auto new_size = samples.size() / system_channels * device_channels;
+ tmp_samples.resize_destructive(new_size);
- for (u32 read_index = 0, write_index = 0; read_index < samples.size();
+ for (u32 read_index = 0, write_index = 0; read_index < new_size;
read_index += system_channels, write_index += device_channels) {
const auto left_sample{static_cast<s16>(std::clamp(
static_cast<s32>(
@@ -82,7 +83,7 @@ void SinkStream::AppendBuffer(SinkBuffer& buffer, std::vector<s16>& samples) {
volume),
min, max))};
- new_samples[write_index + static_cast<u32>(Channels::FrontLeft)] = left_sample;
+ tmp_samples[write_index + static_cast<u32>(Channels::FrontLeft)] = left_sample;
const auto right_sample{static_cast<s16>(std::clamp(
static_cast<s32>(
@@ -90,9 +91,9 @@ void SinkStream::AppendBuffer(SinkBuffer& buffer, std::vector<s16>& samples) {
volume),
min, max))};
- new_samples[write_index + static_cast<u32>(Channels::FrontRight)] = right_sample;
+ tmp_samples[write_index + static_cast<u32>(Channels::FrontRight)] = right_sample;
}
- samples = std::move(new_samples);
+ samples = std::span<s16>(tmp_samples);
} else if (volume != 1.0f) {
for (u32 i = 0; i < samples.size(); i++) {