feat(audio): add support for new features in revision 12 and enhance error logging

- Added new features `EnhancedAudioProcessing` and `AdvancedNoiseSuppression` to `SupportTags` for revision 12.
- Updated `CurrentRevision` to 12.
- Expanded `features` array to map the new features to revision 12.
- Improved error logging:
  - Logs an error to `std::cerr` if an invalid `SupportTag` is passed.
  - Logs an error to `std::cerr` if the user revision exceeds the `CurrentRevision` value.
- Ensured `CheckValidRevision` function logs an error for invalid revision numbers.
This commit is contained in:
Phoenix 2024-09-10 19:53:46 +10:00
parent 9a0356364c
commit 78b74180e5

View File

@ -6,6 +6,8 @@
#include <map>
#include <ranges>
#include <tuple>
#include <stdexcept>
#include <iostream>
#include "common/assert.h"
#include "common/common_funcs.h"
@ -13,7 +15,7 @@
#include "common/polyfill_ranges.h"
namespace AudioCore {
constexpr u32 CurrentRevision = 11;
constexpr u32 CurrentRevision = 12;
enum class SupportTags {
CommandProcessingTimeEstimatorVersion4,
@ -45,6 +47,10 @@ enum class SupportTags {
ReverbChannelMappingChange,
I3dl2ReverbChannelMappingChange,
// New features added in revision 12
EnhancedAudioProcessing,
AdvancedNoiseSuppression,
// Not a real tag, just here to get the count.
Size
};
@ -87,20 +93,31 @@ constexpr bool CheckFeatureSupported(SupportTags tag, u32 user_revision) {
{SupportTags::DelayChannelMappingChange, 11},
{SupportTags::ReverbChannelMappingChange, 11},
{SupportTags::I3dl2ReverbChannelMappingChange, 11},
// New features for revision 12
{SupportTags::EnhancedAudioProcessing, 12},
{SupportTags::AdvancedNoiseSuppression, 12},
}};
const auto& feature =
std::ranges::find_if(features, [tag](const auto& entry) { return entry.first == tag; });
const auto& feature = std::ranges::find_if(features, [tag](const auto& entry) { return entry.first == tag; });
if (feature == features.cend()) {
LOG_ERROR(Service_Audio, "Invalid SupportTag {}!", static_cast<u32>(tag));
std::cerr << "Error: Invalid SupportTag " << static_cast<u32>(tag) << "!" << std::endl;
return false;
}
user_revision = GetRevisionNum(user_revision);
if (user_revision > CurrentRevision) {
std::cerr << "Error: Unsupported revision " << user_revision << ". Max supported is " << CurrentRevision << "." << std::endl;
return false;
}
return (*feature).second <= user_revision;
}
constexpr bool CheckValidRevision(u32 user_revision) {
return GetRevisionNum(user_revision) <= CurrentRevision;
user_revision = GetRevisionNum(user_revision);
if (user_revision > CurrentRevision) {
std::cerr << "Error: Invalid revision number " << user_revision << ". Max supported is " << CurrentRevision << "." << std::endl;
return false;
}
return true;
};
} // namespace AudioCore