summaryrefslogtreecommitdiffstats
path: root/src/audio_core/device
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio_core/device')
-rw-r--r--src/audio_core/device/audio_buffers.h8
-rw-r--r--src/audio_core/device/device_session.cpp12
-rw-r--r--src/audio_core/device/device_session.h7
3 files changed, 15 insertions, 12 deletions
diff --git a/src/audio_core/device/audio_buffers.h b/src/audio_core/device/audio_buffers.h
index 15082f6c6..5d8ed0ef7 100644
--- a/src/audio_core/device/audio_buffers.h
+++ b/src/audio_core/device/audio_buffers.h
@@ -7,6 +7,7 @@
#include <mutex>
#include <span>
#include <vector>
+#include <boost/container/static_vector.hpp>
#include "audio_buffer.h"
#include "audio_core/device/device_session.h"
@@ -48,7 +49,7 @@ public:
*
* @param out_buffers - The buffers which were registered.
*/
- void RegisterBuffers(std::vector<AudioBuffer>& out_buffers) {
+ void RegisterBuffers(boost::container::static_vector<AudioBuffer, N>& out_buffers) {
std::scoped_lock l{lock};
const s32 to_register{std::min(std::min(appended_count, BufferAppendLimit),
BufferAppendLimit - registered_count)};
@@ -162,7 +163,8 @@ public:
* @param max_buffers - Maximum number of buffers to released.
* @return The number of buffers released.
*/
- u32 GetRegisteredAppendedBuffers(std::vector<AudioBuffer>& buffers_flushed, u32 max_buffers) {
+ u32 GetRegisteredAppendedBuffers(
+ boost::container::static_vector<AudioBuffer, N>& buffers_flushed, u32 max_buffers) {
std::scoped_lock l{lock};
if (registered_count + appended_count == 0) {
return 0;
@@ -270,7 +272,7 @@ public:
*/
bool FlushBuffers(u32& buffers_released) {
std::scoped_lock l{lock};
- std::vector<AudioBuffer> buffers_flushed{};
+ boost::container::static_vector<AudioBuffer, N> buffers_flushed{};
buffers_released = GetRegisteredAppendedBuffers(buffers_flushed, append_limit);
diff --git a/src/audio_core/device/device_session.cpp b/src/audio_core/device/device_session.cpp
index b5c0ef0e6..86811fcb8 100644
--- a/src/audio_core/device/device_session.cpp
+++ b/src/audio_core/device/device_session.cpp
@@ -79,7 +79,7 @@ void DeviceSession::ClearBuffers() {
}
}
-void DeviceSession::AppendBuffers(std::span<const AudioBuffer> buffers) const {
+void DeviceSession::AppendBuffers(std::span<const AudioBuffer> buffers) {
for (const auto& buffer : buffers) {
Sink::SinkBuffer new_buffer{
.frames = buffer.size / (channel_count * sizeof(s16)),
@@ -88,13 +88,13 @@ void DeviceSession::AppendBuffers(std::span<const AudioBuffer> buffers) const {
.consumed = false,
};
+ tmp_samples.resize_destructive(buffer.size / sizeof(s16));
if (type == Sink::StreamType::In) {
- std::vector<s16> samples{};
- stream->AppendBuffer(new_buffer, samples);
+ stream->AppendBuffer(new_buffer, tmp_samples);
} else {
- std::vector<s16> samples(buffer.size / sizeof(s16));
- system.ApplicationMemory().ReadBlockUnsafe(buffer.samples, samples.data(), buffer.size);
- stream->AppendBuffer(new_buffer, samples);
+ system.ApplicationMemory().ReadBlockUnsafe(buffer.samples, tmp_samples.data(),
+ buffer.size);
+ stream->AppendBuffer(new_buffer, tmp_samples);
}
}
}
diff --git a/src/audio_core/device/device_session.h b/src/audio_core/device/device_session.h
index 75f766c68..7d52f362d 100644
--- a/src/audio_core/device/device_session.h
+++ b/src/audio_core/device/device_session.h
@@ -10,6 +10,7 @@
#include "audio_core/common/common.h"
#include "audio_core/sink/sink.h"
+#include "common/scratch_buffer.h"
#include "core/hle/service/audio/errors.h"
namespace Core {
@@ -62,7 +63,7 @@ public:
*
* @param buffers - The buffers to play.
*/
- void AppendBuffers(std::span<const AudioBuffer> buffers) const;
+ void AppendBuffers(std::span<const AudioBuffer> buffers);
/**
* (Audio In only) Pop samples from the backend, and write them back to this buffer's address.
@@ -146,8 +147,8 @@ private:
std::shared_ptr<Core::Timing::EventType> thread_event;
/// Is this session initialised?
bool initialized{};
- /// Buffer queue
- std::vector<AudioBuffer> buffer_queue{};
+ /// Temporary sample buffer
+ Common::ScratchBuffer<s16> tmp_samples{};
};
} // namespace AudioCore