audio_device: Make AudioDeviceName constructor constexpr

These are used as read-only arrays, so we can make the data read-only
and available at compile-time.

Now constructing an AudioDevice no longer needs to initialize some
tables
This commit is contained in:
Lioncash
2022-09-14 03:32:14 -04:00
parent 1be456db83
commit 1c7dae966d
5 changed files with 30 additions and 17 deletions

View File

@ -3,7 +3,7 @@
#pragma once
#include <span>
#include <string_view>
#include "audio_core/audio_render_manager.h"
@ -23,21 +23,13 @@ namespace AudioRenderer {
class AudioDevice {
public:
struct AudioDeviceName {
std::array<char, 0x100> name;
std::array<char, 0x100> name{};
AudioDeviceName(const char* name_) {
std::strncpy(name.data(), name_, name.size());
constexpr AudioDeviceName(std::string_view name_) {
name_.copy(name.data(), name.size() - 1);
}
};
std::array<AudioDeviceName, 4> usb_device_names{"AudioStereoJackOutput",
"AudioBuiltInSpeakerOutput", "AudioTvOutput",
"AudioUsbDeviceOutput"};
std::array<AudioDeviceName, 3> device_names{"AudioStereoJackOutput",
"AudioBuiltInSpeakerOutput", "AudioTvOutput"};
std::array<AudioDeviceName, 3> output_device_names{"AudioBuiltInSpeakerOutput", "AudioTvOutput",
"AudioExternalOutput"};
explicit AudioDevice(Core::System& system, u64 applet_resource_user_id, u32 revision);
/**