summaryrefslogtreecommitdiff
path: root/src/audio_core/audio_renderer.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2018-09-14 11:54:17 -0400
committerGravatar Lioncash2018-09-17 15:08:30 -0400
commit1adbcd54fe0d5d75c487c86640fed263251867ea (patch)
treeba2c44b84a00be497fb93f85b8145ea011e9f877 /src/audio_core/audio_renderer.cpp
parentMerge pull request #1311 from FernandoS27/fast-swizzle (diff)
downloadyuzu-1adbcd54fe0d5d75c487c86640fed263251867ea.tar.gz
yuzu-1adbcd54fe0d5d75c487c86640fed263251867ea.tar.xz
yuzu-1adbcd54fe0d5d75c487c86640fed263251867ea.zip
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.
Diffstat (limited to 'src/audio_core/audio_renderer.cpp')
-rw-r--r--src/audio_core/audio_renderer.cpp40
1 files changed, 40 insertions, 0 deletions
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 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "audio_core/algorithm/interpolate.h" 5#include "audio_core/algorithm/interpolate.h"
6#include "audio_core/audio_out.h"
6#include "audio_core/audio_renderer.h" 7#include "audio_core/audio_renderer.h"
8#include "audio_core/codec.h"
7#include "common/assert.h" 9#include "common/assert.h"
8#include "common/logging/log.h" 10#include "common/logging/log.h"
11#include "core/hle/kernel/event.h"
9#include "core/memory.h" 12#include "core/memory.h"
10 13
11namespace AudioCore { 14namespace AudioCore {
@@ -13,6 +16,41 @@ namespace AudioCore {
13constexpr u32 STREAM_SAMPLE_RATE{48000}; 16constexpr u32 STREAM_SAMPLE_RATE{48000};
14constexpr u32 STREAM_NUM_CHANNELS{2}; 17constexpr u32 STREAM_NUM_CHANNELS{2};
15 18
19class AudioRenderer::VoiceState {
20public:
21 bool IsPlaying() const {
22 return is_in_use && info.play_state == PlayState::Started;
23 }
24
25 const VoiceOutStatus& GetOutStatus() const {
26 return out_status;
27 }
28
29 const VoiceInfo& GetInfo() const {
30 return info;
31 }
32
33 VoiceInfo& Info() {
34 return info;
35 }
36
37 void SetWaveIndex(std::size_t index);
38 std::vector<s16> DequeueSamples(std::size_t sample_count);
39 void UpdateState();
40 void RefreshBuffer();
41
42private:
43 bool is_in_use{};
44 bool is_refresh_pending{};
45 std::size_t wave_index{};
46 std::size_t offset{};
47 Codec::ADPCMState adpcm_state{};
48 InterpolationState interp_state{};
49 std::vector<s16> samples;
50 VoiceOutStatus out_status{};
51 VoiceInfo info{};
52};
53
16AudioRenderer::AudioRenderer(AudioRendererParameter params, 54AudioRenderer::AudioRenderer(AudioRendererParameter params,
17 Kernel::SharedPtr<Kernel::Event> buffer_event) 55 Kernel::SharedPtr<Kernel::Event> buffer_event)
18 : worker_params{params}, buffer_event{buffer_event}, voices(params.voice_count) { 56 : worker_params{params}, buffer_event{buffer_event}, voices(params.voice_count) {
@@ -27,6 +65,8 @@ AudioRenderer::AudioRenderer(AudioRendererParameter params,
27 QueueMixedBuffer(2); 65 QueueMixedBuffer(2);
28} 66}
29 67
68AudioRenderer::~AudioRenderer() = default;
69
30u32 AudioRenderer::GetSampleRate() const { 70u32 AudioRenderer::GetSampleRate() const {
31 return worker_params.sample_rate; 71 return worker_params.sample_rate;
32} 72}