mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-13 01:37:56 -05:00
Sources: Run clang-format on everything.
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user