diff --git a/app/src/main/cpp/skyline/services/audio/IAudioDevice.cpp b/app/src/main/cpp/skyline/services/audio/IAudioDevice.cpp index 58668b44..af7c6ae3 100644 --- a/app/src/main/cpp/skyline/services/audio/IAudioDevice.cpp +++ b/app/src/main/cpp/skyline/services/audio/IAudioDevice.cpp @@ -62,4 +62,25 @@ namespace skyline::service::audio { response.copyHandles.push_back(handle); return {}; } + + Result IAudioDevice::GetActiveAudioOutputDeviceName(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + std::string_view deviceName{"AudioTvOutput\0"}; + if (deviceName.size() > request.outputBuf.at(0).size()) + throw exception("The buffer supplied to GetActiveAudioDeviceName is too small"); + request.outputBuf.at(0).copy_from(deviceName); + return {}; + } + + Result IAudioDevice::ListAudioOutputDeviceName(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + span buffer{request.outputBuf.at(0)}; + std::array devices{"AudioExternalOutput\0", "AudioBuiltInSpeakerOutput\0", "AudioTvOutput\0"}; + for (std::string_view deviceName : devices) { + if (deviceName.size() > buffer.size()) + throw exception("The buffer supplied to ListAudioDeviceName is too small"); + buffer.copy_from(deviceName); + buffer = buffer.subspan(deviceName.size()); + } + response.Push(devices.size()); + return {}; + } } diff --git a/app/src/main/cpp/skyline/services/audio/IAudioDevice.h b/app/src/main/cpp/skyline/services/audio/IAudioDevice.h index 0a8a716b..e53e281d 100644 --- a/app/src/main/cpp/skyline/services/audio/IAudioDevice.h +++ b/app/src/main/cpp/skyline/services/audio/IAudioDevice.h @@ -51,6 +51,13 @@ namespace skyline::service::audio { Result QueryAudioDeviceOutputEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + /** + * @url https://switchbrew.org/wiki/Audio_services#GetActiveAudioOutputDeviceName + */ + Result GetActiveAudioOutputDeviceName(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + Result ListAudioOutputDeviceName(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + SERVICE_DECL( SFUNC(0x0, IAudioDevice, ListAudioDeviceName), SFUNC(0x1, IAudioDevice, SetAudioDeviceOutputVolume), @@ -61,7 +68,9 @@ namespace skyline::service::audio { SFUNC(0x7, IAudioDevice, SetAudioDeviceOutputVolume), SFUNC(0xA, IAudioDevice, GetActiveAudioDeviceName), SFUNC(0xB, IAudioDevice, QueryAudioDeviceInputEvent), - SFUNC(0xC, IAudioDevice, QueryAudioDeviceOutputEvent) + SFUNC(0xC, IAudioDevice, QueryAudioDeviceOutputEvent), + SFUNC(0xD, IAudioDevice, GetActiveAudioOutputDeviceName), + SFUNC(0xE, IAudioDevice, ListAudioOutputDeviceName) ) }; }