diff options
| author | 2019-11-26 14:10:49 -0500 | |
|---|---|---|
| committer | 2019-11-26 21:55:37 -0500 | |
| commit | 536fc7f0ea77e08d68c760f387c307d258804e3b (patch) | |
| tree | e979df531bf1222788cc26144531c6e6f5cca1d1 /src/audio_core/audio_renderer.cpp | |
| parent | core/memory: Move memory read/write implementation functions into an anonymou... (diff) | |
| download | yuzu-536fc7f0ea77e08d68c760f387c307d258804e3b.tar.gz yuzu-536fc7f0ea77e08d68c760f387c307d258804e3b.tar.xz yuzu-536fc7f0ea77e08d68c760f387c307d258804e3b.zip | |
core: Prepare various classes for memory read/write migration
Amends a few interfaces to be able to handle the migration over to the
new Memory class by passing the class by reference as a function
parameter where necessary.
Notably, within the filesystem services, this eliminates two ReadBlock()
calls by using the helper functions of HLERequestContext to do that for
us.
Diffstat (limited to 'src/audio_core/audio_renderer.cpp')
| -rw-r--r-- | src/audio_core/audio_renderer.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/audio_core/audio_renderer.cpp b/src/audio_core/audio_renderer.cpp index 6b0167acd..12e2b7901 100644 --- a/src/audio_core/audio_renderer.cpp +++ b/src/audio_core/audio_renderer.cpp | |||
| @@ -36,9 +36,9 @@ public: | |||
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | void SetWaveIndex(std::size_t index); | 38 | void SetWaveIndex(std::size_t index); |
| 39 | std::vector<s16> DequeueSamples(std::size_t sample_count); | 39 | std::vector<s16> DequeueSamples(std::size_t sample_count, Memory::Memory& memory); |
| 40 | void UpdateState(); | 40 | void UpdateState(); |
| 41 | void RefreshBuffer(); | 41 | void RefreshBuffer(Memory::Memory& memory); |
| 42 | 42 | ||
| 43 | private: | 43 | private: |
| 44 | bool is_in_use{}; | 44 | bool is_in_use{}; |
| @@ -66,17 +66,18 @@ public: | |||
| 66 | return info; | 66 | return info; |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | void UpdateState(); | 69 | void UpdateState(Memory::Memory& memory); |
| 70 | 70 | ||
| 71 | private: | 71 | private: |
| 72 | EffectOutStatus out_status{}; | 72 | EffectOutStatus out_status{}; |
| 73 | EffectInStatus info{}; | 73 | EffectInStatus info{}; |
| 74 | }; | 74 | }; |
| 75 | AudioRenderer::AudioRenderer(Core::Timing::CoreTiming& core_timing, AudioRendererParameter params, | 75 | AudioRenderer::AudioRenderer(Core::Timing::CoreTiming& core_timing, Memory::Memory& memory_, |
| 76 | AudioRendererParameter params, | ||
| 76 | std::shared_ptr<Kernel::WritableEvent> buffer_event, | 77 | std::shared_ptr<Kernel::WritableEvent> buffer_event, |
| 77 | std::size_t instance_number) | 78 | std::size_t instance_number) |
| 78 | : worker_params{params}, buffer_event{buffer_event}, voices(params.voice_count), | 79 | : worker_params{params}, buffer_event{buffer_event}, voices(params.voice_count), |
| 79 | effects(params.effect_count) { | 80 | effects(params.effect_count), memory{memory_} { |
| 80 | 81 | ||
| 81 | audio_out = std::make_unique<AudioCore::AudioOut>(); | 82 | audio_out = std::make_unique<AudioCore::AudioOut>(); |
| 82 | stream = audio_out->OpenStream(core_timing, STREAM_SAMPLE_RATE, STREAM_NUM_CHANNELS, | 83 | stream = audio_out->OpenStream(core_timing, STREAM_SAMPLE_RATE, STREAM_NUM_CHANNELS, |
| @@ -162,7 +163,7 @@ std::vector<u8> AudioRenderer::UpdateAudioRenderer(const std::vector<u8>& input_ | |||
| 162 | } | 163 | } |
| 163 | 164 | ||
| 164 | for (auto& effect : effects) { | 165 | for (auto& effect : effects) { |
| 165 | effect.UpdateState(); | 166 | effect.UpdateState(memory); |
| 166 | } | 167 | } |
| 167 | 168 | ||
| 168 | // Release previous buffers and queue next ones for playback | 169 | // Release previous buffers and queue next ones for playback |
| @@ -206,13 +207,14 @@ void AudioRenderer::VoiceState::SetWaveIndex(std::size_t index) { | |||
| 206 | is_refresh_pending = true; | 207 | is_refresh_pending = true; |
| 207 | } | 208 | } |
| 208 | 209 | ||
| 209 | std::vector<s16> AudioRenderer::VoiceState::DequeueSamples(std::size_t sample_count) { | 210 | std::vector<s16> AudioRenderer::VoiceState::DequeueSamples(std::size_t sample_count, |
| 211 | Memory::Memory& memory) { | ||
| 210 | if (!IsPlaying()) { | 212 | if (!IsPlaying()) { |
| 211 | return {}; | 213 | return {}; |
| 212 | } | 214 | } |
| 213 | 215 | ||
| 214 | if (is_refresh_pending) { | 216 | if (is_refresh_pending) { |
| 215 | RefreshBuffer(); | 217 | RefreshBuffer(memory); |
| 216 | } | 218 | } |
| 217 | 219 | ||
| 218 | const std::size_t max_size{samples.size() - offset}; | 220 | const std::size_t max_size{samples.size() - offset}; |
| @@ -256,7 +258,7 @@ void AudioRenderer::VoiceState::UpdateState() { | |||
| 256 | is_in_use = info.is_in_use; | 258 | is_in_use = info.is_in_use; |
| 257 | } | 259 | } |
| 258 | 260 | ||
| 259 | void AudioRenderer::VoiceState::RefreshBuffer() { | 261 | void AudioRenderer::VoiceState::RefreshBuffer(Memory::Memory& memory) { |
| 260 | std::vector<s16> new_samples(info.wave_buffer[wave_index].buffer_sz / sizeof(s16)); | 262 | std::vector<s16> new_samples(info.wave_buffer[wave_index].buffer_sz / sizeof(s16)); |
| 261 | Memory::ReadBlock(info.wave_buffer[wave_index].buffer_addr, new_samples.data(), | 263 | Memory::ReadBlock(info.wave_buffer[wave_index].buffer_addr, new_samples.data(), |
| 262 | info.wave_buffer[wave_index].buffer_sz); | 264 | info.wave_buffer[wave_index].buffer_sz); |
| @@ -307,7 +309,7 @@ void AudioRenderer::VoiceState::RefreshBuffer() { | |||
| 307 | is_refresh_pending = false; | 309 | is_refresh_pending = false; |
| 308 | } | 310 | } |
| 309 | 311 | ||
| 310 | void AudioRenderer::EffectState::UpdateState() { | 312 | void AudioRenderer::EffectState::UpdateState(Memory::Memory& memory) { |
| 311 | if (info.is_new) { | 313 | if (info.is_new) { |
| 312 | out_status.state = EffectStatus::New; | 314 | out_status.state = EffectStatus::New; |
| 313 | } else { | 315 | } else { |
| @@ -340,7 +342,7 @@ void AudioRenderer::QueueMixedBuffer(Buffer::Tag tag) { | |||
| 340 | std::size_t offset{}; | 342 | std::size_t offset{}; |
| 341 | s64 samples_remaining{BUFFER_SIZE}; | 343 | s64 samples_remaining{BUFFER_SIZE}; |
| 342 | while (samples_remaining > 0) { | 344 | while (samples_remaining > 0) { |
| 343 | const std::vector<s16> samples{voice.DequeueSamples(samples_remaining)}; | 345 | const std::vector<s16> samples{voice.DequeueSamples(samples_remaining, memory)}; |
| 344 | 346 | ||
| 345 | if (samples.empty()) { | 347 | if (samples.empty()) { |
| 346 | break; | 348 | break; |