From 6ecbc6c557e49d2531892b6d40c298c7d4a6f63c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 19 Jul 2019 00:13:57 -0400 Subject: service/audren_u: Report proper device names AudioDevice and AudioInterface aren't valid device names on the Switch. We should also be returning consistent names in GetActiveAudioDeviceName(). While we're at it, we can also handle proper name output in ListAudioDeviceName, by returning all the available devices on the Switch. --- src/core/hle/service/audio/audren_u.cpp | 35 +++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'src/core/hle') diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index 679299f68..8b12b8201 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "audio_core/audio_renderer.h" #include "common/alignment.h" @@ -160,7 +161,7 @@ private: class IAudioDevice final : public ServiceFramework { public: - IAudioDevice() : ServiceFramework("IAudioDevice") { + explicit IAudioDevice() : ServiceFramework("IAudioDevice") { static const FunctionInfo functions[] = { {0, &IAudioDevice::ListAudioDeviceName, "ListAudioDeviceName"}, {1, &IAudioDevice::SetAudioDeviceOutputVolume, "SetAudioDeviceOutputVolume"}, @@ -189,15 +190,32 @@ public: } private: + using AudioDeviceName = std::array; + static constexpr std::array audio_device_names{{ + "AudioStereoJackOutput", + "AudioBuiltInSpeakerOutput", + "AudioTvOutput", + "AudioUsbDeviceOutput", + }}; + void ListAudioDeviceName(Kernel::HLERequestContext& ctx) { LOG_WARNING(Service_Audio, "(STUBBED) called"); - constexpr std::array audio_interface{{"AudioInterface"}}; - ctx.WriteBuffer(audio_interface); + const std::size_t num_names_requested = ctx.GetWriteBufferSize() / sizeof(AudioDeviceName); + const std::size_t num_to_copy = std::min(num_names_requested, audio_device_names.size()); + std::vector name_buffer(num_to_copy); + + for (std::size_t i = 0; i < num_to_copy; i++) { + const auto& device_name = audio_device_names[i]; + + device_name.copy(name_buffer[i].data(), device_name.size()); + } + + ctx.WriteBuffer(name_buffer); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(RESULT_SUCCESS); - rb.Push(1); + rb.Push(static_cast(num_to_copy)); } void SetAudioDeviceOutputVolume(Kernel::HLERequestContext& ctx) { @@ -216,8 +234,13 @@ private: void GetActiveAudioDeviceName(Kernel::HLERequestContext& ctx) { LOG_WARNING(Service_Audio, "(STUBBED) called"); - constexpr std::array audio_interface{{"AudioDevice"}}; - ctx.WriteBuffer(audio_interface); + // Currently set to always be TV audio output. + const auto& device_name = audio_device_names[2]; + + AudioDeviceName out_device_name{}; + device_name.copy(out_device_name.data(), device_name.size()); + + ctx.WriteBuffer(out_device_name); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(RESULT_SUCCESS); -- cgit v1.2.3