diff options
| author | 2016-09-18 09:38:01 +0900 | |
|---|---|---|
| committer | 2016-09-18 09:38:01 +0900 | |
| commit | dc8479928c5aee4c6ad6fe4f59006fb604cee701 (patch) | |
| tree | 569a7f13128450bbab973236615587ff00bced5f /src/audio_core/hle/source.cpp | |
| parent | Travis: Import Dolphin’s clang-format hook. (diff) | |
| download | yuzu-dc8479928c5aee4c6ad6fe4f59006fb604cee701.tar.gz yuzu-dc8479928c5aee4c6ad6fe4f59006fb604cee701.tar.xz yuzu-dc8479928c5aee4c6ad6fe4f59006fb604cee701.zip | |
Sources: Run clang-format on everything.
Diffstat (limited to 'src/audio_core/hle/source.cpp')
| -rw-r--r-- | src/audio_core/hle/source.cpp | 119 |
1 files changed, 67 insertions, 52 deletions
diff --git a/src/audio_core/hle/source.cpp b/src/audio_core/hle/source.cpp index 30552fe26..fad0ce2ad 100644 --- a/src/audio_core/hle/source.cpp +++ b/src/audio_core/hle/source.cpp | |||
| @@ -18,7 +18,8 @@ | |||
| 18 | namespace DSP { | 18 | namespace DSP { |
| 19 | namespace HLE { | 19 | namespace HLE { |
| 20 | 20 | ||
| 21 | SourceStatus::Status Source::Tick(SourceConfiguration::Configuration& config, const s16_le (&adpcm_coeffs)[16]) { | 21 | SourceStatus::Status Source::Tick(SourceConfiguration::Configuration& config, |
| 22 | const s16_le (&adpcm_coeffs)[16]) { | ||
| 22 | ParseConfig(config, adpcm_coeffs); | 23 | ParseConfig(config, adpcm_coeffs); |
| 23 | 24 | ||
| 24 | if (state.enabled) { | 25 | if (state.enabled) { |
| @@ -47,7 +48,8 @@ void Source::Reset() { | |||
| 47 | state = {}; | 48 | state = {}; |
| 48 | } | 49 | } |
| 49 | 50 | ||
| 50 | void Source::ParseConfig(SourceConfiguration::Configuration& config, const s16_le (&adpcm_coeffs)[16]) { | 51 | void Source::ParseConfig(SourceConfiguration::Configuration& config, |
| 52 | const s16_le (&adpcm_coeffs)[16]) { | ||
| 51 | if (!config.dirty_raw) { | 53 | if (!config.dirty_raw) { |
| 52 | return; | 54 | return; |
| 53 | } | 55 | } |
| @@ -82,7 +84,8 @@ void Source::ParseConfig(SourceConfiguration::Configuration& config, const s16_l | |||
| 82 | LOG_TRACE(Audio_DSP, "source_id=%zu rate=%f", source_id, state.rate_multiplier); | 84 | LOG_TRACE(Audio_DSP, "source_id=%zu rate=%f", source_id, state.rate_multiplier); |
| 83 | 85 | ||
| 84 | if (state.rate_multiplier <= 0) { | 86 | if (state.rate_multiplier <= 0) { |
| 85 | LOG_ERROR(Audio_DSP, "Was given an invalid rate multiplier: source_id=%zu rate=%f", source_id, state.rate_multiplier); | 87 | LOG_ERROR(Audio_DSP, "Was given an invalid rate multiplier: source_id=%zu rate=%f", |
| 88 | source_id, state.rate_multiplier); | ||
| 86 | state.rate_multiplier = 1.0f; | 89 | state.rate_multiplier = 1.0f; |
| 87 | // Note: Actual firmware starts producing garbage if this occurs. | 90 | // Note: Actual firmware starts producing garbage if this occurs. |
| 88 | } | 91 | } |
| @@ -90,37 +93,39 @@ void Source::ParseConfig(SourceConfiguration::Configuration& config, const s16_l | |||
| 90 | 93 | ||
| 91 | if (config.adpcm_coefficients_dirty) { | 94 | if (config.adpcm_coefficients_dirty) { |
| 92 | config.adpcm_coefficients_dirty.Assign(0); | 95 | config.adpcm_coefficients_dirty.Assign(0); |
| 93 | std::transform(adpcm_coeffs, adpcm_coeffs + state.adpcm_coeffs.size(), state.adpcm_coeffs.begin(), | 96 | std::transform(adpcm_coeffs, adpcm_coeffs + state.adpcm_coeffs.size(), |
| 94 | [](const auto& coeff) { return static_cast<s16>(coeff); }); | 97 | state.adpcm_coeffs.begin(), |
| 98 | [](const auto& coeff) { return static_cast<s16>(coeff); }); | ||
| 95 | LOG_TRACE(Audio_DSP, "source_id=%zu adpcm update", source_id); | 99 | LOG_TRACE(Audio_DSP, "source_id=%zu adpcm update", source_id); |
| 96 | } | 100 | } |
| 97 | 101 | ||
| 98 | if (config.gain_0_dirty) { | 102 | if (config.gain_0_dirty) { |
| 99 | config.gain_0_dirty.Assign(0); | 103 | config.gain_0_dirty.Assign(0); |
| 100 | std::transform(config.gain[0], config.gain[0] + state.gain[0].size(), state.gain[0].begin(), | 104 | std::transform(config.gain[0], config.gain[0] + state.gain[0].size(), state.gain[0].begin(), |
| 101 | [](const auto& coeff) { return static_cast<float>(coeff); }); | 105 | [](const auto& coeff) { return static_cast<float>(coeff); }); |
| 102 | LOG_TRACE(Audio_DSP, "source_id=%zu gain 0 update", source_id); | 106 | LOG_TRACE(Audio_DSP, "source_id=%zu gain 0 update", source_id); |
| 103 | } | 107 | } |
| 104 | 108 | ||
| 105 | if (config.gain_1_dirty) { | 109 | if (config.gain_1_dirty) { |
| 106 | config.gain_1_dirty.Assign(0); | 110 | config.gain_1_dirty.Assign(0); |
| 107 | std::transform(config.gain[1], config.gain[1] + state.gain[1].size(), state.gain[1].begin(), | 111 | std::transform(config.gain[1], config.gain[1] + state.gain[1].size(), state.gain[1].begin(), |
| 108 | [](const auto& coeff) { return static_cast<float>(coeff); }); | 112 | [](const auto& coeff) { return static_cast<float>(coeff); }); |
| 109 | LOG_TRACE(Audio_DSP, "source_id=%zu gain 1 update", source_id); | 113 | LOG_TRACE(Audio_DSP, "source_id=%zu gain 1 update", source_id); |
| 110 | } | 114 | } |
| 111 | 115 | ||
| 112 | if (config.gain_2_dirty) { | 116 | if (config.gain_2_dirty) { |
| 113 | config.gain_2_dirty.Assign(0); | 117 | config.gain_2_dirty.Assign(0); |
| 114 | std::transform(config.gain[2], config.gain[2] + state.gain[2].size(), state.gain[2].begin(), | 118 | std::transform(config.gain[2], config.gain[2] + state.gain[2].size(), state.gain[2].begin(), |
| 115 | [](const auto& coeff) { return static_cast<float>(coeff); }); | 119 | [](const auto& coeff) { return static_cast<float>(coeff); }); |
| 116 | LOG_TRACE(Audio_DSP, "source_id=%zu gain 2 update", source_id); | 120 | LOG_TRACE(Audio_DSP, "source_id=%zu gain 2 update", source_id); |
| 117 | } | 121 | } |
| 118 | 122 | ||
| 119 | if (config.filters_enabled_dirty) { | 123 | if (config.filters_enabled_dirty) { |
| 120 | config.filters_enabled_dirty.Assign(0); | 124 | config.filters_enabled_dirty.Assign(0); |
| 121 | state.filters.Enable(config.simple_filter_enabled.ToBool(), config.biquad_filter_enabled.ToBool()); | 125 | state.filters.Enable(config.simple_filter_enabled.ToBool(), |
| 122 | LOG_TRACE(Audio_DSP, "source_id=%zu enable_simple=%hu enable_biquad=%hu", | 126 | config.biquad_filter_enabled.ToBool()); |
| 123 | source_id, config.simple_filter_enabled.Value(), config.biquad_filter_enabled.Value()); | 127 | LOG_TRACE(Audio_DSP, "source_id=%zu enable_simple=%hu enable_biquad=%hu", source_id, |
| 128 | config.simple_filter_enabled.Value(), config.biquad_filter_enabled.Value()); | ||
| 124 | } | 129 | } |
| 125 | 130 | ||
| 126 | if (config.simple_filter_dirty) { | 131 | if (config.simple_filter_dirty) { |
| @@ -138,36 +143,38 @@ void Source::ParseConfig(SourceConfiguration::Configuration& config, const s16_l | |||
| 138 | if (config.interpolation_dirty) { | 143 | if (config.interpolation_dirty) { |
| 139 | config.interpolation_dirty.Assign(0); | 144 | config.interpolation_dirty.Assign(0); |
| 140 | state.interpolation_mode = config.interpolation_mode; | 145 | state.interpolation_mode = config.interpolation_mode; |
| 141 | LOG_TRACE(Audio_DSP, "source_id=%zu interpolation_mode=%zu", source_id, static_cast<size_t>(state.interpolation_mode)); | 146 | LOG_TRACE(Audio_DSP, "source_id=%zu interpolation_mode=%zu", source_id, |
| 147 | static_cast<size_t>(state.interpolation_mode)); | ||
| 142 | } | 148 | } |
| 143 | 149 | ||
| 144 | if (config.format_dirty || config.embedded_buffer_dirty) { | 150 | if (config.format_dirty || config.embedded_buffer_dirty) { |
| 145 | config.format_dirty.Assign(0); | 151 | config.format_dirty.Assign(0); |
| 146 | state.format = config.format; | 152 | state.format = config.format; |
| 147 | LOG_TRACE(Audio_DSP, "source_id=%zu format=%zu", source_id, static_cast<size_t>(state.format)); | 153 | LOG_TRACE(Audio_DSP, "source_id=%zu format=%zu", source_id, |
| 154 | static_cast<size_t>(state.format)); | ||
| 148 | } | 155 | } |
| 149 | 156 | ||
| 150 | if (config.mono_or_stereo_dirty || config.embedded_buffer_dirty) { | 157 | if (config.mono_or_stereo_dirty || config.embedded_buffer_dirty) { |
| 151 | config.mono_or_stereo_dirty.Assign(0); | 158 | config.mono_or_stereo_dirty.Assign(0); |
| 152 | state.mono_or_stereo = config.mono_or_stereo; | 159 | state.mono_or_stereo = config.mono_or_stereo; |
| 153 | LOG_TRACE(Audio_DSP, "source_id=%zu mono_or_stereo=%zu", source_id, static_cast<size_t>(state.mono_or_stereo)); | 160 | LOG_TRACE(Audio_DSP, "source_id=%zu mono_or_stereo=%zu", source_id, |
| 161 | static_cast<size_t>(state.mono_or_stereo)); | ||
| 154 | } | 162 | } |
| 155 | 163 | ||
| 156 | if (config.embedded_buffer_dirty) { | 164 | if (config.embedded_buffer_dirty) { |
| 157 | config.embedded_buffer_dirty.Assign(0); | 165 | config.embedded_buffer_dirty.Assign(0); |
| 158 | state.input_queue.emplace(Buffer{ | 166 | state.input_queue.emplace(Buffer{config.physical_address, |
| 159 | config.physical_address, | 167 | config.length, |
| 160 | config.length, | 168 | static_cast<u8>(config.adpcm_ps), |
| 161 | static_cast<u8>(config.adpcm_ps), | 169 | {config.adpcm_yn[0], config.adpcm_yn[1]}, |
| 162 | { config.adpcm_yn[0], config.adpcm_yn[1] }, | 170 | config.adpcm_dirty.ToBool(), |
| 163 | config.adpcm_dirty.ToBool(), | 171 | config.is_looping.ToBool(), |
| 164 | config.is_looping.ToBool(), | 172 | config.buffer_id, |
| 165 | config.buffer_id, | 173 | state.mono_or_stereo, |
| 166 | state.mono_or_stereo, | 174 | state.format, |
| 167 | state.format, | 175 | false}); |
| 168 | false | 176 | LOG_TRACE(Audio_DSP, "enqueuing embedded addr=0x%08x len=%u id=%hu", |
| 169 | }); | 177 | config.physical_address, config.length, config.buffer_id); |
| 170 | LOG_TRACE(Audio_DSP, "enqueuing embedded addr=0x%08x len=%u id=%hu", config.physical_address, config.length, config.buffer_id); | ||
| 171 | } | 178 | } |
| 172 | 179 | ||
| 173 | if (config.buffer_queue_dirty) { | 180 | if (config.buffer_queue_dirty) { |
| @@ -175,19 +182,18 @@ void Source::ParseConfig(SourceConfiguration::Configuration& config, const s16_l | |||
| 175 | for (size_t i = 0; i < 4; i++) { | 182 | for (size_t i = 0; i < 4; i++) { |
| 176 | if (config.buffers_dirty & (1 << i)) { | 183 | if (config.buffers_dirty & (1 << i)) { |
| 177 | const auto& b = config.buffers[i]; | 184 | const auto& b = config.buffers[i]; |
| 178 | state.input_queue.emplace(Buffer{ | 185 | state.input_queue.emplace(Buffer{b.physical_address, |
| 179 | b.physical_address, | 186 | b.length, |
| 180 | b.length, | 187 | static_cast<u8>(b.adpcm_ps), |
| 181 | static_cast<u8>(b.adpcm_ps), | 188 | {b.adpcm_yn[0], b.adpcm_yn[1]}, |
| 182 | { b.adpcm_yn[0], b.adpcm_yn[1] }, | 189 | b.adpcm_dirty != 0, |
| 183 | b.adpcm_dirty != 0, | 190 | b.is_looping != 0, |
| 184 | b.is_looping != 0, | 191 | b.buffer_id, |
| 185 | b.buffer_id, | 192 | state.mono_or_stereo, |
| 186 | state.mono_or_stereo, | 193 | state.format, |
| 187 | state.format, | 194 | true}); |
| 188 | true | 195 | LOG_TRACE(Audio_DSP, "enqueuing queued %zu addr=0x%08x len=%u id=%hu", i, |
| 189 | }); | 196 | b.physical_address, b.length, b.buffer_id); |
| 190 | LOG_TRACE(Audio_DSP, "enqueuing queued %zu addr=0x%08x len=%u id=%hu", i, b.physical_address, b.length, b.buffer_id); | ||
| 191 | } | 197 | } |
| 192 | } | 198 | } |
| 193 | config.buffers_dirty = 0; | 199 | config.buffers_dirty = 0; |
| @@ -218,10 +224,13 @@ void Source::GenerateFrame() { | |||
| 218 | break; | 224 | break; |
| 219 | } | 225 | } |
| 220 | 226 | ||
| 221 | const size_t size_to_copy = std::min(state.current_buffer.size(), current_frame.size() - frame_position); | 227 | const size_t size_to_copy = |
| 228 | std::min(state.current_buffer.size(), current_frame.size() - frame_position); | ||
| 222 | 229 | ||
| 223 | std::copy(state.current_buffer.begin(), state.current_buffer.begin() + size_to_copy, current_frame.begin() + frame_position); | 230 | std::copy(state.current_buffer.begin(), state.current_buffer.begin() + size_to_copy, |
| 224 | state.current_buffer.erase(state.current_buffer.begin(), state.current_buffer.begin() + size_to_copy); | 231 | current_frame.begin() + frame_position); |
| 232 | state.current_buffer.erase(state.current_buffer.begin(), | ||
| 233 | state.current_buffer.begin() + size_to_copy); | ||
| 225 | 234 | ||
| 226 | frame_position += size_to_copy; | 235 | frame_position += size_to_copy; |
| 227 | state.next_sample_number += static_cast<u32>(size_to_copy); | 236 | state.next_sample_number += static_cast<u32>(size_to_copy); |
| @@ -230,9 +239,9 @@ void Source::GenerateFrame() { | |||
| 230 | state.filters.ProcessFrame(current_frame); | 239 | state.filters.ProcessFrame(current_frame); |
| 231 | } | 240 | } |
| 232 | 241 | ||
| 233 | |||
| 234 | bool Source::DequeueBuffer() { | 242 | bool Source::DequeueBuffer() { |
| 235 | ASSERT_MSG(state.current_buffer.empty(), "Shouldn't dequeue; we still have data in current_buffer"); | 243 | ASSERT_MSG(state.current_buffer.empty(), |
| 244 | "Shouldn't dequeue; we still have data in current_buffer"); | ||
| 236 | 245 | ||
| 237 | if (state.input_queue.empty()) | 246 | if (state.input_queue.empty()) |
| 238 | return false; | 247 | return false; |
| @@ -261,29 +270,34 @@ bool Source::DequeueBuffer() { | |||
| 261 | break; | 270 | break; |
| 262 | case Format::ADPCM: | 271 | case Format::ADPCM: |
| 263 | DEBUG_ASSERT(num_channels == 1); | 272 | DEBUG_ASSERT(num_channels == 1); |
| 264 | state.current_buffer = Codec::DecodeADPCM(memory, buf.length, state.adpcm_coeffs, state.adpcm_state); | 273 | state.current_buffer = |
| 274 | Codec::DecodeADPCM(memory, buf.length, state.adpcm_coeffs, state.adpcm_state); | ||
| 265 | break; | 275 | break; |
| 266 | default: | 276 | default: |
| 267 | UNIMPLEMENTED(); | 277 | UNIMPLEMENTED(); |
| 268 | break; | 278 | break; |
| 269 | } | 279 | } |
| 270 | } else { | 280 | } else { |
| 271 | LOG_WARNING(Audio_DSP, "source_id=%zu buffer_id=%hu length=%u: Invalid physical address 0x%08X", | 281 | LOG_WARNING(Audio_DSP, |
| 272 | source_id, buf.buffer_id, buf.length, buf.physical_address); | 282 | "source_id=%zu buffer_id=%hu length=%u: Invalid physical address 0x%08X", |
| 283 | source_id, buf.buffer_id, buf.length, buf.physical_address); | ||
| 273 | state.current_buffer.clear(); | 284 | state.current_buffer.clear(); |
| 274 | return true; | 285 | return true; |
| 275 | } | 286 | } |
| 276 | 287 | ||
| 277 | switch (state.interpolation_mode) { | 288 | switch (state.interpolation_mode) { |
| 278 | case InterpolationMode::None: | 289 | case InterpolationMode::None: |
| 279 | state.current_buffer = AudioInterp::None(state.interp_state, state.current_buffer, state.rate_multiplier); | 290 | state.current_buffer = |
| 291 | AudioInterp::None(state.interp_state, state.current_buffer, state.rate_multiplier); | ||
| 280 | break; | 292 | break; |
| 281 | case InterpolationMode::Linear: | 293 | case InterpolationMode::Linear: |
| 282 | state.current_buffer = AudioInterp::Linear(state.interp_state, state.current_buffer, state.rate_multiplier); | 294 | state.current_buffer = |
| 295 | AudioInterp::Linear(state.interp_state, state.current_buffer, state.rate_multiplier); | ||
| 283 | break; | 296 | break; |
| 284 | case InterpolationMode::Polyphase: | 297 | case InterpolationMode::Polyphase: |
| 285 | // TODO(merry): Implement polyphase interpolation | 298 | // TODO(merry): Implement polyphase interpolation |
| 286 | state.current_buffer = AudioInterp::Linear(state.interp_state, state.current_buffer, state.rate_multiplier); | 299 | state.current_buffer = |
| 300 | AudioInterp::Linear(state.interp_state, state.current_buffer, state.rate_multiplier); | ||
| 287 | break; | 301 | break; |
| 288 | default: | 302 | default: |
| 289 | UNIMPLEMENTED(); | 303 | UNIMPLEMENTED(); |
| @@ -296,7 +310,8 @@ bool Source::DequeueBuffer() { | |||
| 296 | state.buffer_update = buf.from_queue; | 310 | state.buffer_update = buf.from_queue; |
| 297 | 311 | ||
| 298 | LOG_TRACE(Audio_DSP, "source_id=%zu buffer_id=%hu from_queue=%s current_buffer.size()=%zu", | 312 | LOG_TRACE(Audio_DSP, "source_id=%zu buffer_id=%hu from_queue=%s current_buffer.size()=%zu", |
| 299 | source_id, buf.buffer_id, buf.from_queue ? "true" : "false", state.current_buffer.size()); | 313 | source_id, buf.buffer_id, buf.from_queue ? "true" : "false", |
| 314 | state.current_buffer.size()); | ||
| 300 | return true; | 315 | return true; |
| 301 | } | 316 | } |
| 302 | 317 | ||