|
@@ -1,6 +1,9 @@
|
|
|
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
|
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
|
|
+#include <array>
|
|
|
|
|
+#include <span>
|
|
|
|
|
+
|
|
|
#include "audio_core/audio_core.h"
|
|
#include "audio_core/audio_core.h"
|
|
|
#include "audio_core/common/feature_support.h"
|
|
#include "audio_core/common/feature_support.h"
|
|
|
#include "audio_core/renderer/audio_device.h"
|
|
#include "audio_core/renderer/audio_device.h"
|
|
@@ -9,14 +12,33 @@
|
|
|
|
|
|
|
|
namespace AudioCore::AudioRenderer {
|
|
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_,
|
|
AudioDevice::AudioDevice(Core::System& system, const u64 applet_resource_user_id_,
|
|
|
const u32 revision)
|
|
const u32 revision)
|
|
|
: output_sink{system.AudioCore().GetOutputSink()},
|
|
: output_sink{system.AudioCore().GetOutputSink()},
|
|
|
applet_resource_user_id{applet_resource_user_id_}, user_revision{revision} {}
|
|
applet_resource_user_id{applet_resource_user_id_}, user_revision{revision} {}
|
|
|
|
|
|
|
|
u32 AudioDevice::ListAudioDeviceName(std::vector<AudioDeviceName>& out_buffer,
|
|
u32 AudioDevice::ListAudioDeviceName(std::vector<AudioDeviceName>& out_buffer,
|
|
|
- const size_t max_count) {
|
|
|
|
|
- std::span<AudioDeviceName> names{};
|
|
|
|
|
|
|
+ const size_t max_count) const {
|
|
|
|
|
+ std::span<const AudioDeviceName> names{};
|
|
|
|
|
|
|
|
if (CheckFeatureSupported(SupportTags::AudioUsbDeviceOutput, user_revision)) {
|
|
if (CheckFeatureSupported(SupportTags::AudioUsbDeviceOutput, user_revision)) {
|
|
|
names = usb_device_names;
|
|
names = usb_device_names;
|
|
@@ -24,7 +46,7 @@ u32 AudioDevice::ListAudioDeviceName(std::vector<AudioDeviceName>& out_buffer,
|
|
|
names = device_names;
|
|
names = device_names;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- u32 out_count{static_cast<u32>(std::min(max_count, names.size()))};
|
|
|
|
|
|
|
+ const u32 out_count{static_cast<u32>(std::min(max_count, names.size()))};
|
|
|
for (u32 i = 0; i < out_count; i++) {
|
|
for (u32 i = 0; i < out_count; i++) {
|
|
|
out_buffer.push_back(names[i]);
|
|
out_buffer.push_back(names[i]);
|
|
|
}
|
|
}
|
|
@@ -32,8 +54,8 @@ u32 AudioDevice::ListAudioDeviceName(std::vector<AudioDeviceName>& out_buffer,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
u32 AudioDevice::ListAudioOutputDeviceName(std::vector<AudioDeviceName>& out_buffer,
|
|
u32 AudioDevice::ListAudioOutputDeviceName(std::vector<AudioDeviceName>& out_buffer,
|
|
|
- const size_t max_count) {
|
|
|
|
|
- u32 out_count{static_cast<u32>(std::min(max_count, output_device_names.size()))};
|
|
|
|
|
|
|
+ const size_t max_count) const {
|
|
|
|
|
+ const u32 out_count{static_cast<u32>(std::min(max_count, output_device_names.size()))};
|
|
|
|
|
|
|
|
for (u32 i = 0; i < out_count; i++) {
|
|
for (u32 i = 0; i < out_count; i++) {
|
|
|
out_buffer.push_back(output_device_names[i]);
|
|
out_buffer.push_back(output_device_names[i]);
|
|
@@ -45,7 +67,7 @@ void AudioDevice::SetDeviceVolumes(const f32 volume) {
|
|
|
output_sink.SetDeviceVolume(volume);
|
|
output_sink.SetDeviceVolume(volume);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-f32 AudioDevice::GetDeviceVolume([[maybe_unused]] std::string_view name) {
|
|
|
|
|
|
|
+f32 AudioDevice::GetDeviceVolume([[maybe_unused]] std::string_view name) const {
|
|
|
return output_sink.GetDeviceVolume();
|
|
return output_sink.GetDeviceVolume();
|
|
|
}
|
|
}
|
|
|
|
|
|