summaryrefslogtreecommitdiffstats
path: root/src/audio_core/sdl2_sink.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio_core/sdl2_sink.cpp')
-rw-r--r--src/audio_core/sdl2_sink.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/audio_core/sdl2_sink.cpp b/src/audio_core/sdl2_sink.cpp
index 1d7912715..65aac877a 100644
--- a/src/audio_core/sdl2_sink.cpp
+++ b/src/audio_core/sdl2_sink.cpp
@@ -10,9 +10,9 @@
#include "audio_core/audio_core.h"
#include "audio_core/sdl2_sink.h"
+#include <numeric>
#include "common/assert.h"
#include "common/logging/log.h"
-#include <numeric>
namespace AudioCore {
@@ -45,7 +45,8 @@ SDL2Sink::SDL2Sink() : impl(std::make_unique<Impl>()) {
SDL_AudioSpec obtained_audiospec;
SDL_zero(obtained_audiospec);
- impl->audio_device_id = SDL_OpenAudioDevice(nullptr, false, &desired_audiospec, &obtained_audiospec, 0);
+ impl->audio_device_id =
+ SDL_OpenAudioDevice(nullptr, false, &desired_audiospec, &obtained_audiospec, 0);
if (impl->audio_device_id <= 0) {
LOG_CRITICAL(Audio_Sink, "SDL_OpenAudioDevice failed");
return;
@@ -86,11 +87,12 @@ size_t SDL2Sink::SamplesInQueue() const {
SDL_LockAudioDevice(impl->audio_device_id);
- size_t total_size = std::accumulate(impl->queue.begin(), impl->queue.end(), static_cast<size_t>(0),
- [](size_t sum, const auto& buffer) {
- // Division by two because each stereo sample is made of two s16.
- return sum + buffer.size() / 2;
- });
+ size_t total_size = std::accumulate(impl->queue.begin(), impl->queue.end(),
+ static_cast<size_t>(0), [](size_t sum, const auto& buffer) {
+ // Division by two because each stereo sample is made of
+ // two s16.
+ return sum + buffer.size() / 2;
+ });
SDL_UnlockAudioDevice(impl->audio_device_id);
@@ -100,7 +102,8 @@ size_t SDL2Sink::SamplesInQueue() const {
void SDL2Sink::Impl::Callback(void* impl_, u8* buffer, int buffer_size_in_bytes) {
Impl* impl = reinterpret_cast<Impl*>(impl_);
- size_t remaining_size = static_cast<size_t>(buffer_size_in_bytes) / sizeof(s16); // Keep track of size in 16-bit increments.
+ size_t remaining_size = static_cast<size_t>(buffer_size_in_bytes) /
+ sizeof(s16); // Keep track of size in 16-bit increments.
while (remaining_size > 0 && !impl->queue.empty()) {
if (impl->queue.front().size() <= remaining_size) {
@@ -111,7 +114,8 @@ void SDL2Sink::Impl::Callback(void* impl_, u8* buffer, int buffer_size_in_bytes)
} else {
memcpy(buffer, impl->queue.front().data(), remaining_size * sizeof(s16));
buffer += remaining_size * sizeof(s16);
- impl->queue.front().erase(impl->queue.front().begin(), impl->queue.front().begin() + remaining_size);
+ impl->queue.front().erase(impl->queue.front().begin(),
+ impl->queue.front().begin() + remaining_size);
remaining_size = 0;
}
}