summaryrefslogtreecommitdiff
path: root/src/audio_core/voice_context.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2020-10-15 14:49:45 -0400
committerGravatar Lioncash2020-10-17 19:50:39 -0400
commitbe1954e04cb5a0c3a526f78ed5490a5e65310280 (patch)
tree267db7ae4be88dbbc288fa605e35d4a2a13839f6 /src/audio_core/voice_context.cpp
parentMerge pull request #4787 from lioncash/conversion (diff)
downloadyuzu-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/voice_context.cpp')
-rw-r--r--src/audio_core/voice_context.cpp47
1 files changed, 26 insertions, 21 deletions
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
305void ServerVoiceInfo::ResetResources(VoiceContext& voice_context) { 307void 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