summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Lioncash2019-07-19 03:44:00 -0400
committerGravatar Lioncash2019-07-19 07:55:23 -0400
commitb9ebab71beaf9afc74788368846086a9c4648f4b (patch)
tree5a1ef62724e1cedab67cab1e3f61284745c3c131
parentservice/audio: Remove global system accessors (diff)
downloadyuzu-b9ebab71beaf9afc74788368846086a9c4648f4b.tar.gz
yuzu-b9ebab71beaf9afc74788368846086a9c4648f4b.tar.xz
yuzu-b9ebab71beaf9afc74788368846086a9c4648f4b.zip
service/audren_u: Move revision testing code out of AudRenU
The revision querying facilities are used by more than just audren. e.g. audio devices can use this to test whether or not USB audio output is supported. This will be used within the following change.
-rw-r--r--src/core/hle/service/audio/audren_u.cpp108
-rw-r--r--src/core/hle/service/audio/audren_u.h18
2 files changed, 63 insertions, 63 deletions
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp
index 6e9f6584f..8a7bf8a79 100644
--- a/src/core/hle/service/audio/audren_u.cpp
+++ b/src/core/hle/service/audio/audren_u.cpp
@@ -349,7 +349,7 @@ void AudRenU::GetAudioRendererWorkBufferSize(Kernel::HLERequestContext& ctx) {
349 }; 349 };
350 350
351 // Calculates the portion of the size related to the mix data (and the sorting thereof). 351 // Calculates the portion of the size related to the mix data (and the sorting thereof).
352 const auto calculate_mix_info_size = [this](const AudioCore::AudioRendererParameter& params) { 352 const auto calculate_mix_info_size = [](const AudioCore::AudioRendererParameter& params) {
353 // The size of the mixing info data structure. 353 // The size of the mixing info data structure.
354 constexpr u64 mix_info_size = 0x940; 354 constexpr u64 mix_info_size = 0x940;
355 355
@@ -421,7 +421,7 @@ void AudRenU::GetAudioRendererWorkBufferSize(Kernel::HLERequestContext& ctx) {
421 421
422 // Calculates the part of the size related to the splitter context. 422 // Calculates the part of the size related to the splitter context.
423 const auto calculate_splitter_context_size = 423 const auto calculate_splitter_context_size =
424 [this](const AudioCore::AudioRendererParameter& params) -> u64 { 424 [](const AudioCore::AudioRendererParameter& params) -> u64 {
425 if (!IsFeatureSupported(AudioFeatures::Splitter, params.revision)) { 425 if (!IsFeatureSupported(AudioFeatures::Splitter, params.revision)) {
426 return 0; 426 return 0;
427 } 427 }
@@ -468,7 +468,7 @@ void AudRenU::GetAudioRendererWorkBufferSize(Kernel::HLERequestContext& ctx) {
468 }; 468 };
469 469
470 // Calculates the part of the size related to performance statistics. 470 // Calculates the part of the size related to performance statistics.
471 const auto calculate_perf_size = [this](const AudioCore::AudioRendererParameter& params) { 471 const auto calculate_perf_size = [](const AudioCore::AudioRendererParameter& params) {
472 // Extra size value appended to the end of the calculation. 472 // Extra size value appended to the end of the calculation.
473 constexpr u64 appended = 128; 473 constexpr u64 appended = 128;
474 474
@@ -495,78 +495,76 @@ void AudRenU::GetAudioRendererWorkBufferSize(Kernel::HLERequestContext& ctx) {
495 }; 495 };
496 496
497 // Calculates the part of the size that relates to the audio command buffer. 497 // Calculates the part of the size that relates to the audio command buffer.
498 const auto calculate_command_buffer_size = 498 const auto calculate_command_buffer_size = [](const AudioCore::AudioRendererParameter& params) {
499 [this](const AudioCore::AudioRendererParameter& params) { 499 constexpr u64 alignment = (buffer_alignment_size - 1) * 2;
500 constexpr u64 alignment = (buffer_alignment_size - 1) * 2;
501 500
502 if (!IsFeatureSupported(AudioFeatures::VariadicCommandBuffer, params.revision)) { 501 if (!IsFeatureSupported(AudioFeatures::VariadicCommandBuffer, params.revision)) {
503 constexpr u64 command_buffer_size = 0x18000; 502 constexpr u64 command_buffer_size = 0x18000;
504 503
505 return command_buffer_size + alignment; 504 return command_buffer_size + alignment;
506 } 505 }
507 506
508 // When the variadic command buffer is supported, this means 507 // When the variadic command buffer is supported, this means
509 // the command generator for the audio renderer can issue commands 508 // the command generator for the audio renderer can issue commands
510 // that are (as one would expect), variable in size. So what we need to do 509 // that are (as one would expect), variable in size. So what we need to do
511 // is determine the maximum possible size for a few command data structures 510 // is determine the maximum possible size for a few command data structures
512 // then multiply them by the amount of present commands indicated by the given 511 // then multiply them by the amount of present commands indicated by the given
513 // respective audio parameters. 512 // respective audio parameters.
514 513
515 constexpr u64 max_biquad_filters = 2; 514 constexpr u64 max_biquad_filters = 2;
516 constexpr u64 max_mix_buffers = 24; 515 constexpr u64 max_mix_buffers = 24;
517 516
518 constexpr u64 biquad_filter_command_size = 0x2C; 517 constexpr u64 biquad_filter_command_size = 0x2C;
519 518
520 constexpr u64 depop_mix_command_size = 0x24; 519 constexpr u64 depop_mix_command_size = 0x24;
521 constexpr u64 depop_setup_command_size = 0x50; 520 constexpr u64 depop_setup_command_size = 0x50;
522 521
523 constexpr u64 effect_command_max_size = 0x540; 522 constexpr u64 effect_command_max_size = 0x540;
524 523
525 constexpr u64 mix_command_size = 0x1C; 524 constexpr u64 mix_command_size = 0x1C;
526 constexpr u64 mix_ramp_command_size = 0x24; 525 constexpr u64 mix_ramp_command_size = 0x24;
527 constexpr u64 mix_ramp_grouped_command_size = 0x13C; 526 constexpr u64 mix_ramp_grouped_command_size = 0x13C;
528 527
529 constexpr u64 perf_command_size = 0x28; 528 constexpr u64 perf_command_size = 0x28;
530 529
531 constexpr u64 sink_command_size = 0x130; 530 constexpr u64 sink_command_size = 0x130;
532 531
533 constexpr u64 submix_command_max_size = 532 constexpr u64 submix_command_max_size =
534 depop_mix_command_size + (mix_command_size * max_mix_buffers) * max_mix_buffers; 533 depop_mix_command_size + (mix_command_size * max_mix_buffers) * max_mix_buffers;
535 534
536 constexpr u64 volume_command_size = 0x1C; 535 constexpr u64 volume_command_size = 0x1C;
537 constexpr u64 volume_ramp_command_size = 0x20; 536 constexpr u64 volume_ramp_command_size = 0x20;
538 537
539 constexpr u64 voice_biquad_filter_command_size = 538 constexpr u64 voice_biquad_filter_command_size =
540 biquad_filter_command_size * max_biquad_filters; 539 biquad_filter_command_size * max_biquad_filters;
541 constexpr u64 voice_data_command_size = 0x9C; 540 constexpr u64 voice_data_command_size = 0x9C;
542 const u64 voice_command_max_size = 541 const u64 voice_command_max_size =
543 (params.splitter_count * depop_setup_command_size) + 542 (params.splitter_count * depop_setup_command_size) +
544 (voice_data_command_size + voice_biquad_filter_command_size + 543 (voice_data_command_size + voice_biquad_filter_command_size + volume_ramp_command_size +
545 volume_ramp_command_size + mix_ramp_grouped_command_size); 544 mix_ramp_grouped_command_size);
546 545
547 // Now calculate the individual elements that comprise the size and add them together. 546 // Now calculate the individual elements that comprise the size and add them together.
548 const u64 effect_commands_size = params.effect_count * effect_command_max_size; 547 const u64 effect_commands_size = params.effect_count * effect_command_max_size;
549 548
550 const u64 final_mix_commands_size = 549 const u64 final_mix_commands_size =
551 depop_mix_command_size + volume_command_size * max_mix_buffers; 550 depop_mix_command_size + volume_command_size * max_mix_buffers;
552 551
553 const u64 perf_commands_size = 552 const u64 perf_commands_size =
554 perf_command_size * 553 perf_command_size * (CalculateNumPerformanceEntries(params) + max_perf_detail_entries);
555 (CalculateNumPerformanceEntries(params) + max_perf_detail_entries);
556 554
557 const u64 sink_commands_size = params.sink_count * sink_command_size; 555 const u64 sink_commands_size = params.sink_count * sink_command_size;
558 556
559 const u64 splitter_commands_size = 557 const u64 splitter_commands_size =
560 params.num_splitter_send_channels * max_mix_buffers * mix_ramp_command_size; 558 params.num_splitter_send_channels * max_mix_buffers * mix_ramp_command_size;
561 559
562 const u64 submix_commands_size = params.submix_count * submix_command_max_size; 560 const u64 submix_commands_size = params.submix_count * submix_command_max_size;
563 561
564 const u64 voice_commands_size = params.voice_count * voice_command_max_size; 562 const u64 voice_commands_size = params.voice_count * voice_command_max_size;
565 563
566 return effect_commands_size + final_mix_commands_size + perf_commands_size + 564 return effect_commands_size + final_mix_commands_size + perf_commands_size +
567 sink_commands_size + splitter_commands_size + submix_commands_size + 565 sink_commands_size + splitter_commands_size + submix_commands_size +
568 voice_commands_size + alignment; 566 voice_commands_size + alignment;
569 }; 567 };
570 568
571 IPC::RequestParser rp{ctx}; 569 IPC::RequestParser rp{ctx};
572 const auto params = rp.PopRaw<AudioCore::AudioRendererParameter>(); 570 const auto params = rp.PopRaw<AudioCore::AudioRendererParameter>();
@@ -633,7 +631,7 @@ void AudRenU::OpenAudioRendererImpl(Kernel::HLERequestContext& ctx) {
633 rb.PushIpcInterface<IAudioRenderer>(system, params, audren_instance_count++); 631 rb.PushIpcInterface<IAudioRenderer>(system, params, audren_instance_count++);
634} 632}
635 633
636bool AudRenU::IsFeatureSupported(AudioFeatures feature, u32_le revision) const { 634bool IsFeatureSupported(AudioFeatures feature, u32_le revision) {
637 // Byte swap 635 // Byte swap
638 const u32_be version_num = revision - Common::MakeMagic('R', 'E', 'V', '0'); 636 const u32_be version_num = revision - Common::MakeMagic('R', 'E', 'V', '0');
639 637
diff --git a/src/core/hle/service/audio/audren_u.h b/src/core/hle/service/audio/audren_u.h
index 6e17489ce..0f3aad501 100644
--- a/src/core/hle/service/audio/audren_u.h
+++ b/src/core/hle/service/audio/audren_u.h
@@ -30,16 +30,18 @@ private:
30 30
31 void OpenAudioRendererImpl(Kernel::HLERequestContext& ctx); 31 void OpenAudioRendererImpl(Kernel::HLERequestContext& ctx);
32 32
33 enum class AudioFeatures : u32 {
34 Splitter,
35 PerformanceMetricsVersion2,
36 VariadicCommandBuffer,
37 };
38
39 bool IsFeatureSupported(AudioFeatures feature, u32_le revision) const;
40
41 std::size_t audren_instance_count = 0; 33 std::size_t audren_instance_count = 0;
42 Core::System& system; 34 Core::System& system;
43}; 35};
44 36
37// Describes a particular audio feature that may be supported in a particular revision.
38enum class AudioFeatures : u32 {
39 Splitter,
40 PerformanceMetricsVersion2,
41 VariadicCommandBuffer,
42};
43
44// Tests if a particular audio feature is supported with a given audio revision.
45bool IsFeatureSupported(AudioFeatures feature, u32_le revision);
46
45} // namespace Service::Audio 47} // namespace Service::Audio