diff options
| author | 2020-10-15 14:49:45 -0400 | |
|---|---|---|
| committer | 2020-10-17 19:50:39 -0400 | |
| commit | be1954e04cb5a0c3a526f78ed5490a5e65310280 (patch) | |
| tree | 267db7ae4be88dbbc288fa605e35d4a2a13839f6 /src/audio_core | |
| parent | Merge pull request #4787 from lioncash/conversion (diff) | |
| download | yuzu-be1954e04cb5a0c3a526f78ed5490a5e65310280.tar.gz yuzu-be1954e04cb5a0c3a526f78ed5490a5e65310280.tar.xz yuzu-be1954e04cb5a0c3a526f78ed5490a5e65310280.zip | |
core: Fix clang build
Recent changes to the build system that made more warnings be flagged as
errors caused building via clang to break.
Fixes #4795
Diffstat (limited to 'src/audio_core')
| -rw-r--r-- | src/audio_core/CMakeLists.txt | 5 | ||||
| -rw-r--r-- | src/audio_core/algorithm/interpolate.cpp | 6 | ||||
| -rw-r--r-- | src/audio_core/audio_renderer.cpp | 4 | ||||
| -rw-r--r-- | src/audio_core/codec.cpp | 6 | ||||
| -rw-r--r-- | src/audio_core/command_generator.cpp | 212 | ||||
| -rw-r--r-- | src/audio_core/command_generator.h | 4 | ||||
| -rw-r--r-- | src/audio_core/cubeb_sink.cpp | 2 | ||||
| -rw-r--r-- | src/audio_core/cubeb_sink.h | 2 | ||||
| -rw-r--r-- | src/audio_core/info_updater.cpp | 4 | ||||
| -rw-r--r-- | src/audio_core/mix_context.cpp | 17 | ||||
| -rw-r--r-- | src/audio_core/sink_context.cpp | 5 | ||||
| -rw-r--r-- | src/audio_core/splitter_context.cpp | 60 | ||||
| -rw-r--r-- | src/audio_core/time_stretch.h | 10 | ||||
| -rw-r--r-- | src/audio_core/voice_context.cpp | 47 |
14 files changed, 215 insertions, 169 deletions
diff --git a/src/audio_core/CMakeLists.txt b/src/audio_core/CMakeLists.txt index 54940a034..74c1453aa 100644 --- a/src/audio_core/CMakeLists.txt +++ b/src/audio_core/CMakeLists.txt | |||
| @@ -51,8 +51,9 @@ if (NOT MSVC) | |||
| 51 | -Werror=implicit-fallthrough | 51 | -Werror=implicit-fallthrough |
| 52 | -Werror=reorder | 52 | -Werror=reorder |
| 53 | -Werror=sign-compare | 53 | -Werror=sign-compare |
| 54 | -Werror=unused-but-set-parameter | 54 | -Werror=sign-conversion |
| 55 | -Werror=unused-but-set-variable | 55 | $<$<CXX_COMPILER_ID:GNU>:-Werror=unused-but-set-parameter> |
| 56 | $<$<CXX_COMPILER_ID:GNU>:-Werror=unused-but-set-variable> | ||
| 56 | -Werror=unused-variable | 57 | -Werror=unused-variable |
| 57 | ) | 58 | ) |
| 58 | endif() | 59 | endif() |
diff --git a/src/audio_core/algorithm/interpolate.cpp b/src/audio_core/algorithm/interpolate.cpp index 699fcb84c..587ee5b7b 100644 --- a/src/audio_core/algorithm/interpolate.cpp +++ b/src/audio_core/algorithm/interpolate.cpp | |||
| @@ -167,8 +167,8 @@ std::vector<s16> Interpolate(InterpolationState& state, std::vector<s16> input, | |||
| 167 | output.reserve(static_cast<std::size_t>(static_cast<double>(input.size()) / ratio + | 167 | output.reserve(static_cast<std::size_t>(static_cast<double>(input.size()) / ratio + |
| 168 | InterpolationState::taps)); | 168 | InterpolationState::taps)); |
| 169 | 169 | ||
| 170 | for (std::size_t frame{}; frame < num_frames; ++frame) { | 170 | for (std::size_t frame = 0; frame < num_frames; ++frame) { |
| 171 | const std::size_t lut_index{(state.fraction >> 8) * InterpolationState::taps}; | 171 | const auto lut_index{static_cast<size_t>(state.fraction >> 8) * InterpolationState::taps}; |
| 172 | 172 | ||
| 173 | std::rotate(state.history.begin(), state.history.end() - 1, state.history.end()); | 173 | std::rotate(state.history.begin(), state.history.end() - 1, state.history.end()); |
| 174 | state.history[0][0] = input[frame * 2 + 0]; | 174 | state.history[0][0] = input[frame * 2 + 0]; |
| @@ -225,7 +225,7 @@ void Resample(s32* output, const s32* input, s32 pitch, s32& fraction, std::size | |||
| 225 | 225 | ||
| 226 | output[i] = (l0 * s0 + l1 * s1 + l2 * s2 + l3 * s3) >> 15; | 226 | output[i] = (l0 * s0 + l1 * s1 + l2 * s2 + l3 * s3) >> 15; |
| 227 | fraction += pitch; | 227 | fraction += pitch; |
| 228 | index += (fraction >> 15); | 228 | index += static_cast<size_t>(fraction >> 15); |
| 229 | fraction &= 0x7fff; | 229 | fraction &= 0x7fff; |
| 230 | } | 230 | } |
| 231 | } | 231 | } |
diff --git a/src/audio_core/audio_renderer.cpp b/src/audio_core/audio_renderer.cpp index a7e851bb8..094bace9c 100644 --- a/src/audio_core/audio_renderer.cpp +++ b/src/audio_core/audio_renderer.cpp | |||
| @@ -187,8 +187,8 @@ void AudioRenderer::QueueMixedBuffer(Buffer::Tag tag) { | |||
| 187 | const auto& in_params = final_mix.GetInParams(); | 187 | const auto& in_params = final_mix.GetInParams(); |
| 188 | std::vector<s32*> mix_buffers(channel_count); | 188 | std::vector<s32*> mix_buffers(channel_count); |
| 189 | for (std::size_t i = 0; i < channel_count; i++) { | 189 | for (std::size_t i = 0; i < channel_count; i++) { |
| 190 | mix_buffers[i] = | 190 | mix_buffers[i] = command_generator.GetMixBuffer( |
| 191 | command_generator.GetMixBuffer(in_params.buffer_offset + buffer_offsets[i]); | 191 | static_cast<u32>(in_params.buffer_offset) + buffer_offsets[i]); |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | for (std::size_t i = 0; i < BUFFER_SIZE; i++) { | 194 | for (std::size_t i = 0; i < BUFFER_SIZE; i++) { |
diff --git a/src/audio_core/codec.cpp b/src/audio_core/codec.cpp index 2fb91c13a..d89f94ea2 100644 --- a/src/audio_core/codec.cpp +++ b/src/audio_core/codec.cpp | |||
| @@ -32,7 +32,7 @@ std::vector<s16> DecodeADPCM(const u8* const data, std::size_t size, const ADPCM | |||
| 32 | for (std::size_t framei = 0; framei < NUM_FRAMES; framei++) { | 32 | for (std::size_t framei = 0; framei < NUM_FRAMES; framei++) { |
| 33 | const int frame_header = data[framei * FRAME_LEN]; | 33 | const int frame_header = data[framei * FRAME_LEN]; |
| 34 | const int scale = 1 << (frame_header & 0xF); | 34 | const int scale = 1 << (frame_header & 0xF); |
| 35 | const int idx = (frame_header >> 4) & 0x7; | 35 | const auto idx = static_cast<size_t>((frame_header >> 4) & 0x7); |
| 36 | 36 | ||
| 37 | // Coefficients are fixed point with 11 bits fractional part. | 37 | // Coefficients are fixed point with 11 bits fractional part. |
| 38 | const int coef1 = coeff[idx * 2 + 0]; | 38 | const int coef1 = coeff[idx * 2 + 0]; |
| @@ -57,11 +57,11 @@ std::vector<s16> DecodeADPCM(const u8* const data, std::size_t size, const ADPCM | |||
| 57 | std::size_t outputi = framei * SAMPLES_PER_FRAME; | 57 | std::size_t outputi = framei * SAMPLES_PER_FRAME; |
| 58 | std::size_t datai = framei * FRAME_LEN + 1; | 58 | std::size_t datai = framei * FRAME_LEN + 1; |
| 59 | for (std::size_t i = 0; i < SAMPLES_PER_FRAME && outputi < sample_count; i += 2) { | 59 | for (std::size_t i = 0; i < SAMPLES_PER_FRAME && outputi < sample_count; i += 2) { |
| 60 | const s16 sample1 = decode_sample(SIGNED_NIBBLES[data[datai] >> 4]); | 60 | const s16 sample1 = decode_sample(SIGNED_NIBBLES[static_cast<u32>(data[datai] >> 4)]); |
| 61 | ret[outputi] = sample1; | 61 | ret[outputi] = sample1; |
| 62 | outputi++; | 62 | outputi++; |
| 63 | 63 | ||
| 64 | const s16 sample2 = decode_sample(SIGNED_NIBBLES[data[datai] & 0xF]); | 64 | const s16 sample2 = decode_sample(SIGNED_NIBBLES[static_cast<u32>(data[datai] & 0xF)]); |
| 65 | ret[outputi] = sample2; | 65 | ret[outputi] = sample2; |
| 66 | outputi++; | 66 | outputi++; |
| 67 | 67 | ||
diff --git a/src/audio_core/command_generator.cpp b/src/audio_core/command_generator.cpp index fb8700ccf..c0edb625d 100644 --- a/src/audio_core/command_generator.cpp +++ b/src/audio_core/command_generator.cpp | |||
| @@ -15,8 +15,8 @@ constexpr std::size_t MIX_BUFFER_SIZE = 0x3f00; | |||
| 15 | constexpr std::size_t SCALED_MIX_BUFFER_SIZE = MIX_BUFFER_SIZE << 15ULL; | 15 | constexpr std::size_t SCALED_MIX_BUFFER_SIZE = MIX_BUFFER_SIZE << 15ULL; |
| 16 | 16 | ||
| 17 | template <std::size_t N> | 17 | template <std::size_t N> |
| 18 | void ApplyMix(s32* output, const s32* input, s32 gain, s32 sample_count) { | 18 | void ApplyMix(s32* output, const s32* input, s32 gain, std::size_t sample_count) { |
| 19 | for (std::size_t i = 0; i < static_cast<std::size_t>(sample_count); i += N) { | 19 | for (std::size_t i = 0; i < sample_count; i += N) { |
| 20 | for (std::size_t j = 0; j < N; j++) { | 20 | for (std::size_t j = 0; j < N; j++) { |
| 21 | output[i + j] += | 21 | output[i + j] += |
| 22 | static_cast<s32>((static_cast<s64>(input[i + j]) * gain + 0x4000) >> 15); | 22 | static_cast<s32>((static_cast<s64>(input[i + j]) * gain + 0x4000) >> 15); |
| @@ -111,7 +111,8 @@ void CommandGenerator::GenerateVoiceCommand(ServerVoiceInfo& voice_info) { | |||
| 111 | const auto channel_count = in_params.channel_count; | 111 | const auto channel_count = in_params.channel_count; |
| 112 | 112 | ||
| 113 | for (s32 channel = 0; channel < channel_count; channel++) { | 113 | for (s32 channel = 0; channel < channel_count; channel++) { |
| 114 | const auto resource_id = in_params.voice_channel_resource_id[channel]; | 114 | const auto resource_id = |
| 115 | static_cast<u32>(in_params.voice_channel_resource_id[static_cast<u32>(channel)]); | ||
| 115 | auto& dsp_state = voice_context.GetDspSharedState(resource_id); | 116 | auto& dsp_state = voice_context.GetDspSharedState(resource_id); |
| 116 | auto& channel_resource = voice_context.GetChannelResource(resource_id); | 117 | auto& channel_resource = voice_context.GetChannelResource(resource_id); |
| 117 | 118 | ||
| @@ -132,14 +133,15 @@ void CommandGenerator::GenerateVoiceCommand(ServerVoiceInfo& voice_info) { | |||
| 132 | 133 | ||
| 133 | if (in_params.mix_id != AudioCommon::NO_MIX) { | 134 | if (in_params.mix_id != AudioCommon::NO_MIX) { |
| 134 | // If we're using a mix id | 135 | // If we're using a mix id |
| 135 | auto& mix_info = mix_context.GetInfo(in_params.mix_id); | 136 | auto& mix_info = mix_context.GetInfo(static_cast<u32>(in_params.mix_id)); |
| 136 | const auto& dest_mix_params = mix_info.GetInParams(); | 137 | const auto& dest_mix_params = mix_info.GetInParams(); |
| 137 | 138 | ||
| 138 | // Voice Mixing | 139 | // Voice Mixing |
| 139 | GenerateVoiceMixCommand( | 140 | GenerateVoiceMixCommand( |
| 140 | channel_resource.GetCurrentMixVolume(), channel_resource.GetLastMixVolume(), | 141 | channel_resource.GetCurrentMixVolume(), channel_resource.GetLastMixVolume(), |
| 141 | dsp_state, dest_mix_params.buffer_offset, dest_mix_params.buffer_count, | 142 | dsp_state, static_cast<u32>(dest_mix_params.buffer_offset), |
| 142 | worker_params.mix_buffer_count + channel, in_params.node_id); | 143 | static_cast<u32>(dest_mix_params.buffer_count), |
| 144 | worker_params.mix_buffer_count + static_cast<u32>(channel), in_params.node_id); | ||
| 143 | 145 | ||
| 144 | // Update last mix volumes | 146 | // Update last mix volumes |
| 145 | channel_resource.UpdateLastMixVolumes(); | 147 | channel_resource.UpdateLastMixVolumes(); |
| @@ -156,12 +158,15 @@ void CommandGenerator::GenerateVoiceCommand(ServerVoiceInfo& voice_info) { | |||
| 156 | continue; | 158 | continue; |
| 157 | } | 159 | } |
| 158 | 160 | ||
| 159 | const auto& mix_info = mix_context.GetInfo(destination_data->GetMixId()); | 161 | const auto& mix_info = |
| 162 | mix_context.GetInfo(static_cast<u32>(destination_data->GetMixId())); | ||
| 160 | const auto& dest_mix_params = mix_info.GetInParams(); | 163 | const auto& dest_mix_params = mix_info.GetInParams(); |
| 161 | GenerateVoiceMixCommand( | 164 | GenerateVoiceMixCommand( |
| 162 | destination_data->CurrentMixVolumes(), destination_data->LastMixVolumes(), | 165 | destination_data->CurrentMixVolumes(), destination_data->LastMixVolumes(), |
| 163 | dsp_state, dest_mix_params.buffer_offset, dest_mix_params.buffer_count, | 166 | dsp_state, static_cast<u32>(dest_mix_params.buffer_offset), |
| 164 | worker_params.mix_buffer_count + channel, in_params.node_id); | 167 | static_cast<u32>(dest_mix_params.buffer_count), |
| 168 | worker_params.mix_buffer_count + static_cast<u32>(channel), | ||
| 169 | in_params.node_id); | ||
| 165 | destination_data->MarkDirty(); | 170 | destination_data->MarkDirty(); |
| 166 | } | 171 | } |
| 167 | } | 172 | } |
| @@ -219,9 +224,10 @@ void CommandGenerator::GenerateDataSourceCommand(ServerVoiceInfo& voice_info, Vo | |||
| 219 | 224 | ||
| 220 | if (depop) { | 225 | if (depop) { |
| 221 | if (in_params.mix_id != AudioCommon::NO_MIX) { | 226 | if (in_params.mix_id != AudioCommon::NO_MIX) { |
| 222 | auto& mix_info = mix_context.GetInfo(in_params.mix_id); | 227 | auto& mix_info = mix_context.GetInfo(static_cast<u32>(in_params.mix_id)); |
| 223 | const auto& mix_in = mix_info.GetInParams(); | 228 | const auto& mix_in = mix_info.GetInParams(); |
| 224 | GenerateDepopPrepareCommand(dsp_state, mix_in.buffer_count, mix_in.buffer_offset); | 229 | GenerateDepopPrepareCommand(dsp_state, static_cast<u32>(mix_in.buffer_count), |
| 230 | static_cast<u32>(mix_in.buffer_offset)); | ||
| 225 | } else if (in_params.splitter_info_id != AudioCommon::NO_SPLITTER) { | 231 | } else if (in_params.splitter_info_id != AudioCommon::NO_SPLITTER) { |
| 226 | s32 index{}; | 232 | s32 index{}; |
| 227 | while (const auto* destination = | 233 | while (const auto* destination = |
| @@ -229,23 +235,24 @@ void CommandGenerator::GenerateDataSourceCommand(ServerVoiceInfo& voice_info, Vo | |||
| 229 | if (!destination->IsConfigured()) { | 235 | if (!destination->IsConfigured()) { |
| 230 | continue; | 236 | continue; |
| 231 | } | 237 | } |
| 232 | auto& mix_info = mix_context.GetInfo(destination->GetMixId()); | 238 | auto& mix_info = mix_context.GetInfo(static_cast<u32>(destination->GetMixId())); |
| 233 | const auto& mix_in = mix_info.GetInParams(); | 239 | const auto& mix_in = mix_info.GetInParams(); |
| 234 | GenerateDepopPrepareCommand(dsp_state, mix_in.buffer_count, mix_in.buffer_offset); | 240 | GenerateDepopPrepareCommand(dsp_state, static_cast<u32>(mix_in.buffer_count), |
| 241 | static_cast<u32>(mix_in.buffer_offset)); | ||
| 235 | } | 242 | } |
| 236 | } | 243 | } |
| 237 | } else { | 244 | } else { |
| 238 | switch (in_params.sample_format) { | 245 | switch (in_params.sample_format) { |
| 239 | case SampleFormat::Pcm16: | 246 | case SampleFormat::Pcm16: |
| 240 | DecodeFromWaveBuffers(voice_info, GetChannelMixBuffer(channel), dsp_state, channel, | 247 | DecodeFromWaveBuffers(voice_info, GetChannelMixBuffer(channel), dsp_state, channel, |
| 241 | worker_params.sample_rate, worker_params.sample_count, | 248 | static_cast<s32>(worker_params.sample_rate), |
| 242 | in_params.node_id); | 249 | static_cast<s32>(worker_params.sample_count), in_params.node_id); |
| 243 | break; | 250 | break; |
| 244 | case SampleFormat::Adpcm: | 251 | case SampleFormat::Adpcm: |
| 245 | ASSERT(channel == 0 && in_params.channel_count == 1); | 252 | ASSERT(channel == 0 && in_params.channel_count == 1); |
| 246 | DecodeFromWaveBuffers(voice_info, GetChannelMixBuffer(0), dsp_state, 0, | 253 | DecodeFromWaveBuffers(voice_info, GetChannelMixBuffer(0), dsp_state, 0, |
| 247 | worker_params.sample_rate, worker_params.sample_count, | 254 | static_cast<s32>(worker_params.sample_rate), |
| 248 | in_params.node_id); | 255 | static_cast<s32>(worker_params.sample_count), in_params.node_id); |
| 249 | break; | 256 | break; |
| 250 | default: | 257 | default: |
| 251 | UNREACHABLE_MSG("Unimplemented sample format={}", in_params.sample_format); | 258 | UNREACHABLE_MSG("Unimplemented sample format={}", in_params.sample_format); |
| @@ -255,7 +262,7 @@ void CommandGenerator::GenerateDataSourceCommand(ServerVoiceInfo& voice_info, Vo | |||
| 255 | 262 | ||
| 256 | void CommandGenerator::GenerateBiquadFilterCommandForVoice(ServerVoiceInfo& voice_info, | 263 | void CommandGenerator::GenerateBiquadFilterCommandForVoice(ServerVoiceInfo& voice_info, |
| 257 | VoiceState& dsp_state, | 264 | VoiceState& dsp_state, |
| 258 | s32 mix_buffer_count, s32 channel) { | 265 | u32 mix_buffer_count, s32 channel) { |
| 259 | for (std::size_t i = 0; i < AudioCommon::MAX_BIQUAD_FILTERS; i++) { | 266 | for (std::size_t i = 0; i < AudioCommon::MAX_BIQUAD_FILTERS; i++) { |
| 260 | const auto& in_params = voice_info.GetInParams(); | 267 | const auto& in_params = voice_info.GetInParams(); |
| 261 | auto& biquad_filter = in_params.biquad_filter[i]; | 268 | auto& biquad_filter = in_params.biquad_filter[i]; |
| @@ -335,8 +342,8 @@ void CommandGenerator::GenerateDepopForMixBuffersCommand(std::size_t mix_buffer_ | |||
| 335 | continue; | 342 | continue; |
| 336 | } | 343 | } |
| 337 | 344 | ||
| 338 | depop_buffer[i] = | 345 | depop_buffer[i] = ApplyMixDepop(GetMixBuffer(i), depop_buffer[i], delta, |
| 339 | ApplyMixDepop(GetMixBuffer(i), depop_buffer[i], delta, worker_params.sample_count); | 346 | static_cast<s32>(worker_params.sample_count)); |
| 340 | } | 347 | } |
| 341 | } | 348 | } |
| 342 | 349 | ||
| @@ -348,7 +355,7 @@ void CommandGenerator::GenerateEffectCommand(ServerMixInfo& mix_info) { | |||
| 348 | if (index == AudioCommon::NO_EFFECT_ORDER) { | 355 | if (index == AudioCommon::NO_EFFECT_ORDER) { |
| 349 | break; | 356 | break; |
| 350 | } | 357 | } |
| 351 | auto* info = effect_context.GetInfo(index); | 358 | auto* info = effect_context.GetInfo(static_cast<u32>(index)); |
| 352 | const auto type = info->GetType(); | 359 | const auto type = info->GetType(); |
| 353 | 360 | ||
| 354 | // TODO(ogniK): Finish remaining effects | 361 | // TODO(ogniK): Finish remaining effects |
| @@ -377,11 +384,11 @@ void CommandGenerator::GenerateI3dl2ReverbEffectCommand(s32 mix_buffer_offset, E | |||
| 377 | } | 384 | } |
| 378 | const auto& params = dynamic_cast<EffectI3dl2Reverb*>(info)->GetParams(); | 385 | const auto& params = dynamic_cast<EffectI3dl2Reverb*>(info)->GetParams(); |
| 379 | const auto channel_count = params.channel_count; | 386 | const auto channel_count = params.channel_count; |
| 380 | for (s32 i = 0; i < channel_count; i++) { | 387 | for (size_t i = 0; i < channel_count; i++) { |
| 381 | // TODO(ogniK): Actually implement reverb | 388 | // TODO(ogniK): Actually implement reverb |
| 382 | if (params.input[i] != params.output[i]) { | 389 | if (params.input[i] != params.output[i]) { |
| 383 | const auto* input = GetMixBuffer(mix_buffer_offset + params.input[i]); | 390 | const auto* input = GetMixBuffer(static_cast<u32>(mix_buffer_offset + params.input[i])); |
| 384 | auto* output = GetMixBuffer(mix_buffer_offset + params.output[i]); | 391 | auto* output = GetMixBuffer(static_cast<u32>(mix_buffer_offset + params.output[i])); |
| 385 | ApplyMix<1>(output, input, 32768, worker_params.sample_count); | 392 | ApplyMix<1>(output, input, 32768, worker_params.sample_count); |
| 386 | } | 393 | } |
| 387 | } | 394 | } |
| @@ -392,13 +399,14 @@ void CommandGenerator::GenerateBiquadFilterEffectCommand(s32 mix_buffer_offset, | |||
| 392 | if (!enabled) { | 399 | if (!enabled) { |
| 393 | return; | 400 | return; |
| 394 | } | 401 | } |
| 402 | |||
| 395 | const auto& params = dynamic_cast<EffectBiquadFilter*>(info)->GetParams(); | 403 | const auto& params = dynamic_cast<EffectBiquadFilter*>(info)->GetParams(); |
| 396 | const auto channel_count = params.channel_count; | 404 | const auto channel_count = static_cast<u32>(params.channel_count); |
| 397 | for (s32 i = 0; i < channel_count; i++) { | 405 | for (size_t i = 0; i < channel_count; i++) { |
| 398 | // TODO(ogniK): Actually implement biquad filter | 406 | // TODO(ogniK): Actually implement biquad filter |
| 399 | if (params.input[i] != params.output[i]) { | 407 | if (params.input[i] != params.output[i]) { |
| 400 | const auto* input = GetMixBuffer(mix_buffer_offset + params.input[i]); | 408 | const auto* input = GetMixBuffer(static_cast<u32>(mix_buffer_offset + params.input[i])); |
| 401 | auto* output = GetMixBuffer(mix_buffer_offset + params.output[i]); | 409 | auto* output = GetMixBuffer(static_cast<u32>(mix_buffer_offset + params.output[i])); |
| 402 | ApplyMix<1>(output, input, 32768, worker_params.sample_count); | 410 | ApplyMix<1>(output, input, 32768, worker_params.sample_count); |
| 403 | } | 411 | } |
| 404 | } | 412 | } |
| @@ -425,26 +433,30 @@ void CommandGenerator::GenerateAuxCommand(s32 mix_buffer_offset, EffectBase* inf | |||
| 425 | memory.ReadBlock(aux->GetSendInfo(), &send_info, sizeof(AuxInfoDSP)); | 433 | memory.ReadBlock(aux->GetSendInfo(), &send_info, sizeof(AuxInfoDSP)); |
| 426 | memory.ReadBlock(aux->GetRecvInfo(), &recv_info, sizeof(AuxInfoDSP)); | 434 | memory.ReadBlock(aux->GetRecvInfo(), &recv_info, sizeof(AuxInfoDSP)); |
| 427 | 435 | ||
| 428 | WriteAuxBuffer(send_info, aux->GetSendBuffer(), params.sample_count, | 436 | WriteAuxBuffer(send_info, aux->GetSendBuffer(), |
| 429 | GetMixBuffer(input_index), worker_params.sample_count, offset, | 437 | static_cast<u32>(params.sample_count), |
| 430 | write_count); | 438 | GetMixBuffer(static_cast<u32>(input_index)), |
| 439 | worker_params.sample_count, offset, write_count); | ||
| 431 | memory.WriteBlock(aux->GetSendInfo(), &send_info, sizeof(AuxInfoDSP)); | 440 | memory.WriteBlock(aux->GetSendInfo(), &send_info, sizeof(AuxInfoDSP)); |
| 432 | 441 | ||
| 433 | const auto samples_read = ReadAuxBuffer( | 442 | const auto samples_read = ReadAuxBuffer( |
| 434 | recv_info, aux->GetRecvBuffer(), params.sample_count, | 443 | recv_info, aux->GetRecvBuffer(), static_cast<u32>(params.sample_count), |
| 435 | GetMixBuffer(output_index), worker_params.sample_count, offset, write_count); | 444 | GetMixBuffer(static_cast<u32>(output_index)), worker_params.sample_count, |
| 445 | offset, write_count); | ||
| 436 | memory.WriteBlock(aux->GetRecvInfo(), &recv_info, sizeof(AuxInfoDSP)); | 446 | memory.WriteBlock(aux->GetRecvInfo(), &recv_info, sizeof(AuxInfoDSP)); |
| 437 | 447 | ||
| 438 | if (samples_read != static_cast<int>(worker_params.sample_count) && | 448 | if (samples_read != static_cast<int>(worker_params.sample_count) && |
| 439 | samples_read <= params.sample_count) { | 449 | samples_read <= params.sample_count) { |
| 440 | std::memset(GetMixBuffer(output_index), 0, params.sample_count - samples_read); | 450 | std::memset(GetMixBuffer(static_cast<u32>(output_index)), 0, |
| 451 | static_cast<size_t>(params.sample_count - samples_read)); | ||
| 441 | } | 452 | } |
| 442 | } else { | 453 | } else { |
| 443 | AuxInfoDSP empty{}; | 454 | AuxInfoDSP empty{}; |
| 444 | memory.WriteBlock(aux->GetSendInfo(), &empty, sizeof(AuxInfoDSP)); | 455 | memory.WriteBlock(aux->GetSendInfo(), &empty, sizeof(AuxInfoDSP)); |
| 445 | memory.WriteBlock(aux->GetRecvInfo(), &empty, sizeof(AuxInfoDSP)); | 456 | memory.WriteBlock(aux->GetRecvInfo(), &empty, sizeof(AuxInfoDSP)); |
| 446 | if (output_index != input_index) { | 457 | if (output_index != input_index) { |
| 447 | std::memcpy(GetMixBuffer(output_index), GetMixBuffer(input_index), | 458 | std::memcpy(GetMixBuffer(static_cast<u32>(output_index)), |
| 459 | GetMixBuffer(static_cast<u32>(input_index)), | ||
| 448 | worker_params.sample_count * sizeof(s32)); | 460 | worker_params.sample_count * sizeof(s32)); |
| 449 | } | 461 | } |
| 450 | } | 462 | } |
| @@ -458,7 +470,8 @@ ServerSplitterDestinationData* CommandGenerator::GetDestinationData(s32 splitter | |||
| 458 | if (splitter_id == AudioCommon::NO_SPLITTER) { | 470 | if (splitter_id == AudioCommon::NO_SPLITTER) { |
| 459 | return nullptr; | 471 | return nullptr; |
| 460 | } | 472 | } |
| 461 | return splitter_context.GetDestinationData(splitter_id, index); | 473 | return splitter_context.GetDestinationData(static_cast<u32>(splitter_id), |
| 474 | static_cast<u32>(index)); | ||
| 462 | } | 475 | } |
| 463 | 476 | ||
| 464 | s32 CommandGenerator::WriteAuxBuffer(AuxInfoDSP& dsp_info, VAddr send_buffer, u32 max_samples, | 477 | s32 CommandGenerator::WriteAuxBuffer(AuxInfoDSP& dsp_info, VAddr send_buffer, u32 max_samples, |
| @@ -488,7 +501,7 @@ s32 CommandGenerator::WriteAuxBuffer(AuxInfoDSP& dsp_info, VAddr send_buffer, u3 | |||
| 488 | if (write_count != 0) { | 501 | if (write_count != 0) { |
| 489 | dsp_info.write_offset = (dsp_info.write_offset + write_count) % max_samples; | 502 | dsp_info.write_offset = (dsp_info.write_offset + write_count) % max_samples; |
| 490 | } | 503 | } |
| 491 | return sample_count; | 504 | return static_cast<s32>(sample_count); |
| 492 | } | 505 | } |
| 493 | 506 | ||
| 494 | s32 CommandGenerator::ReadAuxBuffer(AuxInfoDSP& recv_info, VAddr recv_buffer, u32 max_samples, | 507 | s32 CommandGenerator::ReadAuxBuffer(AuxInfoDSP& recv_info, VAddr recv_buffer, u32 max_samples, |
| @@ -518,7 +531,7 @@ s32 CommandGenerator::ReadAuxBuffer(AuxInfoDSP& recv_info, VAddr recv_buffer, u3 | |||
| 518 | if (read_count != 0) { | 531 | if (read_count != 0) { |
| 519 | recv_info.read_offset = (recv_info.read_offset + read_count) % max_samples; | 532 | recv_info.read_offset = (recv_info.read_offset + read_count) % max_samples; |
| 520 | } | 533 | } |
| 521 | return sample_count; | 534 | return static_cast<s32>(sample_count); |
| 522 | } | 535 | } |
| 523 | 536 | ||
| 524 | void CommandGenerator::GenerateVolumeRampCommand(float last_volume, float current_volume, | 537 | void CommandGenerator::GenerateVolumeRampCommand(float last_volume, float current_volume, |
| @@ -537,15 +550,15 @@ void CommandGenerator::GenerateVolumeRampCommand(float last_volume, float curren | |||
| 537 | } | 550 | } |
| 538 | // Apply generic gain on samples | 551 | // Apply generic gain on samples |
| 539 | ApplyGain(GetChannelMixBuffer(channel), GetChannelMixBuffer(channel), last, delta, | 552 | ApplyGain(GetChannelMixBuffer(channel), GetChannelMixBuffer(channel), last, delta, |
| 540 | worker_params.sample_count); | 553 | static_cast<s32>(worker_params.sample_count)); |
| 541 | } | 554 | } |
| 542 | 555 | ||
| 543 | void CommandGenerator::GenerateVoiceMixCommand(const MixVolumeBuffer& mix_volumes, | 556 | void CommandGenerator::GenerateVoiceMixCommand(const MixVolumeBuffer& mix_volumes, |
| 544 | const MixVolumeBuffer& last_mix_volumes, | 557 | const MixVolumeBuffer& last_mix_volumes, |
| 545 | VoiceState& dsp_state, s32 mix_buffer_offset, | 558 | VoiceState& dsp_state, u32 mix_buffer_offset, |
| 546 | s32 mix_buffer_count, s32 voice_index, s32 node_id) { | 559 | u32 mix_buffer_count, u32 voice_index, s32 node_id) { |
| 547 | // Loop all our mix buffers | 560 | // Loop all our mix buffers |
| 548 | for (s32 i = 0; i < mix_buffer_count; i++) { | 561 | for (size_t i = 0; i < mix_buffer_count; i++) { |
| 549 | if (last_mix_volumes[i] != 0.0f || mix_volumes[i] != 0.0f) { | 562 | if (last_mix_volumes[i] != 0.0f || mix_volumes[i] != 0.0f) { |
| 550 | const auto delta = static_cast<float>((mix_volumes[i] - last_mix_volumes[i])) / | 563 | const auto delta = static_cast<float>((mix_volumes[i] - last_mix_volumes[i])) / |
| 551 | static_cast<float>(worker_params.sample_count); | 564 | static_cast<float>(worker_params.sample_count); |
| @@ -558,9 +571,9 @@ void CommandGenerator::GenerateVoiceMixCommand(const MixVolumeBuffer& mix_volume | |||
| 558 | mix_volumes[i]); | 571 | mix_volumes[i]); |
| 559 | } | 572 | } |
| 560 | 573 | ||
| 561 | dsp_state.previous_samples[i] = | 574 | dsp_state.previous_samples[i] = ApplyMixRamp( |
| 562 | ApplyMixRamp(GetMixBuffer(mix_buffer_offset + i), GetMixBuffer(voice_index), | 575 | GetMixBuffer(mix_buffer_offset + i), GetMixBuffer(voice_index), last_mix_volumes[i], |
| 563 | last_mix_volumes[i], delta, worker_params.sample_count); | 576 | delta, static_cast<s32>(worker_params.sample_count)); |
| 564 | } else { | 577 | } else { |
| 565 | dsp_state.previous_samples[i] = 0; | 578 | dsp_state.previous_samples[i] = 0; |
| 566 | } | 579 | } |
| @@ -572,7 +585,8 @@ void CommandGenerator::GenerateSubMixCommand(ServerMixInfo& mix_info) { | |||
| 572 | LOG_DEBUG(Audio, "(DSP_TRACE) GenerateSubMixCommand"); | 585 | LOG_DEBUG(Audio, "(DSP_TRACE) GenerateSubMixCommand"); |
| 573 | } | 586 | } |
| 574 | const auto& in_params = mix_info.GetInParams(); | 587 | const auto& in_params = mix_info.GetInParams(); |
| 575 | GenerateDepopForMixBuffersCommand(in_params.buffer_count, in_params.buffer_offset, | 588 | GenerateDepopForMixBuffersCommand(static_cast<u32>(in_params.buffer_count), |
| 589 | static_cast<u32>(in_params.buffer_offset), | ||
| 576 | in_params.sample_rate); | 590 | in_params.sample_rate); |
| 577 | 591 | ||
| 578 | GenerateEffectCommand(mix_info); | 592 | GenerateEffectCommand(mix_info); |
| @@ -586,18 +600,18 @@ void CommandGenerator::GenerateMixCommands(ServerMixInfo& mix_info) { | |||
| 586 | } | 600 | } |
| 587 | const auto& in_params = mix_info.GetInParams(); | 601 | const auto& in_params = mix_info.GetInParams(); |
| 588 | if (in_params.dest_mix_id != AudioCommon::NO_MIX) { | 602 | if (in_params.dest_mix_id != AudioCommon::NO_MIX) { |
| 589 | const auto& dest_mix = mix_context.GetInfo(in_params.dest_mix_id); | 603 | const auto& dest_mix = mix_context.GetInfo(static_cast<u32>(in_params.dest_mix_id)); |
| 590 | const auto& dest_in_params = dest_mix.GetInParams(); | 604 | const auto& dest_in_params = dest_mix.GetInParams(); |
| 591 | 605 | ||
| 592 | const auto buffer_count = in_params.buffer_count; | 606 | const auto buffer_count = static_cast<u32>(in_params.buffer_count); |
| 593 | 607 | ||
| 594 | for (s32 i = 0; i < buffer_count; i++) { | 608 | for (u32 i = 0; i < buffer_count; i++) { |
| 595 | for (s32 j = 0; j < dest_in_params.buffer_count; j++) { | 609 | for (u32 j = 0; j < static_cast<u32>(dest_in_params.buffer_count); j++) { |
| 596 | const auto mixed_volume = in_params.volume * in_params.mix_volume[i][j]; | 610 | const auto mixed_volume = in_params.volume * in_params.mix_volume[i][j]; |
| 597 | if (mixed_volume != 0.0f) { | 611 | if (mixed_volume != 0.0f) { |
| 598 | GenerateMixCommand(dest_in_params.buffer_offset + j, | 612 | GenerateMixCommand(static_cast<size_t>(dest_in_params.buffer_offset) + j, |
| 599 | in_params.buffer_offset + i, mixed_volume, | 613 | static_cast<size_t>(in_params.buffer_offset) + i, |
| 600 | in_params.node_id); | 614 | mixed_volume, static_cast<s32>(in_params.node_id)); |
| 601 | } | 615 | } |
| 602 | } | 616 | } |
| 603 | } | 617 | } |
| @@ -608,15 +622,17 @@ void CommandGenerator::GenerateMixCommands(ServerMixInfo& mix_info) { | |||
| 608 | continue; | 622 | continue; |
| 609 | } | 623 | } |
| 610 | 624 | ||
| 611 | const auto& dest_mix = mix_context.GetInfo(destination_data->GetMixId()); | 625 | const auto& dest_mix = |
| 626 | mix_context.GetInfo(static_cast<u32>(destination_data->GetMixId())); | ||
| 612 | const auto& dest_in_params = dest_mix.GetInParams(); | 627 | const auto& dest_in_params = dest_mix.GetInParams(); |
| 613 | const auto mix_index = (base - 1) % in_params.buffer_count + in_params.buffer_offset; | 628 | const auto mix_index = (base - 1) % in_params.buffer_count + in_params.buffer_offset; |
| 614 | for (std::size_t i = 0; i < static_cast<std::size_t>(dest_in_params.buffer_count); | 629 | for (std::size_t i = 0; i < static_cast<std::size_t>(dest_in_params.buffer_count); |
| 615 | i++) { | 630 | i++) { |
| 616 | const auto mixed_volume = in_params.volume * destination_data->GetMixVolume(i); | 631 | const auto mixed_volume = in_params.volume * destination_data->GetMixVolume(i); |
| 617 | if (mixed_volume != 0.0f) { | 632 | if (mixed_volume != 0.0f) { |
| 618 | GenerateMixCommand(dest_in_params.buffer_offset + i, mix_index, mixed_volume, | 633 | GenerateMixCommand(static_cast<size_t>(dest_in_params.buffer_offset) + i, |
| 619 | in_params.node_id); | 634 | static_cast<size_t>(mix_index), mixed_volume, |
| 635 | static_cast<s32>(in_params.node_id)); | ||
| 620 | } | 636 | } |
| 621 | } | 637 | } |
| 622 | } | 638 | } |
| @@ -635,7 +651,8 @@ void CommandGenerator::GenerateMixCommand(std::size_t output_offset, std::size_t | |||
| 635 | auto* output = GetMixBuffer(output_offset); | 651 | auto* output = GetMixBuffer(output_offset); |
| 636 | const auto* input = GetMixBuffer(input_offset); | 652 | const auto* input = GetMixBuffer(input_offset); |
| 637 | 653 | ||
| 638 | const s32 gain = static_cast<s32>(volume * 32768.0f); | 654 | const auto gain = static_cast<s32>(volume * 32768.0f); |
| 655 | |||
| 639 | // Mix with loop unrolling | 656 | // Mix with loop unrolling |
| 640 | if (worker_params.sample_count % 4 == 0) { | 657 | if (worker_params.sample_count % 4 == 0) { |
| 641 | ApplyMix<4>(output, input, gain, worker_params.sample_count); | 658 | ApplyMix<4>(output, input, gain, worker_params.sample_count); |
| @@ -653,7 +670,8 @@ void CommandGenerator::GenerateFinalMixCommand() { | |||
| 653 | auto& mix_info = mix_context.GetFinalMixInfo(); | 670 | auto& mix_info = mix_context.GetFinalMixInfo(); |
| 654 | const auto& in_params = mix_info.GetInParams(); | 671 | const auto& in_params = mix_info.GetInParams(); |
| 655 | 672 | ||
| 656 | GenerateDepopForMixBuffersCommand(in_params.buffer_count, in_params.buffer_offset, | 673 | GenerateDepopForMixBuffersCommand(static_cast<u32>(in_params.buffer_count), |
| 674 | static_cast<u32>(in_params.buffer_offset), | ||
| 657 | in_params.sample_rate); | 675 | in_params.sample_rate); |
| 658 | 676 | ||
| 659 | GenerateEffectCommand(mix_info); | 677 | GenerateEffectCommand(mix_info); |
| @@ -667,16 +685,16 @@ void CommandGenerator::GenerateFinalMixCommand() { | |||
| 667 | in_params.node_id, in_params.buffer_offset + i, in_params.buffer_offset + i, | 685 | in_params.node_id, in_params.buffer_offset + i, in_params.buffer_offset + i, |
| 668 | in_params.volume); | 686 | in_params.volume); |
| 669 | } | 687 | } |
| 670 | ApplyGainWithoutDelta(GetMixBuffer(in_params.buffer_offset + i), | 688 | ApplyGainWithoutDelta(GetMixBuffer(static_cast<size_t>(in_params.buffer_offset + i)), |
| 671 | GetMixBuffer(in_params.buffer_offset + i), gain, | 689 | GetMixBuffer(static_cast<size_t>(in_params.buffer_offset + i)), gain, |
| 672 | worker_params.sample_count); | 690 | static_cast<s32>(worker_params.sample_count)); |
| 673 | } | 691 | } |
| 674 | } | 692 | } |
| 675 | 693 | ||
| 676 | s32 CommandGenerator::DecodePcm16(ServerVoiceInfo& voice_info, VoiceState& dsp_state, | 694 | s32 CommandGenerator::DecodePcm16(ServerVoiceInfo& voice_info, VoiceState& dsp_state, |
| 677 | s32 sample_count, s32 channel, std::size_t mix_offset) { | 695 | s32 sample_count, s32 channel, std::size_t mix_offset) { |
| 678 | const auto& in_params = voice_info.GetInParams(); | 696 | const auto& in_params = voice_info.GetInParams(); |
| 679 | const auto& wave_buffer = in_params.wave_buffer[dsp_state.wave_buffer_index]; | 697 | const auto& wave_buffer = in_params.wave_buffer[static_cast<u32>(dsp_state.wave_buffer_index)]; |
| 680 | if (wave_buffer.buffer_address == 0) { | 698 | if (wave_buffer.buffer_address == 0) { |
| 681 | return 0; | 699 | return 0; |
| 682 | } | 700 | } |
| @@ -689,24 +707,26 @@ s32 CommandGenerator::DecodePcm16(ServerVoiceInfo& voice_info, VoiceState& dsp_s | |||
| 689 | const auto samples_remaining = | 707 | const auto samples_remaining = |
| 690 | (wave_buffer.end_sample_offset - wave_buffer.start_sample_offset) - dsp_state.offset; | 708 | (wave_buffer.end_sample_offset - wave_buffer.start_sample_offset) - dsp_state.offset; |
| 691 | const auto start_offset = | 709 | const auto start_offset = |
| 692 | ((wave_buffer.start_sample_offset + dsp_state.offset) * in_params.channel_count) * | 710 | static_cast<size_t>((wave_buffer.start_sample_offset + dsp_state.offset) * |
| 711 | in_params.channel_count) * | ||
| 693 | sizeof(s16); | 712 | sizeof(s16); |
| 694 | const auto buffer_pos = wave_buffer.buffer_address + start_offset; | 713 | const auto buffer_pos = wave_buffer.buffer_address + start_offset; |
| 695 | const auto samples_processed = std::min(sample_count, samples_remaining); | 714 | const auto samples_processed = std::min(sample_count, samples_remaining); |
| 696 | 715 | ||
| 697 | if (in_params.channel_count == 1) { | 716 | if (in_params.channel_count == 1) { |
| 698 | std::vector<s16> buffer(samples_processed); | 717 | std::vector<s16> buffer(static_cast<size_t>(samples_processed)); |
| 699 | memory.ReadBlock(buffer_pos, buffer.data(), buffer.size() * sizeof(s16)); | 718 | memory.ReadBlock(buffer_pos, buffer.data(), buffer.size() * sizeof(s16)); |
| 700 | for (std::size_t i = 0; i < buffer.size(); i++) { | 719 | for (std::size_t i = 0; i < buffer.size(); i++) { |
| 701 | sample_buffer[mix_offset + i] = buffer[i]; | 720 | sample_buffer[mix_offset + i] = buffer[i]; |
| 702 | } | 721 | } |
| 703 | } else { | 722 | } else { |
| 704 | const auto channel_count = in_params.channel_count; | 723 | const auto channel_count = in_params.channel_count; |
| 705 | std::vector<s16> buffer(samples_processed * channel_count); | 724 | std::vector<s16> buffer(static_cast<size_t>(samples_processed * channel_count)); |
| 706 | memory.ReadBlock(buffer_pos, buffer.data(), buffer.size() * sizeof(s16)); | 725 | memory.ReadBlock(buffer_pos, buffer.data(), buffer.size() * sizeof(s16)); |
| 707 | 726 | ||
| 708 | for (std::size_t i = 0; i < static_cast<std::size_t>(samples_processed); i++) { | 727 | for (std::size_t i = 0; i < static_cast<std::size_t>(samples_processed); i++) { |
| 709 | sample_buffer[mix_offset + i] = buffer[i * channel_count + channel]; | 728 | sample_buffer[mix_offset + i] = |
| 729 | buffer[i * static_cast<u32>(channel_count) + static_cast<u32>(channel)]; | ||
| 710 | } | 730 | } |
| 711 | } | 731 | } |
| 712 | 732 | ||
| @@ -716,7 +736,7 @@ s32 CommandGenerator::DecodePcm16(ServerVoiceInfo& voice_info, VoiceState& dsp_s | |||
| 716 | s32 CommandGenerator::DecodeAdpcm(ServerVoiceInfo& voice_info, VoiceState& dsp_state, | 736 | s32 CommandGenerator::DecodeAdpcm(ServerVoiceInfo& voice_info, VoiceState& dsp_state, |
| 717 | s32 sample_count, s32 channel, std::size_t mix_offset) { | 737 | s32 sample_count, s32 channel, std::size_t mix_offset) { |
| 718 | const auto& in_params = voice_info.GetInParams(); | 738 | const auto& in_params = voice_info.GetInParams(); |
| 719 | const auto& wave_buffer = in_params.wave_buffer[dsp_state.wave_buffer_index]; | 739 | const auto& wave_buffer = in_params.wave_buffer[static_cast<u32>(dsp_state.wave_buffer_index)]; |
| 720 | if (wave_buffer.buffer_address == 0) { | 740 | if (wave_buffer.buffer_address == 0) { |
| 721 | return 0; | 741 | return 0; |
| 722 | } | 742 | } |
| @@ -736,7 +756,7 @@ s32 CommandGenerator::DecodeAdpcm(ServerVoiceInfo& voice_info, VoiceState& dsp_s | |||
| 736 | constexpr std::size_t SAMPLES_PER_FRAME = 14; | 756 | constexpr std::size_t SAMPLES_PER_FRAME = 14; |
| 737 | 757 | ||
| 738 | auto frame_header = dsp_state.context.header; | 758 | auto frame_header = dsp_state.context.header; |
| 739 | s32 idx = (frame_header >> 4) & 0xf; | 759 | auto idx = static_cast<size_t>((frame_header >> 4) & 0xf); |
| 740 | s32 scale = frame_header & 0xf; | 760 | s32 scale = frame_header & 0xf; |
| 741 | s16 yn1 = dsp_state.context.yn1; | 761 | s16 yn1 = dsp_state.context.yn1; |
| 742 | s16 yn2 = dsp_state.context.yn2; | 762 | s16 yn2 = dsp_state.context.yn2; |
| @@ -753,9 +773,10 @@ s32 CommandGenerator::DecodeAdpcm(ServerVoiceInfo& voice_info, VoiceState& dsp_s | |||
| 753 | const auto samples_processed = std::min(sample_count, samples_remaining); | 773 | const auto samples_processed = std::min(sample_count, samples_remaining); |
| 754 | const auto sample_pos = wave_buffer.start_sample_offset + dsp_state.offset; | 774 | const auto sample_pos = wave_buffer.start_sample_offset + dsp_state.offset; |
| 755 | 775 | ||
| 756 | const auto samples_remaining_in_frame = sample_pos % SAMPLES_PER_FRAME; | 776 | const auto samples_remaining_in_frame = static_cast<u32>(sample_pos) % SAMPLES_PER_FRAME; |
| 757 | auto position_in_frame = ((sample_pos / SAMPLES_PER_FRAME) * NIBBLES_PER_SAMPLE) + | 777 | auto position_in_frame = |
| 758 | samples_remaining_in_frame + (samples_remaining_in_frame != 0 ? 2 : 0); | 778 | ((static_cast<u32>(sample_pos) / SAMPLES_PER_FRAME) * NIBBLES_PER_SAMPLE) + |
| 779 | samples_remaining_in_frame + (samples_remaining_in_frame != 0 ? 2 : 0); | ||
| 759 | 780 | ||
| 760 | const auto decode_sample = [&](const int nibble) -> s16 { | 781 | const auto decode_sample = [&](const int nibble) -> s16 { |
| 761 | const int xn = nibble * (1 << scale); | 782 | const int xn = nibble * (1 << scale); |
| @@ -774,7 +795,7 @@ s32 CommandGenerator::DecodeAdpcm(ServerVoiceInfo& voice_info, VoiceState& dsp_s | |||
| 774 | 795 | ||
| 775 | std::size_t buffer_offset{}; | 796 | std::size_t buffer_offset{}; |
| 776 | std::vector<u8> buffer( | 797 | std::vector<u8> buffer( |
| 777 | std::max((samples_processed / FRAME_LEN) * SAMPLES_PER_FRAME, FRAME_LEN)); | 798 | std::max((static_cast<u32>(samples_processed) / FRAME_LEN) * SAMPLES_PER_FRAME, FRAME_LEN)); |
| 778 | memory.ReadBlock(wave_buffer.buffer_address + (position_in_frame / 2), buffer.data(), | 799 | memory.ReadBlock(wave_buffer.buffer_address + (position_in_frame / 2), buffer.data(), |
| 779 | buffer.size()); | 800 | buffer.size()); |
| 780 | std::size_t cur_mix_offset = mix_offset; | 801 | std::size_t cur_mix_offset = mix_offset; |
| @@ -784,7 +805,7 @@ s32 CommandGenerator::DecodeAdpcm(ServerVoiceInfo& voice_info, VoiceState& dsp_s | |||
| 784 | if (position_in_frame % NIBBLES_PER_SAMPLE == 0) { | 805 | if (position_in_frame % NIBBLES_PER_SAMPLE == 0) { |
| 785 | // Read header | 806 | // Read header |
| 786 | frame_header = buffer[buffer_offset++]; | 807 | frame_header = buffer[buffer_offset++]; |
| 787 | idx = (frame_header >> 4) & 0xf; | 808 | idx = static_cast<size_t>((frame_header >> 4) & 0xf); |
| 788 | scale = frame_header & 0xf; | 809 | scale = frame_header & 0xf; |
| 789 | coef1 = coeffs[idx * 2]; | 810 | coef1 = coeffs[idx * 2]; |
| 790 | coef2 = coeffs[idx * 2 + 1]; | 811 | coef2 = coeffs[idx * 2 + 1]; |
| @@ -794,8 +815,8 @@ s32 CommandGenerator::DecodeAdpcm(ServerVoiceInfo& voice_info, VoiceState& dsp_s | |||
| 794 | if (remaining_samples >= static_cast<int>(SAMPLES_PER_FRAME)) { | 815 | if (remaining_samples >= static_cast<int>(SAMPLES_PER_FRAME)) { |
| 795 | for (std::size_t i = 0; i < SAMPLES_PER_FRAME / 2; i++) { | 816 | for (std::size_t i = 0; i < SAMPLES_PER_FRAME / 2; i++) { |
| 796 | // Sample 1 | 817 | // Sample 1 |
| 797 | const s32 s0 = SIGNED_NIBBLES[buffer[buffer_offset] >> 4]; | 818 | const s32 s0 = SIGNED_NIBBLES[static_cast<u32>(buffer[buffer_offset] >> 4)]; |
| 798 | const s32 s1 = SIGNED_NIBBLES[buffer[buffer_offset++] & 0xf]; | 819 | const s32 s1 = SIGNED_NIBBLES[static_cast<u32>(buffer[buffer_offset++] & 0xf)]; |
| 799 | const s16 sample_1 = decode_sample(s0); | 820 | const s16 sample_1 = decode_sample(s0); |
| 800 | const s16 sample_2 = decode_sample(s1); | 821 | const s16 sample_2 = decode_sample(s1); |
| 801 | sample_buffer[cur_mix_offset++] = sample_1; | 822 | sample_buffer[cur_mix_offset++] = sample_1; |
| @@ -807,14 +828,14 @@ s32 CommandGenerator::DecodeAdpcm(ServerVoiceInfo& voice_info, VoiceState& dsp_s | |||
| 807 | } | 828 | } |
| 808 | } | 829 | } |
| 809 | // Decode mid frame | 830 | // Decode mid frame |
| 810 | s32 current_nibble = buffer[buffer_offset]; | 831 | auto current_nibble = static_cast<s32>(buffer[buffer_offset]); |
| 811 | if (position_in_frame++ & 0x1) { | 832 | if ((position_in_frame++ & 1) != 0) { |
| 812 | current_nibble &= 0xf; | 833 | current_nibble &= 0xf; |
| 813 | buffer_offset++; | 834 | buffer_offset++; |
| 814 | } else { | 835 | } else { |
| 815 | current_nibble >>= 4; | 836 | current_nibble >>= 4; |
| 816 | } | 837 | } |
| 817 | const s16 sample = decode_sample(SIGNED_NIBBLES[current_nibble]); | 838 | const s16 sample = decode_sample(SIGNED_NIBBLES[static_cast<u32>(current_nibble)]); |
| 818 | sample_buffer[cur_mix_offset++] = sample; | 839 | sample_buffer[cur_mix_offset++] = sample; |
| 819 | remaining_samples--; | 840 | remaining_samples--; |
| 820 | } | 841 | } |
| @@ -835,7 +856,7 @@ const s32* CommandGenerator::GetMixBuffer(std::size_t index) const { | |||
| 835 | } | 856 | } |
| 836 | 857 | ||
| 837 | std::size_t CommandGenerator::GetMixChannelBufferOffset(s32 channel) const { | 858 | std::size_t CommandGenerator::GetMixChannelBufferOffset(s32 channel) const { |
| 838 | return worker_params.mix_buffer_count + channel; | 859 | return worker_params.mix_buffer_count + static_cast<u32>(channel); |
| 839 | } | 860 | } |
| 840 | 861 | ||
| 841 | std::size_t CommandGenerator::GetTotalMixBufferCount() const { | 862 | std::size_t CommandGenerator::GetTotalMixBufferCount() const { |
| @@ -843,11 +864,11 @@ std::size_t CommandGenerator::GetTotalMixBufferCount() const { | |||
| 843 | } | 864 | } |
| 844 | 865 | ||
| 845 | s32* CommandGenerator::GetChannelMixBuffer(s32 channel) { | 866 | s32* CommandGenerator::GetChannelMixBuffer(s32 channel) { |
| 846 | return GetMixBuffer(worker_params.mix_buffer_count + channel); | 867 | return GetMixBuffer(worker_params.mix_buffer_count + static_cast<u32>(channel)); |
| 847 | } | 868 | } |
| 848 | 869 | ||
| 849 | const s32* CommandGenerator::GetChannelMixBuffer(s32 channel) const { | 870 | const s32* CommandGenerator::GetChannelMixBuffer(s32 channel) const { |
| 850 | return GetMixBuffer(worker_params.mix_buffer_count + channel); | 871 | return GetMixBuffer(worker_params.mix_buffer_count + static_cast<u32>(channel)); |
| 851 | } | 872 | } |
| 852 | 873 | ||
| 853 | void CommandGenerator::DecodeFromWaveBuffers(ServerVoiceInfo& voice_info, s32* output, | 874 | void CommandGenerator::DecodeFromWaveBuffers(ServerVoiceInfo& voice_info, s32* output, |
| @@ -895,9 +916,10 @@ void CommandGenerator::DecodeFromWaveBuffers(ServerVoiceInfo& voice_info, s32* o | |||
| 895 | 916 | ||
| 896 | s32 samples_read{}; | 917 | s32 samples_read{}; |
| 897 | while (samples_read < samples_to_read) { | 918 | while (samples_read < samples_to_read) { |
| 898 | const auto& wave_buffer = in_params.wave_buffer[dsp_state.wave_buffer_index]; | 919 | const auto& wave_buffer = |
| 920 | in_params.wave_buffer[static_cast<u32>(dsp_state.wave_buffer_index)]; | ||
| 899 | // No more data can be read | 921 | // No more data can be read |
| 900 | if (!dsp_state.is_wave_buffer_valid[dsp_state.wave_buffer_index]) { | 922 | if (!dsp_state.is_wave_buffer_valid[static_cast<u32>(dsp_state.wave_buffer_index)]) { |
| 901 | is_buffer_completed = true; | 923 | is_buffer_completed = true; |
| 902 | break; | 924 | break; |
| 903 | } | 925 | } |
| @@ -921,7 +943,7 @@ void CommandGenerator::DecodeFromWaveBuffers(ServerVoiceInfo& voice_info, s32* o | |||
| 921 | UNREACHABLE_MSG("Unimplemented sample format={}", in_params.sample_format); | 943 | UNREACHABLE_MSG("Unimplemented sample format={}", in_params.sample_format); |
| 922 | } | 944 | } |
| 923 | 945 | ||
| 924 | temp_mix_offset += samples_decoded; | 946 | temp_mix_offset += static_cast<size_t>(samples_decoded); |
| 925 | samples_read += samples_decoded; | 947 | samples_read += samples_decoded; |
| 926 | dsp_state.offset += samples_decoded; | 948 | dsp_state.offset += samples_decoded; |
| 927 | dsp_state.played_sample_count += samples_decoded; | 949 | dsp_state.played_sample_count += samples_decoded; |
| @@ -944,10 +966,12 @@ void CommandGenerator::DecodeFromWaveBuffers(ServerVoiceInfo& voice_info, s32* o | |||
| 944 | } else { | 966 | } else { |
| 945 | 967 | ||
| 946 | // Update our wave buffer states | 968 | // Update our wave buffer states |
| 947 | dsp_state.is_wave_buffer_valid[dsp_state.wave_buffer_index] = false; | 969 | dsp_state.is_wave_buffer_valid[static_cast<u32>(dsp_state.wave_buffer_index)] = |
| 970 | false; | ||
| 948 | dsp_state.wave_buffer_consumed++; | 971 | dsp_state.wave_buffer_consumed++; |
| 949 | dsp_state.wave_buffer_index = | 972 | dsp_state.wave_buffer_index = |
| 950 | (dsp_state.wave_buffer_index + 1) % AudioCommon::MAX_WAVE_BUFFERS; | 973 | static_cast<u32>(dsp_state.wave_buffer_index + 1) % |
| 974 | AudioCommon::MAX_WAVE_BUFFERS; | ||
| 951 | if (wave_buffer.end_of_stream) { | 975 | if (wave_buffer.end_of_stream) { |
| 952 | dsp_state.played_sample_count = 0; | 976 | dsp_state.played_sample_count = 0; |
| 953 | } | 977 | } |
| @@ -957,16 +981,20 @@ void CommandGenerator::DecodeFromWaveBuffers(ServerVoiceInfo& voice_info, s32* o | |||
| 957 | 981 | ||
| 958 | if (in_params.behavior_flags.is_pitch_and_src_skipped.Value()) { | 982 | if (in_params.behavior_flags.is_pitch_and_src_skipped.Value()) { |
| 959 | // No need to resample | 983 | // No need to resample |
| 960 | std::memcpy(output, sample_buffer.data(), samples_read * sizeof(s32)); | 984 | std::memcpy(output, sample_buffer.data(), |
| 985 | static_cast<size_t>(samples_read) * sizeof(s32)); | ||
| 961 | } else { | 986 | } else { |
| 962 | std::fill(sample_buffer.begin() + temp_mix_offset, | 987 | { |
| 963 | sample_buffer.begin() + temp_mix_offset + (samples_to_read - samples_read), | 988 | const auto begin = sample_buffer.begin() + static_cast<ptrdiff_t>(temp_mix_offset); |
| 964 | 0); | 989 | const auto end = begin + (samples_to_read - samples_read); |
| 990 | std::fill(begin, end, 0); | ||
| 991 | } | ||
| 965 | AudioCore::Resample(output, sample_buffer.data(), resample_rate, dsp_state.fraction, | 992 | AudioCore::Resample(output, sample_buffer.data(), resample_rate, dsp_state.fraction, |
| 966 | samples_to_output); | 993 | static_cast<size_t>(samples_to_output)); |
| 967 | // Resample | 994 | // Resample |
| 968 | for (std::size_t i = 0; i < AudioCommon::MAX_SAMPLE_HISTORY; i++) { | 995 | for (std::size_t i = 0; i < AudioCommon::MAX_SAMPLE_HISTORY; i++) { |
| 969 | dsp_state.sample_history[i] = sample_buffer[samples_to_read + i]; | 996 | dsp_state.sample_history[i] = |
| 997 | sample_buffer[static_cast<size_t>(samples_to_read) + i]; | ||
| 970 | } | 998 | } |
| 971 | } | 999 | } |
| 972 | output += samples_to_output; | 1000 | output += samples_to_output; |
diff --git a/src/audio_core/command_generator.h b/src/audio_core/command_generator.h index 53e57748b..6cba70ae3 100644 --- a/src/audio_core/command_generator.h +++ b/src/audio_core/command_generator.h | |||
| @@ -50,12 +50,12 @@ public: | |||
| 50 | private: | 50 | private: |
| 51 | void GenerateDataSourceCommand(ServerVoiceInfo& voice_info, VoiceState& dsp_state, s32 channel); | 51 | void GenerateDataSourceCommand(ServerVoiceInfo& voice_info, VoiceState& dsp_state, s32 channel); |
| 52 | void GenerateBiquadFilterCommandForVoice(ServerVoiceInfo& voice_info, VoiceState& dsp_state, | 52 | void GenerateBiquadFilterCommandForVoice(ServerVoiceInfo& voice_info, VoiceState& dsp_state, |
| 53 | s32 mix_buffer_count, s32 channel); | 53 | u32 mix_buffer_count, s32 channel); |
| 54 | void GenerateVolumeRampCommand(float last_volume, float current_volume, s32 channel, | 54 | void GenerateVolumeRampCommand(float last_volume, float current_volume, s32 channel, |
| 55 | s32 node_id); | 55 | s32 node_id); |
| 56 | void GenerateVoiceMixCommand(const MixVolumeBuffer& mix_volumes, | 56 | void GenerateVoiceMixCommand(const MixVolumeBuffer& mix_volumes, |
| 57 | const MixVolumeBuffer& last_mix_volumes, VoiceState& dsp_state, | 57 | const MixVolumeBuffer& last_mix_volumes, VoiceState& dsp_state, |
| 58 | s32 mix_buffer_offset, s32 mix_buffer_count, s32 voice_index, | 58 | u32 mix_buffer_offset, u32 mix_buffer_count, u32 voice_index, |
| 59 | s32 node_id); | 59 | s32 node_id); |
| 60 | void GenerateSubMixCommand(ServerMixInfo& mix_info); | 60 | void GenerateSubMixCommand(ServerMixInfo& mix_info); |
| 61 | void GenerateMixCommands(ServerMixInfo& mix_info); | 61 | void GenerateMixCommands(ServerMixInfo& mix_info); |
diff --git a/src/audio_core/cubeb_sink.cpp b/src/audio_core/cubeb_sink.cpp index 6eaa60815..a20b6ad5f 100644 --- a/src/audio_core/cubeb_sink.cpp +++ b/src/audio_core/cubeb_sink.cpp | |||
| @@ -202,7 +202,7 @@ long CubebSinkStream::DataCallback(cubeb_stream* stream, void* user_data, const | |||
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | const std::size_t num_channels = impl->GetNumChannels(); | 204 | const std::size_t num_channels = impl->GetNumChannels(); |
| 205 | const std::size_t samples_to_write = num_channels * num_frames; | 205 | const std::size_t samples_to_write = num_channels * static_cast<u64>(num_frames); |
| 206 | std::size_t samples_written; | 206 | std::size_t samples_written; |
| 207 | 207 | ||
| 208 | /* | 208 | /* |
diff --git a/src/audio_core/cubeb_sink.h b/src/audio_core/cubeb_sink.h index 7ce850f47..c50d0b7bd 100644 --- a/src/audio_core/cubeb_sink.h +++ b/src/audio_core/cubeb_sink.h | |||
| @@ -27,7 +27,7 @@ private: | |||
| 27 | std::vector<SinkStreamPtr> sink_streams; | 27 | std::vector<SinkStreamPtr> sink_streams; |
| 28 | 28 | ||
| 29 | #ifdef _WIN32 | 29 | #ifdef _WIN32 |
| 30 | u32 com_init_result = 0; | 30 | s32 com_init_result = 0; |
| 31 | #endif | 31 | #endif |
| 32 | }; | 32 | }; |
| 33 | 33 | ||
diff --git a/src/audio_core/info_updater.cpp b/src/audio_core/info_updater.cpp index 2940e53a9..f999a8b17 100644 --- a/src/audio_core/info_updater.cpp +++ b/src/audio_core/info_updater.cpp | |||
| @@ -350,7 +350,7 @@ ResultCode InfoUpdater::UpdateMixes(MixContext& mix_context, std::size_t mix_buf | |||
| 350 | std::size_t total_buffer_count{}; | 350 | std::size_t total_buffer_count{}; |
| 351 | for (std::size_t i = 0; i < mix_count; i++) { | 351 | for (std::size_t i = 0; i < mix_count; i++) { |
| 352 | const auto& in = mix_in_params[i]; | 352 | const auto& in = mix_in_params[i]; |
| 353 | total_buffer_count += in.buffer_count; | 353 | total_buffer_count += static_cast<size_t>(in.buffer_count); |
| 354 | if (static_cast<std::size_t>(in.dest_mix_id) > mix_count && | 354 | if (static_cast<std::size_t>(in.dest_mix_id) > mix_count && |
| 355 | in.dest_mix_id != AudioCommon::NO_MIX && in.mix_id != AudioCommon::FINAL_MIX) { | 355 | in.dest_mix_id != AudioCommon::NO_MIX && in.mix_id != AudioCommon::FINAL_MIX) { |
| 356 | LOG_ERROR( | 356 | LOG_ERROR( |
| @@ -379,7 +379,7 @@ ResultCode InfoUpdater::UpdateMixes(MixContext& mix_context, std::size_t mix_buf | |||
| 379 | const auto& mix_in = mix_in_params[i]; | 379 | const auto& mix_in = mix_in_params[i]; |
| 380 | std::size_t target_mix{}; | 380 | std::size_t target_mix{}; |
| 381 | if (behavior_info.IsMixInParameterDirtyOnlyUpdateSupported()) { | 381 | if (behavior_info.IsMixInParameterDirtyOnlyUpdateSupported()) { |
| 382 | target_mix = mix_in.mix_id; | 382 | target_mix = static_cast<size_t>(mix_in.mix_id); |
| 383 | } else { | 383 | } else { |
| 384 | // Non dirty supported games just use i instead of the actual mix_id | 384 | // Non dirty supported games just use i instead of the actual mix_id |
| 385 | target_mix = i; | 385 | target_mix = i; |
diff --git a/src/audio_core/mix_context.cpp b/src/audio_core/mix_context.cpp index 4bca72eb0..c28bee453 100644 --- a/src/audio_core/mix_context.cpp +++ b/src/audio_core/mix_context.cpp | |||
| @@ -62,7 +62,7 @@ void MixContext::UpdateDistancesFromFinalMix() { | |||
| 62 | distance_to_final_mix = AudioCommon::NO_FINAL_MIX; | 62 | distance_to_final_mix = AudioCommon::NO_FINAL_MIX; |
| 63 | break; | 63 | break; |
| 64 | } else { | 64 | } else { |
| 65 | const auto& dest_mix = GetInfo(mix_id); | 65 | const auto& dest_mix = GetInfo(static_cast<u32>(mix_id)); |
| 66 | const auto dest_mix_distance = dest_mix.GetInParams().final_mix_distance; | 66 | const auto dest_mix_distance = dest_mix.GetInParams().final_mix_distance; |
| 67 | 67 | ||
| 68 | if (dest_mix_distance == AudioCommon::NO_FINAL_MIX) { | 68 | if (dest_mix_distance == AudioCommon::NO_FINAL_MIX) { |
| @@ -129,7 +129,7 @@ bool MixContext::TsortInfo(SplitterContext& splitter_context) { | |||
| 129 | std::size_t info_id{}; | 129 | std::size_t info_id{}; |
| 130 | for (auto itr = sorted_list.rbegin(); itr != sorted_list.rend(); ++itr) { | 130 | for (auto itr = sorted_list.rbegin(); itr != sorted_list.rend(); ++itr) { |
| 131 | // Set our sorted info | 131 | // Set our sorted info |
| 132 | sorted_info[info_id++] = &GetInfo(*itr); | 132 | sorted_info[info_id++] = &GetInfo(static_cast<u32>(*itr)); |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | // Calculate the mix buffer offset | 135 | // Calculate the mix buffer offset |
| @@ -218,7 +218,8 @@ bool ServerMixInfo::Update(EdgeMatrix& edge_matrix, const MixInfo::InParams& mix | |||
| 218 | for (std::size_t i = 0; i < effect_count; i++) { | 218 | for (std::size_t i = 0; i < effect_count; i++) { |
| 219 | auto* effect_info = effect_context.GetInfo(i); | 219 | auto* effect_info = effect_context.GetInfo(i); |
| 220 | if (effect_info->GetMixID() == in_params.mix_id) { | 220 | if (effect_info->GetMixID() == in_params.mix_id) { |
| 221 | effect_processing_order[effect_info->GetProcessingOrder()] = static_cast<s32>(i); | 221 | const auto processing_order = static_cast<u32>(effect_info->GetProcessingOrder()); |
| 222 | effect_processing_order[processing_order] = static_cast<s32>(i); | ||
| 222 | } | 223 | } |
| 223 | } | 224 | } |
| 224 | 225 | ||
| @@ -265,7 +266,7 @@ bool ServerMixInfo::UpdateConnection(EdgeMatrix& edge_matrix, const MixInfo::InP | |||
| 265 | if (in_params.dest_mix_id == mix_in.dest_mix_id && | 266 | if (in_params.dest_mix_id == mix_in.dest_mix_id && |
| 266 | in_params.splitter_id == mix_in.splitter_id && | 267 | in_params.splitter_id == mix_in.splitter_id && |
| 267 | ((in_params.splitter_id == AudioCommon::NO_SPLITTER) || | 268 | ((in_params.splitter_id == AudioCommon::NO_SPLITTER) || |
| 268 | !splitter_context.GetInfo(in_params.splitter_id).HasNewConnection())) { | 269 | !splitter_context.GetInfo(static_cast<u32>(in_params.splitter_id)).HasNewConnection())) { |
| 269 | return false; | 270 | return false; |
| 270 | } | 271 | } |
| 271 | // Remove current edges for mix id | 272 | // Remove current edges for mix id |
| @@ -275,11 +276,11 @@ bool ServerMixInfo::UpdateConnection(EdgeMatrix& edge_matrix, const MixInfo::InP | |||
| 275 | edge_matrix.Connect(in_params.mix_id, mix_in.dest_mix_id); | 276 | edge_matrix.Connect(in_params.mix_id, mix_in.dest_mix_id); |
| 276 | } else if (mix_in.splitter_id != AudioCommon::NO_SPLITTER) { | 277 | } else if (mix_in.splitter_id != AudioCommon::NO_SPLITTER) { |
| 277 | // Recurse our splitter linked and set our edges | 278 | // Recurse our splitter linked and set our edges |
| 278 | auto& splitter_info = splitter_context.GetInfo(mix_in.splitter_id); | 279 | auto& splitter_info = splitter_context.GetInfo(static_cast<u32>(mix_in.splitter_id)); |
| 279 | const auto length = splitter_info.GetLength(); | 280 | const auto length = static_cast<size_t>(splitter_info.GetLength()); |
| 280 | for (s32 i = 0; i < length; i++) { | 281 | for (size_t i = 0; i < length; i++) { |
| 281 | const auto* splitter_destination = | 282 | const auto* splitter_destination = |
| 282 | splitter_context.GetDestinationData(mix_in.splitter_id, i); | 283 | splitter_context.GetDestinationData(static_cast<u32>(mix_in.splitter_id), i); |
| 283 | if (splitter_destination == nullptr) { | 284 | if (splitter_destination == nullptr) { |
| 284 | continue; | 285 | continue; |
| 285 | } | 286 | } |
diff --git a/src/audio_core/sink_context.cpp b/src/audio_core/sink_context.cpp index 0882b411a..3d713814a 100644 --- a/src/audio_core/sink_context.cpp +++ b/src/audio_core/sink_context.cpp | |||
| @@ -23,8 +23,9 @@ bool SinkContext::InUse() const { | |||
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | std::vector<u8> SinkContext::OutputBuffers() const { | 25 | std::vector<u8> SinkContext::OutputBuffers() const { |
| 26 | std::vector<u8> buffer_ret(use_count); | 26 | const auto output_use_count = static_cast<size_t>(use_count); |
| 27 | std::memcpy(buffer_ret.data(), buffers.data(), use_count); | 27 | std::vector<u8> buffer_ret(output_use_count); |
| 28 | std::memcpy(buffer_ret.data(), buffers.data(), output_use_count); | ||
| 28 | return buffer_ret; | 29 | return buffer_ret; |
| 29 | } | 30 | } |
| 30 | 31 | ||
diff --git a/src/audio_core/splitter_context.cpp b/src/audio_core/splitter_context.cpp index f21b53147..f3e870648 100644 --- a/src/audio_core/splitter_context.cpp +++ b/src/audio_core/splitter_context.cpp | |||
| @@ -109,7 +109,7 @@ std::size_t ServerSplitterInfo::Update(SplitterInfo::InInfoPrams& header) { | |||
| 109 | new_connection = true; | 109 | new_connection = true; |
| 110 | // We need to update the size here due to the splitter bug being present and providing an | 110 | // We need to update the size here due to the splitter bug being present and providing an |
| 111 | // incorrect size. We're suppose to also update the header here but we just ignore and continue | 111 | // incorrect size. We're suppose to also update the header here but we just ignore and continue |
| 112 | return (sizeof(s32_le) * (header.length - 1)) + (sizeof(s32_le) * 3); | 112 | return (sizeof(s32_le) * static_cast<size_t>(header.length - 1)) + (sizeof(s32_le) * 3); |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | ServerSplitterDestinationData* ServerSplitterInfo::GetHead() { | 115 | ServerSplitterDestinationData* ServerSplitterInfo::GetHead() { |
| @@ -306,13 +306,14 @@ bool SplitterContext::UpdateInfo(const std::vector<u8>& input, std::size_t& inpu | |||
| 306 | break; | 306 | break; |
| 307 | } | 307 | } |
| 308 | 308 | ||
| 309 | if (header.send_id < 0 || static_cast<std::size_t>(header.send_id) > info_count) { | 309 | const auto send_id = static_cast<std::size_t>(header.send_id); |
| 310 | if (header.send_id < 0 || send_id > info_count) { | ||
| 310 | LOG_ERROR(Audio, "Bad splitter data id"); | 311 | LOG_ERROR(Audio, "Bad splitter data id"); |
| 311 | break; | 312 | break; |
| 312 | } | 313 | } |
| 313 | 314 | ||
| 314 | UpdateOffsets(sizeof(SplitterInfo::InInfoPrams)); | 315 | UpdateOffsets(sizeof(SplitterInfo::InInfoPrams)); |
| 315 | auto& info = GetInfo(header.send_id); | 316 | auto& info = GetInfo(send_id); |
| 316 | if (!RecomposeDestination(info, header, input, input_offset)) { | 317 | if (!RecomposeDestination(info, header, input, input_offset)) { |
| 317 | LOG_ERROR(Audio, "Failed to recompose destination for splitter!"); | 318 | LOG_ERROR(Audio, "Failed to recompose destination for splitter!"); |
| 318 | return false; | 319 | return false; |
| @@ -348,11 +349,12 @@ bool SplitterContext::UpdateData(const std::vector<u8>& input, std::size_t& inpu | |||
| 348 | break; | 349 | break; |
| 349 | } | 350 | } |
| 350 | 351 | ||
| 351 | if (header.splitter_id < 0 || static_cast<std::size_t>(header.splitter_id) > data_count) { | 352 | const auto splitter_id = static_cast<std::size_t>(header.splitter_id); |
| 353 | if (header.splitter_id < 0 || splitter_id > data_count) { | ||
| 352 | LOG_ERROR(Audio, "Bad splitter data id"); | 354 | LOG_ERROR(Audio, "Bad splitter data id"); |
| 353 | break; | 355 | break; |
| 354 | } | 356 | } |
| 355 | GetData(header.splitter_id).Update(header); | 357 | GetData(splitter_id).Update(header); |
| 356 | } | 358 | } |
| 357 | return true; | 359 | return true; |
| 358 | } | 360 | } |
| @@ -386,9 +388,9 @@ bool SplitterContext::RecomposeDestination(ServerSplitterInfo& info, | |||
| 386 | return true; | 388 | return true; |
| 387 | } | 389 | } |
| 388 | 390 | ||
| 389 | auto* start_head = &GetData(header.resource_id_base); | 391 | auto* start_head = &GetData(static_cast<u32>(header.resource_id_base)); |
| 390 | current_head = start_head; | 392 | current_head = start_head; |
| 391 | std::vector<s32_le> resource_ids(size - 1); | 393 | std::vector<s32_le> resource_ids(static_cast<size_t>(size - 1)); |
| 392 | if (!AudioCommon::CanConsumeBuffer(input.size(), input_offset, | 394 | if (!AudioCommon::CanConsumeBuffer(input.size(), input_offset, |
| 393 | resource_ids.size() * sizeof(s32_le))) { | 395 | resource_ids.size() * sizeof(s32_le))) { |
| 394 | LOG_ERROR(Audio, "Buffer is an invalid size!"); | 396 | LOG_ERROR(Audio, "Buffer is an invalid size!"); |
| @@ -397,8 +399,8 @@ bool SplitterContext::RecomposeDestination(ServerSplitterInfo& info, | |||
| 397 | std::memcpy(resource_ids.data(), input.data() + input_offset, | 399 | std::memcpy(resource_ids.data(), input.data() + input_offset, |
| 398 | resource_ids.size() * sizeof(s32_le)); | 400 | resource_ids.size() * sizeof(s32_le)); |
| 399 | 401 | ||
| 400 | for (auto resource_id : resource_ids) { | 402 | for (const auto resource_id : resource_ids) { |
| 401 | auto* head = &GetData(resource_id); | 403 | auto* head = &GetData(static_cast<u32>(resource_id)); |
| 402 | current_head->SetNextDestination(head); | 404 | current_head->SetNextDestination(head); |
| 403 | current_head = head; | 405 | current_head = head; |
| 404 | } | 406 | } |
| @@ -444,7 +446,7 @@ bool NodeStates::DepthFirstSearch(EdgeMatrix& edge_matrix) { | |||
| 444 | const auto node_id = static_cast<s32>(i); | 446 | const auto node_id = static_cast<s32>(i); |
| 445 | 447 | ||
| 446 | // If we don't have a state, send to our index stack for work | 448 | // If we don't have a state, send to our index stack for work |
| 447 | if (GetState(i) == NodeStates::State::NoState) { | 449 | if (GetState(i) == State::NoState) { |
| 448 | index_stack.push(node_id); | 450 | index_stack.push(node_id); |
| 449 | } | 451 | } |
| 450 | 452 | ||
| @@ -453,19 +455,19 @@ bool NodeStates::DepthFirstSearch(EdgeMatrix& edge_matrix) { | |||
| 453 | // Get the current node | 455 | // Get the current node |
| 454 | const auto current_stack_index = index_stack.top(); | 456 | const auto current_stack_index = index_stack.top(); |
| 455 | // Check if we've seen the node yet | 457 | // Check if we've seen the node yet |
| 456 | const auto index_state = GetState(current_stack_index); | 458 | const auto index_state = GetState(static_cast<u32>(current_stack_index)); |
| 457 | if (index_state == NodeStates::State::NoState) { | 459 | if (index_state == State::NoState) { |
| 458 | // Mark the node as seen | 460 | // Mark the node as seen |
| 459 | UpdateState(NodeStates::State::InFound, current_stack_index); | 461 | UpdateState(State::InFound, static_cast<u32>(current_stack_index)); |
| 460 | } else if (index_state == NodeStates::State::InFound) { | 462 | } else if (index_state == State::InFound) { |
| 461 | // We've seen this node before, mark it as completed | 463 | // We've seen this node before, mark it as completed |
| 462 | UpdateState(NodeStates::State::InCompleted, current_stack_index); | 464 | UpdateState(State::InCompleted, static_cast<u32>(current_stack_index)); |
| 463 | // Update our index list | 465 | // Update our index list |
| 464 | PushTsortResult(current_stack_index); | 466 | PushTsortResult(current_stack_index); |
| 465 | // Pop the stack | 467 | // Pop the stack |
| 466 | index_stack.pop(); | 468 | index_stack.pop(); |
| 467 | continue; | 469 | continue; |
| 468 | } else if (index_state == NodeStates::State::InCompleted) { | 470 | } else if (index_state == State::InCompleted) { |
| 469 | // If our node is already sorted, clear it | 471 | // If our node is already sorted, clear it |
| 470 | index_stack.pop(); | 472 | index_stack.pop(); |
| 471 | continue; | 473 | continue; |
| @@ -479,11 +481,11 @@ bool NodeStates::DepthFirstSearch(EdgeMatrix& edge_matrix) { | |||
| 479 | } | 481 | } |
| 480 | 482 | ||
| 481 | // Check if our node exists | 483 | // Check if our node exists |
| 482 | const auto node_state = GetState(j); | 484 | const auto node_state = GetState(static_cast<u32>(j)); |
| 483 | if (node_state == NodeStates::State::NoState) { | 485 | if (node_state == State::NoState) { |
| 484 | // Add more work | 486 | // Add more work |
| 485 | index_stack.push(j); | 487 | index_stack.push(j); |
| 486 | } else if (node_state == NodeStates::State::InFound) { | 488 | } else if (node_state == State::InFound) { |
| 487 | UNREACHABLE_MSG("Node start marked as found"); | 489 | UNREACHABLE_MSG("Node start marked as found"); |
| 488 | ResetState(); | 490 | ResetState(); |
| 489 | return false; | 491 | return false; |
| @@ -507,17 +509,17 @@ void NodeStates::ResetState() { | |||
| 507 | } | 509 | } |
| 508 | } | 510 | } |
| 509 | 511 | ||
| 510 | void NodeStates::UpdateState(NodeStates::State state, std::size_t i) { | 512 | void NodeStates::UpdateState(State state, std::size_t i) { |
| 511 | switch (state) { | 513 | switch (state) { |
| 512 | case NodeStates::State::NoState: | 514 | case State::NoState: |
| 513 | was_node_found[i] = false; | 515 | was_node_found[i] = false; |
| 514 | was_node_completed[i] = false; | 516 | was_node_completed[i] = false; |
| 515 | break; | 517 | break; |
| 516 | case NodeStates::State::InFound: | 518 | case State::InFound: |
| 517 | was_node_found[i] = true; | 519 | was_node_found[i] = true; |
| 518 | was_node_completed[i] = false; | 520 | was_node_completed[i] = false; |
| 519 | break; | 521 | break; |
| 520 | case NodeStates::State::InCompleted: | 522 | case State::InCompleted: |
| 521 | was_node_found[i] = false; | 523 | was_node_found[i] = false; |
| 522 | was_node_completed[i] = true; | 524 | was_node_completed[i] = true; |
| 523 | break; | 525 | break; |
| @@ -528,13 +530,13 @@ NodeStates::State NodeStates::GetState(std::size_t i) { | |||
| 528 | ASSERT(i < node_count); | 530 | ASSERT(i < node_count); |
| 529 | if (was_node_found[i]) { | 531 | if (was_node_found[i]) { |
| 530 | // If our node exists in our found list | 532 | // If our node exists in our found list |
| 531 | return NodeStates::State::InFound; | 533 | return State::InFound; |
| 532 | } else if (was_node_completed[i]) { | 534 | } else if (was_node_completed[i]) { |
| 533 | // If node is in the completed list | 535 | // If node is in the completed list |
| 534 | return NodeStates::State::InCompleted; | 536 | return State::InCompleted; |
| 535 | } else { | 537 | } else { |
| 536 | // If in neither | 538 | // If in neither |
| 537 | return NodeStates::State::NoState; | 539 | return State::NoState; |
| 538 | } | 540 | } |
| 539 | } | 541 | } |
| 540 | 542 | ||
| @@ -601,16 +603,16 @@ std::size_t EdgeMatrix::GetNodeCount() const { | |||
| 601 | 603 | ||
| 602 | void EdgeMatrix::SetState(s32 a, s32 b, bool state) { | 604 | void EdgeMatrix::SetState(s32 a, s32 b, bool state) { |
| 603 | ASSERT(InRange(a, b)); | 605 | ASSERT(InRange(a, b)); |
| 604 | edge_matrix.at(a * node_count + b) = state; | 606 | edge_matrix.at(static_cast<u32>(a) * node_count + static_cast<u32>(b)) = state; |
| 605 | } | 607 | } |
| 606 | 608 | ||
| 607 | bool EdgeMatrix::GetState(s32 a, s32 b) { | 609 | bool EdgeMatrix::GetState(s32 a, s32 b) { |
| 608 | ASSERT(InRange(a, b)); | 610 | ASSERT(InRange(a, b)); |
| 609 | return edge_matrix.at(a * node_count + b); | 611 | return edge_matrix.at(static_cast<u32>(a) * node_count + static_cast<u32>(b)); |
| 610 | } | 612 | } |
| 611 | 613 | ||
| 612 | bool EdgeMatrix::InRange(s32 a, s32 b) const { | 614 | bool EdgeMatrix::InRange(s32 a, s32 b) const { |
| 613 | const std::size_t pos = a * node_count + b; | 615 | const std::size_t pos = static_cast<u32>(a) * node_count + static_cast<u32>(b); |
| 614 | return pos < (node_count * node_count); | 616 | return pos < (node_count * node_count); |
| 615 | } | 617 | } |
| 616 | 618 | ||
diff --git a/src/audio_core/time_stretch.h b/src/audio_core/time_stretch.h index bb2270b96..3808e554d 100644 --- a/src/audio_core/time_stretch.h +++ b/src/audio_core/time_stretch.h | |||
| @@ -5,9 +5,17 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <cstddef> | 7 | #include <cstddef> |
| 8 | #include <SoundTouch.h> | ||
| 9 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 10 | 9 | ||
| 10 | #if defined(__GNUC__) | ||
| 11 | #pragma GCC diagnostic push | ||
| 12 | #pragma GCC diagnostic ignored "-Wsign-conversion" | ||
| 13 | #endif | ||
| 14 | #include <SoundTouch.h> | ||
| 15 | #if defined(__GNUC__) | ||
| 16 | #pragma GCC diagnostic pop | ||
| 17 | #endif | ||
| 18 | |||
| 11 | namespace AudioCore { | 19 | namespace AudioCore { |
| 12 | 20 | ||
| 13 | class TimeStretcher { | 21 | class TimeStretcher { |
diff --git a/src/audio_core/voice_context.cpp b/src/audio_core/voice_context.cpp index c46ee55f1..276b96ca4 100644 --- a/src/audio_core/voice_context.cpp +++ b/src/audio_core/voice_context.cpp | |||
| @@ -98,7 +98,7 @@ void ServerVoiceInfo::UpdateParameters(const VoiceInfo::InParams& voice_in, | |||
| 98 | BehaviorInfo& behavior_info) { | 98 | BehaviorInfo& behavior_info) { |
| 99 | in_params.in_use = voice_in.is_in_use; | 99 | in_params.in_use = voice_in.is_in_use; |
| 100 | in_params.id = voice_in.id; | 100 | in_params.id = voice_in.id; |
| 101 | in_params.node_id = voice_in.node_id; | 101 | in_params.node_id = static_cast<s32>(voice_in.node_id); |
| 102 | in_params.last_playstate = in_params.current_playstate; | 102 | in_params.last_playstate = in_params.current_playstate; |
| 103 | switch (voice_in.play_state) { | 103 | switch (voice_in.play_state) { |
| 104 | case PlayState::Paused: | 104 | case PlayState::Paused: |
| @@ -220,8 +220,10 @@ void ServerVoiceInfo::UpdateWaveBuffer(ServerWaveBuffer& out_wavebuffer, | |||
| 220 | if (sample_format == SampleFormat::Pcm16) { | 220 | if (sample_format == SampleFormat::Pcm16) { |
| 221 | const auto buffer_size = in_wave_buffer.buffer_size; | 221 | const auto buffer_size = in_wave_buffer.buffer_size; |
| 222 | if (in_wave_buffer.start_sample_offset < 0 || in_wave_buffer.end_sample_offset < 0 || | 222 | if (in_wave_buffer.start_sample_offset < 0 || in_wave_buffer.end_sample_offset < 0 || |
| 223 | (buffer_size < (sizeof(s16) * in_wave_buffer.start_sample_offset)) || | 223 | (buffer_size < |
| 224 | (buffer_size < (sizeof(s16) * in_wave_buffer.end_sample_offset))) { | 224 | (sizeof(s16) * static_cast<u32>(in_wave_buffer.start_sample_offset))) || |
| 225 | (buffer_size < | ||
| 226 | (sizeof(s16) * static_cast<u32>(in_wave_buffer.end_sample_offset)))) { | ||
| 225 | // TODO(ogniK): Write error info | 227 | // TODO(ogniK): Write error info |
| 226 | return; | 228 | return; |
| 227 | } | 229 | } |
| @@ -254,8 +256,8 @@ void ServerVoiceInfo::WriteOutStatus( | |||
| 254 | voice_out.played_sample_count = 0; | 256 | voice_out.played_sample_count = 0; |
| 255 | voice_out.voice_dropped = false; | 257 | voice_out.voice_dropped = false; |
| 256 | } else if (!in_params.is_new) { | 258 | } else if (!in_params.is_new) { |
| 257 | voice_out.wave_buffer_consumed = voice_states[0]->wave_buffer_consumed; | 259 | voice_out.wave_buffer_consumed = static_cast<u32>(voice_states[0]->wave_buffer_consumed); |
| 258 | voice_out.played_sample_count = voice_states[0]->played_sample_count; | 260 | voice_out.played_sample_count = static_cast<u64>(voice_states[0]->played_sample_count); |
| 259 | voice_out.voice_dropped = in_params.voice_drop_flag; | 261 | voice_out.voice_dropped = in_params.voice_drop_flag; |
| 260 | } else { | 262 | } else { |
| 261 | voice_out.wave_buffer_consumed = 0; | 263 | voice_out.wave_buffer_consumed = 0; |
| @@ -293,8 +295,8 @@ bool ServerVoiceInfo::UpdateForCommandGeneration(VoiceContext& voice_context) { | |||
| 293 | in_params.is_new = false; | 295 | in_params.is_new = false; |
| 294 | } | 296 | } |
| 295 | 297 | ||
| 296 | const s32 channel_count = in_params.channel_count; | 298 | const auto channel_count = static_cast<size_t>(in_params.channel_count); |
| 297 | for (s32 i = 0; i < channel_count; i++) { | 299 | for (size_t i = 0; i < channel_count; i++) { |
| 298 | const auto channel_resource = in_params.voice_channel_resource_id[i]; | 300 | const auto channel_resource = in_params.voice_channel_resource_id[i]; |
| 299 | dsp_voice_states[i] = | 301 | dsp_voice_states[i] = |
| 300 | &voice_context.GetDspSharedState(static_cast<std::size_t>(channel_resource)); | 302 | &voice_context.GetDspSharedState(static_cast<std::size_t>(channel_resource)); |
| @@ -303,8 +305,9 @@ bool ServerVoiceInfo::UpdateForCommandGeneration(VoiceContext& voice_context) { | |||
| 303 | } | 305 | } |
| 304 | 306 | ||
| 305 | void ServerVoiceInfo::ResetResources(VoiceContext& voice_context) { | 307 | void ServerVoiceInfo::ResetResources(VoiceContext& voice_context) { |
| 306 | const s32 channel_count = in_params.channel_count; | 308 | const auto channel_count = static_cast<size_t>(in_params.channel_count); |
| 307 | for (s32 i = 0; i < channel_count; i++) { | 309 | |
| 310 | for (size_t i = 0; i < channel_count; i++) { | ||
| 308 | const auto channel_resource = in_params.voice_channel_resource_id[i]; | 311 | const auto channel_resource = in_params.voice_channel_resource_id[i]; |
| 309 | auto& dsp_state = | 312 | auto& dsp_state = |
| 310 | voice_context.GetDspSharedState(static_cast<std::size_t>(channel_resource)); | 313 | voice_context.GetDspSharedState(static_cast<std::size_t>(channel_resource)); |
| @@ -325,9 +328,9 @@ bool ServerVoiceInfo::UpdateParametersForCommandGeneration( | |||
| 325 | 328 | ||
| 326 | switch (in_params.current_playstate) { | 329 | switch (in_params.current_playstate) { |
| 327 | case ServerPlayState::Play: { | 330 | case ServerPlayState::Play: { |
| 328 | for (std::size_t i = 0; i < AudioCommon::MAX_WAVE_BUFFERS; i++) { | 331 | for (size_t i = 0; i < AudioCommon::MAX_WAVE_BUFFERS; i++) { |
| 329 | if (!in_params.wave_buffer[i].sent_to_dsp) { | 332 | if (!in_params.wave_buffer[i].sent_to_dsp) { |
| 330 | for (s32 channel = 0; channel < channel_count; channel++) { | 333 | for (size_t channel = 0; channel < static_cast<size_t>(channel_count); channel++) { |
| 331 | dsp_voice_states[channel]->is_wave_buffer_valid[i] = true; | 334 | dsp_voice_states[channel]->is_wave_buffer_valid[i] = true; |
| 332 | } | 335 | } |
| 333 | in_params.wave_buffer[i].sent_to_dsp = true; | 336 | in_params.wave_buffer[i].sent_to_dsp = true; |
| @@ -344,12 +347,13 @@ bool ServerVoiceInfo::UpdateParametersForCommandGeneration( | |||
| 344 | case ServerPlayState::RequestStop: { | 347 | case ServerPlayState::RequestStop: { |
| 345 | for (std::size_t i = 0; i < AudioCommon::MAX_WAVE_BUFFERS; i++) { | 348 | for (std::size_t i = 0; i < AudioCommon::MAX_WAVE_BUFFERS; i++) { |
| 346 | in_params.wave_buffer[i].sent_to_dsp = true; | 349 | in_params.wave_buffer[i].sent_to_dsp = true; |
| 347 | for (s32 channel = 0; channel < channel_count; channel++) { | 350 | for (std::size_t channel = 0; channel < static_cast<size_t>(channel_count); channel++) { |
| 348 | auto* dsp_state = dsp_voice_states[channel]; | 351 | auto* dsp_state = dsp_voice_states[channel]; |
| 349 | 352 | ||
| 350 | if (dsp_state->is_wave_buffer_valid[i]) { | 353 | if (dsp_state->is_wave_buffer_valid[i]) { |
| 351 | dsp_state->wave_buffer_index = | 354 | dsp_state->wave_buffer_index = |
| 352 | (dsp_state->wave_buffer_index + 1) % AudioCommon::MAX_WAVE_BUFFERS; | 355 | static_cast<s32>(static_cast<u32>(dsp_state->wave_buffer_index + 1) % |
| 356 | AudioCommon::MAX_WAVE_BUFFERS); | ||
| 353 | dsp_state->wave_buffer_consumed++; | 357 | dsp_state->wave_buffer_consumed++; |
| 354 | } | 358 | } |
| 355 | 359 | ||
| @@ -357,7 +361,7 @@ bool ServerVoiceInfo::UpdateParametersForCommandGeneration( | |||
| 357 | } | 361 | } |
| 358 | } | 362 | } |
| 359 | 363 | ||
| 360 | for (s32 channel = 0; channel < channel_count; channel++) { | 364 | for (size_t channel = 0; channel < static_cast<size_t>(channel_count); channel++) { |
| 361 | auto* dsp_state = dsp_voice_states[channel]; | 365 | auto* dsp_state = dsp_voice_states[channel]; |
| 362 | dsp_state->offset = 0; | 366 | dsp_state->offset = 0; |
| 363 | dsp_state->played_sample_count = 0; | 367 | dsp_state->played_sample_count = 0; |
| @@ -383,15 +387,16 @@ void ServerVoiceInfo::FlushWaveBuffers( | |||
| 383 | auto wave_head = in_params.wave_bufffer_head; | 387 | auto wave_head = in_params.wave_bufffer_head; |
| 384 | 388 | ||
| 385 | for (u8 i = 0; i < flush_count; i++) { | 389 | for (u8 i = 0; i < flush_count; i++) { |
| 386 | in_params.wave_buffer[wave_head].sent_to_dsp = true; | 390 | in_params.wave_buffer[static_cast<u16>(wave_head)].sent_to_dsp = true; |
| 387 | for (s32 channel = 0; channel < channel_count; channel++) { | 391 | for (size_t channel = 0; channel < static_cast<size_t>(channel_count); channel++) { |
| 388 | auto* dsp_state = dsp_voice_states[channel]; | 392 | auto* dsp_state = dsp_voice_states[channel]; |
| 389 | dsp_state->wave_buffer_consumed++; | 393 | dsp_state->wave_buffer_consumed++; |
| 390 | dsp_state->is_wave_buffer_valid[wave_head] = false; | 394 | dsp_state->is_wave_buffer_valid[static_cast<u16>(wave_head)] = false; |
| 391 | dsp_state->wave_buffer_index = | 395 | dsp_state->wave_buffer_index = static_cast<s32>( |
| 392 | (dsp_state->wave_buffer_index + 1) % AudioCommon::MAX_WAVE_BUFFERS; | 396 | static_cast<u32>(dsp_state->wave_buffer_index + 1) % AudioCommon::MAX_WAVE_BUFFERS); |
| 393 | } | 397 | } |
| 394 | wave_head = (wave_head + 1) % AudioCommon::MAX_WAVE_BUFFERS; | 398 | wave_head = |
| 399 | static_cast<s16>(static_cast<u32>(wave_head + 1) % AudioCommon::MAX_WAVE_BUFFERS); | ||
| 395 | } | 400 | } |
| 396 | } | 401 | } |
| 397 | 402 | ||
| @@ -483,7 +488,7 @@ s32 VoiceContext::DecodePcm16(s32* output_buffer, ServerWaveBuffer* wave_buffer, | |||
| 483 | const auto samples_remaining = | 488 | const auto samples_remaining = |
| 484 | (wave_buffer->end_sample_offset - wave_buffer->start_sample_offset) - buffer_offset; | 489 | (wave_buffer->end_sample_offset - wave_buffer->start_sample_offset) - buffer_offset; |
| 485 | const auto start_offset = (wave_buffer->start_sample_offset + buffer_offset) * channel_count; | 490 | const auto start_offset = (wave_buffer->start_sample_offset + buffer_offset) * channel_count; |
| 486 | const auto buffer_pos = wave_buffer->buffer_address + start_offset; | 491 | const auto buffer_pos = wave_buffer->buffer_address + static_cast<VAddr>(start_offset); |
| 487 | 492 | ||
| 488 | s16* buffer_data = reinterpret_cast<s16*>(memory.GetPointer(buffer_pos)); | 493 | s16* buffer_data = reinterpret_cast<s16*>(memory.GetPointer(buffer_pos)); |
| 489 | 494 | ||