diff options
| author | 2019-07-19 00:13:57 -0400 | |
|---|---|---|
| committer | 2019-07-19 06:57:30 -0400 | |
| commit | 6ecbc6c557e49d2531892b6d40c298c7d4a6f63c (patch) | |
| tree | dcbd615421fb81ef1010c9ae29eefa9d27fd1447 /src/core | |
| parent | Merge pull request #2687 from lioncash/tls-process (diff) | |
| download | yuzu-6ecbc6c557e49d2531892b6d40c298c7d4a6f63c.tar.gz yuzu-6ecbc6c557e49d2531892b6d40c298c7d4a6f63c.tar.xz yuzu-6ecbc6c557e49d2531892b6d40c298c7d4a6f63c.zip | |
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.
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hle/service/audio/audren_u.cpp | 35 |
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 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 @@ | |||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <array> | 6 | #include <array> |
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <string_view> | ||
| 8 | 9 | ||
| 9 | #include "audio_core/audio_renderer.h" | 10 | #include "audio_core/audio_renderer.h" |
| 10 | #include "common/alignment.h" | 11 | #include "common/alignment.h" |
| @@ -160,7 +161,7 @@ private: | |||
| 160 | 161 | ||
| 161 | class IAudioDevice final : public ServiceFramework<IAudioDevice> { | 162 | class IAudioDevice final : public ServiceFramework<IAudioDevice> { |
| 162 | public: | 163 | public: |
| 163 | IAudioDevice() : ServiceFramework("IAudioDevice") { | 164 | explicit IAudioDevice() : ServiceFramework("IAudioDevice") { |
| 164 | static const FunctionInfo functions[] = { | 165 | static const FunctionInfo functions[] = { |
| 165 | {0, &IAudioDevice::ListAudioDeviceName, "ListAudioDeviceName"}, | 166 | {0, &IAudioDevice::ListAudioDeviceName, "ListAudioDeviceName"}, |
| 166 | {1, &IAudioDevice::SetAudioDeviceOutputVolume, "SetAudioDeviceOutputVolume"}, | 167 | {1, &IAudioDevice::SetAudioDeviceOutputVolume, "SetAudioDeviceOutputVolume"}, |
| @@ -189,15 +190,32 @@ public: | |||
| 189 | } | 190 | } |
| 190 | 191 | ||
| 191 | private: | 192 | private: |
| 193 | using AudioDeviceName = std::array<char, 256>; | ||
| 194 | static constexpr std::array<std::string_view, 4> audio_device_names{{ | ||
| 195 | "AudioStereoJackOutput", | ||
| 196 | "AudioBuiltInSpeakerOutput", | ||
| 197 | "AudioTvOutput", | ||
| 198 | "AudioUsbDeviceOutput", | ||
| 199 | }}; | ||
| 200 | |||
| 192 | void ListAudioDeviceName(Kernel::HLERequestContext& ctx) { | 201 | void ListAudioDeviceName(Kernel::HLERequestContext& ctx) { |
| 193 | LOG_WARNING(Service_Audio, "(STUBBED) called"); | 202 | LOG_WARNING(Service_Audio, "(STUBBED) called"); |
| 194 | 203 | ||
| 195 | constexpr std::array<char, 15> audio_interface{{"AudioInterface"}}; | 204 | const std::size_t num_names_requested = ctx.GetWriteBufferSize() / sizeof(AudioDeviceName); |
| 196 | ctx.WriteBuffer(audio_interface); | 205 | const std::size_t num_to_copy = std::min(num_names_requested, audio_device_names.size()); |
| 206 | std::vector<AudioDeviceName> name_buffer(num_to_copy); | ||
| 207 | |||
| 208 | for (std::size_t i = 0; i < num_to_copy; i++) { | ||
| 209 | const auto& device_name = audio_device_names[i]; | ||
| 210 | |||
| 211 | device_name.copy(name_buffer[i].data(), device_name.size()); | ||
| 212 | } | ||
| 213 | |||
| 214 | ctx.WriteBuffer(name_buffer); | ||
| 197 | 215 | ||
| 198 | IPC::ResponseBuilder rb{ctx, 3}; | 216 | IPC::ResponseBuilder rb{ctx, 3}; |
| 199 | rb.Push(RESULT_SUCCESS); | 217 | rb.Push(RESULT_SUCCESS); |
| 200 | rb.Push<u32>(1); | 218 | rb.Push(static_cast<u32>(num_to_copy)); |
| 201 | } | 219 | } |
| 202 | 220 | ||
| 203 | void SetAudioDeviceOutputVolume(Kernel::HLERequestContext& ctx) { | 221 | void SetAudioDeviceOutputVolume(Kernel::HLERequestContext& ctx) { |
| @@ -216,8 +234,13 @@ private: | |||
| 216 | void GetActiveAudioDeviceName(Kernel::HLERequestContext& ctx) { | 234 | void GetActiveAudioDeviceName(Kernel::HLERequestContext& ctx) { |
| 217 | LOG_WARNING(Service_Audio, "(STUBBED) called"); | 235 | LOG_WARNING(Service_Audio, "(STUBBED) called"); |
| 218 | 236 | ||
| 219 | constexpr std::array<char, 12> audio_interface{{"AudioDevice"}}; | 237 | // Currently set to always be TV audio output. |
| 220 | ctx.WriteBuffer(audio_interface); | 238 | const auto& device_name = audio_device_names[2]; |
| 239 | |||
| 240 | AudioDeviceName out_device_name{}; | ||
| 241 | device_name.copy(out_device_name.data(), device_name.size()); | ||
| 242 | |||
| 243 | ctx.WriteBuffer(out_device_name); | ||
| 221 | 244 | ||
| 222 | IPC::ResponseBuilder rb{ctx, 3}; | 245 | IPC::ResponseBuilder rb{ctx, 3}; |
| 223 | rb.Push(RESULT_SUCCESS); | 246 | rb.Push(RESULT_SUCCESS); |