summaryrefslogtreecommitdiff
path: root/src/audio_core/voice_context.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2020-10-20 19:07:39 -0700
committerGravatar GitHub2020-10-20 19:07:39 -0700
commit3d592972dc3fd61cc88771b889eff237e4e03e0f (patch)
tree0dbc65ac86e609ae22087c7be9d4759ac6b73004 /src/audio_core/voice_context.cpp
parentkernel: Fix build with recent compiler flag changes (diff)
downloadyuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.tar.gz
yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.tar.xz
yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.zip
Revert "core: Fix clang build"
Diffstat (limited to 'src/audio_core/voice_context.cpp')
-rw-r--r--src/audio_core/voice_context.cpp47
1 files changed, 21 insertions, 26 deletions
diff --git a/src/audio_core/voice_context.cpp b/src/audio_core/voice_context.cpp
index 276b96ca4..c46ee55f1 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 = static_cast<s32>(voice_in.node_id); 101 in_params.node_id = 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,10 +220,8 @@ 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 < 223 (buffer_size < (sizeof(s16) * in_wave_buffer.start_sample_offset)) ||
224 (sizeof(s16) * static_cast<u32>(in_wave_buffer.start_sample_offset))) || 224 (buffer_size < (sizeof(s16) * in_wave_buffer.end_sample_offset))) {
225 (buffer_size <
226 (sizeof(s16) * static_cast<u32>(in_wave_buffer.end_sample_offset)))) {
227 // TODO(ogniK): Write error info 225 // TODO(ogniK): Write error info
228 return; 226 return;
229 } 227 }
@@ -256,8 +254,8 @@ void ServerVoiceInfo::WriteOutStatus(
256 voice_out.played_sample_count = 0; 254 voice_out.played_sample_count = 0;
257 voice_out.voice_dropped = false; 255 voice_out.voice_dropped = false;
258 } else if (!in_params.is_new) { 256 } else if (!in_params.is_new) {
259 voice_out.wave_buffer_consumed = static_cast<u32>(voice_states[0]->wave_buffer_consumed); 257 voice_out.wave_buffer_consumed = voice_states[0]->wave_buffer_consumed;
260 voice_out.played_sample_count = static_cast<u64>(voice_states[0]->played_sample_count); 258 voice_out.played_sample_count = voice_states[0]->played_sample_count;
261 voice_out.voice_dropped = in_params.voice_drop_flag; 259 voice_out.voice_dropped = in_params.voice_drop_flag;
262 } else { 260 } else {
263 voice_out.wave_buffer_consumed = 0; 261 voice_out.wave_buffer_consumed = 0;
@@ -295,8 +293,8 @@ bool ServerVoiceInfo::UpdateForCommandGeneration(VoiceContext& voice_context) {
295 in_params.is_new = false; 293 in_params.is_new = false;
296 } 294 }
297 295
298 const auto channel_count = static_cast<size_t>(in_params.channel_count); 296 const s32 channel_count = in_params.channel_count;
299 for (size_t i = 0; i < channel_count; i++) { 297 for (s32 i = 0; i < channel_count; i++) {
300 const auto channel_resource = in_params.voice_channel_resource_id[i]; 298 const auto channel_resource = in_params.voice_channel_resource_id[i];
301 dsp_voice_states[i] = 299 dsp_voice_states[i] =
302 &voice_context.GetDspSharedState(static_cast<std::size_t>(channel_resource)); 300 &voice_context.GetDspSharedState(static_cast<std::size_t>(channel_resource));
@@ -305,9 +303,8 @@ bool ServerVoiceInfo::UpdateForCommandGeneration(VoiceContext& voice_context) {
305} 303}
306 304
307void ServerVoiceInfo::ResetResources(VoiceContext& voice_context) { 305void ServerVoiceInfo::ResetResources(VoiceContext& voice_context) {
308 const auto channel_count = static_cast<size_t>(in_params.channel_count); 306 const s32 channel_count = in_params.channel_count;
309 307 for (s32 i = 0; i < channel_count; i++) {
310 for (size_t i = 0; i < channel_count; i++) {
311 const auto channel_resource = in_params.voice_channel_resource_id[i]; 308 const auto channel_resource = in_params.voice_channel_resource_id[i];
312 auto& dsp_state = 309 auto& dsp_state =
313 voice_context.GetDspSharedState(static_cast<std::size_t>(channel_resource)); 310 voice_context.GetDspSharedState(static_cast<std::size_t>(channel_resource));
@@ -328,9 +325,9 @@ bool ServerVoiceInfo::UpdateParametersForCommandGeneration(
328 325
329 switch (in_params.current_playstate) { 326 switch (in_params.current_playstate) {
330 case ServerPlayState::Play: { 327 case ServerPlayState::Play: {
331 for (size_t i = 0; i < AudioCommon::MAX_WAVE_BUFFERS; i++) { 328 for (std::size_t i = 0; i < AudioCommon::MAX_WAVE_BUFFERS; i++) {
332 if (!in_params.wave_buffer[i].sent_to_dsp) { 329 if (!in_params.wave_buffer[i].sent_to_dsp) {
333 for (size_t channel = 0; channel < static_cast<size_t>(channel_count); channel++) { 330 for (s32 channel = 0; channel < channel_count; channel++) {
334 dsp_voice_states[channel]->is_wave_buffer_valid[i] = true; 331 dsp_voice_states[channel]->is_wave_buffer_valid[i] = true;
335 } 332 }
336 in_params.wave_buffer[i].sent_to_dsp = true; 333 in_params.wave_buffer[i].sent_to_dsp = true;
@@ -347,13 +344,12 @@ bool ServerVoiceInfo::UpdateParametersForCommandGeneration(
347 case ServerPlayState::RequestStop: { 344 case ServerPlayState::RequestStop: {
348 for (std::size_t i = 0; i < AudioCommon::MAX_WAVE_BUFFERS; i++) { 345 for (std::size_t i = 0; i < AudioCommon::MAX_WAVE_BUFFERS; i++) {
349 in_params.wave_buffer[i].sent_to_dsp = true; 346 in_params.wave_buffer[i].sent_to_dsp = true;
350 for (std::size_t channel = 0; channel < static_cast<size_t>(channel_count); channel++) { 347 for (s32 channel = 0; channel < channel_count; channel++) {
351 auto* dsp_state = dsp_voice_states[channel]; 348 auto* dsp_state = dsp_voice_states[channel];
352 349
353 if (dsp_state->is_wave_buffer_valid[i]) { 350 if (dsp_state->is_wave_buffer_valid[i]) {
354 dsp_state->wave_buffer_index = 351 dsp_state->wave_buffer_index =
355 static_cast<s32>(static_cast<u32>(dsp_state->wave_buffer_index + 1) % 352 (dsp_state->wave_buffer_index + 1) % AudioCommon::MAX_WAVE_BUFFERS;
356 AudioCommon::MAX_WAVE_BUFFERS);
357 dsp_state->wave_buffer_consumed++; 353 dsp_state->wave_buffer_consumed++;
358 } 354 }
359 355
@@ -361,7 +357,7 @@ bool ServerVoiceInfo::UpdateParametersForCommandGeneration(
361 } 357 }
362 } 358 }
363 359
364 for (size_t channel = 0; channel < static_cast<size_t>(channel_count); channel++) { 360 for (s32 channel = 0; channel < channel_count; channel++) {
365 auto* dsp_state = dsp_voice_states[channel]; 361 auto* dsp_state = dsp_voice_states[channel];
366 dsp_state->offset = 0; 362 dsp_state->offset = 0;
367 dsp_state->played_sample_count = 0; 363 dsp_state->played_sample_count = 0;
@@ -387,16 +383,15 @@ void ServerVoiceInfo::FlushWaveBuffers(
387 auto wave_head = in_params.wave_bufffer_head; 383 auto wave_head = in_params.wave_bufffer_head;
388 384
389 for (u8 i = 0; i < flush_count; i++) { 385 for (u8 i = 0; i < flush_count; i++) {
390 in_params.wave_buffer[static_cast<u16>(wave_head)].sent_to_dsp = true; 386 in_params.wave_buffer[wave_head].sent_to_dsp = true;
391 for (size_t channel = 0; channel < static_cast<size_t>(channel_count); channel++) { 387 for (s32 channel = 0; channel < channel_count; channel++) {
392 auto* dsp_state = dsp_voice_states[channel]; 388 auto* dsp_state = dsp_voice_states[channel];
393 dsp_state->wave_buffer_consumed++; 389 dsp_state->wave_buffer_consumed++;
394 dsp_state->is_wave_buffer_valid[static_cast<u16>(wave_head)] = false; 390 dsp_state->is_wave_buffer_valid[wave_head] = false;
395 dsp_state->wave_buffer_index = static_cast<s32>( 391 dsp_state->wave_buffer_index =
396 static_cast<u32>(dsp_state->wave_buffer_index + 1) % AudioCommon::MAX_WAVE_BUFFERS); 392 (dsp_state->wave_buffer_index + 1) % AudioCommon::MAX_WAVE_BUFFERS;
397 } 393 }
398 wave_head = 394 wave_head = (wave_head + 1) % AudioCommon::MAX_WAVE_BUFFERS;
399 static_cast<s16>(static_cast<u32>(wave_head + 1) % AudioCommon::MAX_WAVE_BUFFERS);
400 } 395 }
401} 396}
402 397
@@ -488,7 +483,7 @@ s32 VoiceContext::DecodePcm16(s32* output_buffer, ServerWaveBuffer* wave_buffer,
488 const auto samples_remaining = 483 const auto samples_remaining =
489 (wave_buffer->end_sample_offset - wave_buffer->start_sample_offset) - buffer_offset; 484 (wave_buffer->end_sample_offset - wave_buffer->start_sample_offset) - buffer_offset;
490 const auto start_offset = (wave_buffer->start_sample_offset + buffer_offset) * channel_count; 485 const auto start_offset = (wave_buffer->start_sample_offset + buffer_offset) * channel_count;
491 const auto buffer_pos = wave_buffer->buffer_address + static_cast<VAddr>(start_offset); 486 const auto buffer_pos = wave_buffer->buffer_address + start_offset;
492 487
493 s16* buffer_data = reinterpret_cast<s16*>(memory.GetPointer(buffer_pos)); 488 s16* buffer_data = reinterpret_cast<s16*>(memory.GetPointer(buffer_pos));
494 489