From 1adbcd54fe0d5d75c487c86640fed263251867ea Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 14 Sep 2018 11:54:17 -0400 Subject: audio_renderer: Replace includes with forward declarations where applicable Avoids including unnecessary headers within the audio_renderer.h header, lessening the likelihood of needing to rebuild source files including this header if they ever change. Given std::vector allows forward declaring contained types, we can move VoiceState to the cpp file and hide the implementation entirely. --- src/audio_core/audio_renderer.cpp | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/audio_core/audio_renderer.cpp') diff --git a/src/audio_core/audio_renderer.cpp b/src/audio_core/audio_renderer.cpp index ed3b7defc..83b75e61f 100644 --- a/src/audio_core/audio_renderer.cpp +++ b/src/audio_core/audio_renderer.cpp @@ -3,9 +3,12 @@ // Refer to the license.txt file included. #include "audio_core/algorithm/interpolate.h" +#include "audio_core/audio_out.h" #include "audio_core/audio_renderer.h" +#include "audio_core/codec.h" #include "common/assert.h" #include "common/logging/log.h" +#include "core/hle/kernel/event.h" #include "core/memory.h" namespace AudioCore { @@ -13,6 +16,41 @@ namespace AudioCore { constexpr u32 STREAM_SAMPLE_RATE{48000}; constexpr u32 STREAM_NUM_CHANNELS{2}; +class AudioRenderer::VoiceState { +public: + bool IsPlaying() const { + return is_in_use && info.play_state == PlayState::Started; + } + + const VoiceOutStatus& GetOutStatus() const { + return out_status; + } + + const VoiceInfo& GetInfo() const { + return info; + } + + VoiceInfo& Info() { + return info; + } + + void SetWaveIndex(std::size_t index); + std::vector DequeueSamples(std::size_t sample_count); + void UpdateState(); + void RefreshBuffer(); + +private: + bool is_in_use{}; + bool is_refresh_pending{}; + std::size_t wave_index{}; + std::size_t offset{}; + Codec::ADPCMState adpcm_state{}; + InterpolationState interp_state{}; + std::vector samples; + VoiceOutStatus out_status{}; + VoiceInfo info{}; +}; + AudioRenderer::AudioRenderer(AudioRendererParameter params, Kernel::SharedPtr buffer_event) : worker_params{params}, buffer_event{buffer_event}, voices(params.voice_count) { @@ -27,6 +65,8 @@ AudioRenderer::AudioRenderer(AudioRendererParameter params, QueueMixedBuffer(2); } +AudioRenderer::~AudioRenderer() = default; + u32 AudioRenderer::GetSampleRate() const { return worker_params.sample_rate; } -- cgit v1.2.3