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
This commit is contained in:
Ac_K 2020-11-20 21:59:01 +01:00 committed by GitHub
parent 9493cdfe55
commit 57c4e6ef21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 254 additions and 63 deletions

View file

@ -1,5 +1,4 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Concurrent;
using System.Collections.Generic;
namespace Ryujinx.Audio
@ -15,6 +14,7 @@ namespace Ryujinx.Audio
private ConcurrentQueue<int> _trackIds;
private ConcurrentQueue<long> _buffers;
private ConcurrentDictionary<int, ReleaseCallback> _releaseCallbacks;
private ulong _playedSampleCount;
public DummyAudioOut()
{
@ -76,6 +76,8 @@ namespace Ryujinx.Audio
{
_buffers.Enqueue(bufferTag);
_playedSampleCount += (ulong)buffer.Length;
if (_releaseCallbacks.TryGetValue(trackId, out var callback))
{
callback?.Invoke();
@ -86,9 +88,15 @@ namespace Ryujinx.Audio
public void Stop(int trackId) { }
public float GetVolume() => _volume;
public uint GetBufferCount(int trackId) => (uint)_buffers.Count;
public void SetVolume(float volume)
public ulong GetPlayedSampleCount(int trackId) => _playedSampleCount;
public bool FlushBuffers(int trackId) => false;
public float GetVolume(int trackId) => _volume;
public void SetVolume(int trackId, float volume)
{
_volume = volume;
}