From 57c4e6ef21d1f281b172aedcfd993a2ac43456ef Mon Sep 17 00:00:00 2001 From: Ac_K Date: Fri, 20 Nov 2020 21:59:01 +0100 Subject: audout: Implement and fix some calls (#1725) * audout: Implement GetAudioOutBufferCount, GetAudioOutPlayedSampleCount and FlushAudioOutBuffers This PR implement audout service calls: - GetAudioOutBufferCount - GetAudioOutPlayedSampleCount - FlushAudioOutBuffers The RE calls just give some hints about no extra checks. Since we use a totally different implementation because of our backend, I can't do something better for now. SetAudioOutVolume and GetAudioOutVolume are fixed too by set/get the volume of the current opened track, previous implementation was wrong. This fix #1133, fix #1258 and fix #1519. Thanks to @jduncanator for this help during the implementation and all his precious advices. * Fix some debug leftovers * Address jD feedback --- .../Services/Audio/AudioOutManager/IAudioOut.cs | 43 ++++++++++++++++++---- 1 file changed, 36 insertions(+), 7 deletions(-) (limited to 'Ryujinx.HLE/HOS') diff --git a/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager/IAudioOut.cs b/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager/IAudioOut.cs index d75fecf2..eaf644f6 100644 --- a/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager/IAudioOut.cs +++ b/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager/IAudioOut.cs @@ -149,17 +149,46 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioOutManager return ResultCode.Success; } + [Command(9)] // 4.0.0+ + // GetAudioOutBufferCount() -> u32 + public ResultCode GetAudioOutBufferCount(ServiceCtx context) + { + uint bufferCount = _audioOut.GetBufferCount(_track); + + context.ResponseData.Write(bufferCount); + + return ResultCode.Success; + } + + [Command(10)] // 4.0.0+ + // GetAudioOutPlayedSampleCount() -> u64 + public ResultCode GetAudioOutPlayedSampleCount(ServiceCtx context) + { + ulong playedSampleCount = _audioOut.GetPlayedSampleCount(_track); + + context.ResponseData.Write(playedSampleCount); + + return ResultCode.Success; + } + + [Command(11)] // 4.0.0+ + // FlushAudioOutBuffers() -> b8 + public ResultCode FlushAudioOutBuffers(ServiceCtx context) + { + bool heldBuffers = _audioOut.FlushBuffers(_track); + + context.ResponseData.Write(heldBuffers); + + 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); + float volume = context.RequestData.ReadSingle(); - _audioOut.SetVolume(newVolume); + _audioOut.SetVolume(_track, volume); return ResultCode.Success; } @@ -168,7 +197,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioOutManager // GetAudioOutVolume() -> s32 public ResultCode GetAudioOutVolume(ServiceCtx context) { - float volume = _audioOut.GetVolume(); + float volume = _audioOut.GetVolume(_track); context.ResponseData.Write(volume); -- cgit v1.2.3