summaryrefslogtreecommitdiffstats
path: root/src/audio_core
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/audio_core/CMakeLists.txt6
-rw-r--r--src/audio_core/renderer/command/command_buffer.cpp14
-rw-r--r--src/audio_core/sink/sink_stream.cpp11
-rw-r--r--src/audio_core/sink/sink_stream.h5
4 files changed, 22 insertions, 14 deletions
diff --git a/src/audio_core/CMakeLists.txt b/src/audio_core/CMakeLists.txt
index 8e3a8f5a8..75416c53a 100644
--- a/src/audio_core/CMakeLists.txt
+++ b/src/audio_core/CMakeLists.txt
@@ -226,6 +226,10 @@ if(ENABLE_CUBEB)
target_compile_definitions(audio_core PRIVATE -DHAVE_CUBEB=1)
endif()
if(ENABLE_SDL2)
- target_link_libraries(audio_core PRIVATE SDL2)
+ if (YUZU_USE_EXTERNAL_SDL2)
+ target_link_libraries(audio_core PRIVATE SDL2-static)
+ else()
+ target_link_libraries(audio_core PRIVATE SDL2)
+ endif()
target_compile_definitions(audio_core PRIVATE HAVE_SDL2)
endif()
diff --git a/src/audio_core/renderer/command/command_buffer.cpp b/src/audio_core/renderer/command/command_buffer.cpp
index 2ef879ee1..8c6fe97e7 100644
--- a/src/audio_core/renderer/command/command_buffer.cpp
+++ b/src/audio_core/renderer/command/command_buffer.cpp
@@ -460,21 +460,23 @@ void CommandBuffer::GenerateDeviceSinkCommand(const s32 node_id, const s16 buffe
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) {
const auto size_{state.upsampler_info->sample_count * parameter.input_count};
const auto size_bytes{size_ * sizeof(s32)};
const auto addr{memory_pool->Translate(state.upsampler_info->samples_pos, size_bytes)};
cmd.sample_buffer = {reinterpret_cast<s32*>(addr),
- parameter.input_count * state.upsampler_info->sample_count};
+ (max_input + 1) * state.upsampler_info->sample_count};
} else {
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);
}
diff --git a/src/audio_core/sink/sink_stream.cpp b/src/audio_core/sink/sink_stream.cpp
index e3d060f11..06c2a876e 100644
--- a/src/audio_core/sink/sink_stream.cpp
+++ b/src/audio_core/sink/sink_stream.cpp
@@ -266,19 +266,20 @@ void SinkStream::ProcessAudioOutAndRender(std::span<s16> output_buffer, std::siz
}
void SinkStream::Stall() {
- if (stalled) {
+ std::scoped_lock lk{stall_guard};
+ if (stalled_lock) {
return;
}
- stalled = true;
- system.StallProcesses();
+ stalled_lock = system.StallProcesses();
}
void SinkStream::Unstall() {
- if (!stalled) {
+ std::scoped_lock lk{stall_guard};
+ if (!stalled_lock) {
return;
}
system.UnstallProcesses();
- stalled = false;
+ stalled_lock.unlock();
}
} // namespace AudioCore::Sink
diff --git a/src/audio_core/sink/sink_stream.h b/src/audio_core/sink/sink_stream.h
index 38a4b2f51..5fea72ab7 100644
--- a/src/audio_core/sink/sink_stream.h
+++ b/src/audio_core/sink/sink_stream.h
@@ -6,6 +6,7 @@
#include <array>
#include <atomic>
#include <memory>
+#include <mutex>
#include <span>
#include <vector>
@@ -240,8 +241,8 @@ private:
f32 system_volume{1.0f};
/// Set via IAudioDevice service calls
f32 device_volume{1.0f};
- /// True if coretiming has been stalled
- bool stalled{false};
+ std::mutex stall_guard;
+ std::unique_lock<std::mutex> stalled_lock;
};
using SinkStreamPtr = std::unique_ptr<SinkStream>;