summaryrefslogtreecommitdiffstats
path: root/src/audio_core/renderer
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2022-09-14 09:32:14 +0200
committerLioncash <mathew1800@gmail.com>2022-09-15 15:03:40 +0200
commit1c7dae966d52287ba5812c27d2fe0c59938aa416 (patch)
tree35709e02b9e5c0ef33f3bac4dadfb8bb3e8e3baf /src/audio_core/renderer
parentMerge pull request #8880 from german77/slow-moving (diff)
downloadyuzu-1c7dae966d52287ba5812c27d2fe0c59938aa416.tar
yuzu-1c7dae966d52287ba5812c27d2fe0c59938aa416.tar.gz
yuzu-1c7dae966d52287ba5812c27d2fe0c59938aa416.tar.bz2
yuzu-1c7dae966d52287ba5812c27d2fe0c59938aa416.tar.lz
yuzu-1c7dae966d52287ba5812c27d2fe0c59938aa416.tar.xz
yuzu-1c7dae966d52287ba5812c27d2fe0c59938aa416.tar.zst
yuzu-1c7dae966d52287ba5812c27d2fe0c59938aa416.zip
Diffstat (limited to 'src/audio_core/renderer')
-rw-r--r--src/audio_core/renderer/audio_device.cpp24
-rw-r--r--src/audio_core/renderer/audio_device.h16
2 files changed, 27 insertions, 13 deletions
diff --git a/src/audio_core/renderer/audio_device.cpp b/src/audio_core/renderer/audio_device.cpp
index d5886e55e..a4696065e 100644
--- a/src/audio_core/renderer/audio_device.cpp
+++ b/src/audio_core/renderer/audio_device.cpp
@@ -1,6 +1,9 @@
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
+#include <array>
+#include <span>
+
#include "audio_core/audio_core.h"
#include "audio_core/common/feature_support.h"
#include "audio_core/renderer/audio_device.h"
@@ -9,6 +12,25 @@
namespace AudioCore::AudioRenderer {
+constexpr std::array usb_device_names{
+ AudioDevice::AudioDeviceName{"AudioStereoJackOutput"},
+ AudioDevice::AudioDeviceName{"AudioBuiltInSpeakerOutput"},
+ AudioDevice::AudioDeviceName{"AudioTvOutput"},
+ AudioDevice::AudioDeviceName{"AudioUsbDeviceOutput"},
+};
+
+constexpr std::array device_names{
+ AudioDevice::AudioDeviceName{"AudioStereoJackOutput"},
+ AudioDevice::AudioDeviceName{"AudioBuiltInSpeakerOutput"},
+ AudioDevice::AudioDeviceName{"AudioTvOutput"},
+};
+
+constexpr std::array output_device_names{
+ AudioDevice::AudioDeviceName{"AudioBuiltInSpeakerOutput"},
+ AudioDevice::AudioDeviceName{"AudioTvOutput"},
+ AudioDevice::AudioDeviceName{"AudioExternalOutput"},
+};
+
AudioDevice::AudioDevice(Core::System& system, const u64 applet_resource_user_id_,
const u32 revision)
: output_sink{system.AudioCore().GetOutputSink()},
@@ -16,7 +38,7 @@ AudioDevice::AudioDevice(Core::System& system, const u64 applet_resource_user_id
u32 AudioDevice::ListAudioDeviceName(std::vector<AudioDeviceName>& out_buffer,
const size_t max_count) {
- std::span<AudioDeviceName> names{};
+ std::span<const AudioDeviceName> names{};
if (CheckFeatureSupported(SupportTags::AudioUsbDeviceOutput, user_revision)) {
names = usb_device_names;
diff --git a/src/audio_core/renderer/audio_device.h b/src/audio_core/renderer/audio_device.h
index 1f449f261..ba1f4c748 100644
--- a/src/audio_core/renderer/audio_device.h
+++ b/src/audio_core/renderer/audio_device.h
@@ -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);
/**