From c17e1f99f0d9047681ead1d51ff498cd252c2b3c Mon Sep 17 00:00:00 2001 From: Ac_K Date: Fri, 11 Oct 2019 17:54:29 +0200 Subject: audout:u: Implement SetAudioOutVolume and GetAudioOutVolume (#781) * audout:u: Implement SetAudioOutVolume and GetAudioOutVolume - Implementation of `audout:u` SetAudioOutVolume and GetAudioOutVolume (checked with RE). - Add Get and Set for Volume into audio backends. - Cleanup of all audio backends to follow the `IAalOutput` structure and .NET standard. - Split OpenAL backend into 2 files for consistency. * Address comments * Fix the volume calculation --- .../Services/Audio/AudioOutManager/IAudioOut.cs | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'Ryujinx.HLE/HOS/Services/Audio/AudioOutManager') diff --git a/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager/IAudioOut.cs b/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager/IAudioOut.cs index 5b6983d6..11d8036c 100644 --- a/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager/IAudioOut.cs +++ b/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager/IAudioOut.cs @@ -147,6 +147,32 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioOutManager return ResultCode.Success; } + [Command(12)] // 6.0.0+ + // SetAudioOutVolume(s32) + public ResultCode SetAudioOutVolume(ServiceCtx context) + { + // Games send a gain value here, so we need to apply it on the current volume value. + + float gain = context.RequestData.ReadSingle(); + float currentVolume = _audioOut.GetVolume(); + float newVolume = Math.Clamp(currentVolume + gain, 0.0f, 1.0f); + + _audioOut.SetVolume(newVolume); + + return ResultCode.Success; + } + + [Command(13)] // 6.0.0+ + // GetAudioOutVolume() -> s32 + public ResultCode GetAudioOutVolume(ServiceCtx context) + { + float volume = _audioOut.GetVolume(); + + context.ResponseData.Write(volume); + + return ResultCode.Success; + } + public void Dispose() { Dispose(true); -- cgit v1.2.3