mirror of
https://github.com/yuzu-mirror/yuzu
synced 2024-12-12 17:12:28 +00:00
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.
This commit is contained in:
parent
a94b623dfb
commit
1adbcd54fe
2 changed files with 52 additions and 39 deletions
|
@ -3,9 +3,12 @@
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "audio_core/algorithm/interpolate.h"
|
#include "audio_core/algorithm/interpolate.h"
|
||||||
|
#include "audio_core/audio_out.h"
|
||||||
#include "audio_core/audio_renderer.h"
|
#include "audio_core/audio_renderer.h"
|
||||||
|
#include "audio_core/codec.h"
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
#include "core/hle/kernel/event.h"
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
|
|
||||||
namespace AudioCore {
|
namespace AudioCore {
|
||||||
|
@ -13,6 +16,41 @@ namespace AudioCore {
|
||||||
constexpr u32 STREAM_SAMPLE_RATE{48000};
|
constexpr u32 STREAM_SAMPLE_RATE{48000};
|
||||||
constexpr u32 STREAM_NUM_CHANNELS{2};
|
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<s16> 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<s16> samples;
|
||||||
|
VoiceOutStatus out_status{};
|
||||||
|
VoiceInfo info{};
|
||||||
|
};
|
||||||
|
|
||||||
AudioRenderer::AudioRenderer(AudioRendererParameter params,
|
AudioRenderer::AudioRenderer(AudioRendererParameter params,
|
||||||
Kernel::SharedPtr<Kernel::Event> buffer_event)
|
Kernel::SharedPtr<Kernel::Event> buffer_event)
|
||||||
: worker_params{params}, buffer_event{buffer_event}, voices(params.voice_count) {
|
: worker_params{params}, buffer_event{buffer_event}, voices(params.voice_count) {
|
||||||
|
@ -27,6 +65,8 @@ AudioRenderer::AudioRenderer(AudioRendererParameter params,
|
||||||
QueueMixedBuffer(2);
|
QueueMixedBuffer(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AudioRenderer::~AudioRenderer() = default;
|
||||||
|
|
||||||
u32 AudioRenderer::GetSampleRate() const {
|
u32 AudioRenderer::GetSampleRate() const {
|
||||||
return worker_params.sample_rate;
|
return worker_params.sample_rate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,16 +8,20 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "audio_core/algorithm/interpolate.h"
|
|
||||||
#include "audio_core/audio_out.h"
|
|
||||||
#include "audio_core/codec.h"
|
|
||||||
#include "audio_core/stream.h"
|
#include "audio_core/stream.h"
|
||||||
|
#include "common/common_funcs.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/swap.h"
|
#include "common/swap.h"
|
||||||
#include "core/hle/kernel/event.h"
|
#include "core/hle/kernel/object.h"
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
class Event;
|
||||||
|
}
|
||||||
|
|
||||||
namespace AudioCore {
|
namespace AudioCore {
|
||||||
|
|
||||||
|
class AudioOut;
|
||||||
|
|
||||||
enum class PlayState : u8 {
|
enum class PlayState : u8 {
|
||||||
Started = 0,
|
Started = 0,
|
||||||
Stopped = 1,
|
Stopped = 1,
|
||||||
|
@ -158,6 +162,8 @@ static_assert(sizeof(UpdateDataHeader) == 0x40, "UpdateDataHeader has wrong size
|
||||||
class AudioRenderer {
|
class AudioRenderer {
|
||||||
public:
|
public:
|
||||||
AudioRenderer(AudioRendererParameter params, Kernel::SharedPtr<Kernel::Event> buffer_event);
|
AudioRenderer(AudioRendererParameter params, Kernel::SharedPtr<Kernel::Event> buffer_event);
|
||||||
|
~AudioRenderer();
|
||||||
|
|
||||||
std::vector<u8> UpdateAudioRenderer(const std::vector<u8>& input_params);
|
std::vector<u8> UpdateAudioRenderer(const std::vector<u8>& input_params);
|
||||||
void QueueMixedBuffer(Buffer::Tag tag);
|
void QueueMixedBuffer(Buffer::Tag tag);
|
||||||
void ReleaseAndQueueBuffers();
|
void ReleaseAndQueueBuffers();
|
||||||
|
@ -166,45 +172,12 @@ public:
|
||||||
u32 GetMixBufferCount() const;
|
u32 GetMixBufferCount() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class VoiceState {
|
class 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<s16> 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<s16> samples;
|
|
||||||
VoiceOutStatus out_status{};
|
|
||||||
VoiceInfo info{};
|
|
||||||
};
|
|
||||||
|
|
||||||
AudioRendererParameter worker_params;
|
AudioRendererParameter worker_params;
|
||||||
Kernel::SharedPtr<Kernel::Event> buffer_event;
|
Kernel::SharedPtr<Kernel::Event> buffer_event;
|
||||||
std::vector<VoiceState> voices;
|
std::vector<VoiceState> voices;
|
||||||
std::unique_ptr<AudioCore::AudioOut> audio_out;
|
std::unique_ptr<AudioOut> audio_out;
|
||||||
AudioCore::StreamPtr stream;
|
AudioCore::StreamPtr stream;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue