Stub some IAudioDevice calls

This commit is contained in:
Dima 2022-12-06 19:53:37 +03:00 committed by Billy Laws
parent 3a94bcf692
commit efef67b92b
2 changed files with 31 additions and 1 deletions

View File

@ -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<std::string_view, 3> 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<u32>(devices.size());
return {};
}
}

View File

@ -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)
)
};
}