summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-07-19 00:13:57 -0400
committerLioncash <mathew1800@gmail.com>2019-07-19 06:57:30 -0400
commit6ecbc6c557e49d2531892b6d40c298c7d4a6f63c (patch)
treedcbd615421fb81ef1010c9ae29eefa9d27fd1447
parent5d369112d9d467d4257e24ce57f3ebba824556f0 (diff)
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.
-rw-r--r--src/core/hle/service/audio/audren_u.cpp35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp
index 679299f683..8b12b82017 100644
--- a/src/core/hle/service/audio/audren_u.cpp
+++ b/src/core/hle/service/audio/audren_u.cpp
@@ -5,6 +5,7 @@
#include <algorithm>
#include <array>
#include <memory>
+#include <string_view>
#include "audio_core/audio_renderer.h"
#include "common/alignment.h"
@@ -160,7 +161,7 @@ private:
class IAudioDevice final : public ServiceFramework<IAudioDevice> {
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<char, 256>;
+ static constexpr std::array<std::string_view, 4> audio_device_names{{
+ "AudioStereoJackOutput",
+ "AudioBuiltInSpeakerOutput",
+ "AudioTvOutput",
+ "AudioUsbDeviceOutput",
+ }};
+
void ListAudioDeviceName(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_Audio, "(STUBBED) called");
- constexpr std::array<char, 15> 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<AudioDeviceName> 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<u32>(1);
+ rb.Push(static_cast<u32>(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<char, 12> 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);