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:
parent
9493cdfe55
commit
57c4e6ef21
7 changed files with 254 additions and 63 deletions
|
@ -54,6 +54,16 @@ namespace Ryujinx.Audio.SoundIo
|
|||
/// </summary>
|
||||
public ConcurrentQueue<long> ReleasedBuffers { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Buffer count of the track
|
||||
/// </summary>
|
||||
public uint BufferCount => (uint)m_ReservedBuffers.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Played sample count of the track
|
||||
/// </summary>
|
||||
public ulong PlayedSampleCount { get; private set; }
|
||||
|
||||
private int _hardwareChannels;
|
||||
private int _virtualChannels;
|
||||
|
||||
|
@ -430,6 +440,8 @@ namespace Ryujinx.Audio.SoundIo
|
|||
|
||||
AudioStream.EndWrite();
|
||||
|
||||
PlayedSampleCount += (ulong)samples.Length;
|
||||
|
||||
UpdateReleasedBuffers(samples.Length);
|
||||
}
|
||||
|
||||
|
@ -571,6 +583,28 @@ namespace Ryujinx.Audio.SoundIo
|
|||
return m_ReservedBuffers.Any(x => x.Tag == bufferTag);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flush all track buffers
|
||||
/// </summary>
|
||||
public bool FlushBuffers()
|
||||
{
|
||||
m_Buffer.Clear();
|
||||
|
||||
if (m_ReservedBuffers.Count > 0)
|
||||
{
|
||||
foreach (var buffer in m_ReservedBuffers)
|
||||
{
|
||||
ReleasedBuffers.Enqueue(buffer.Tag);
|
||||
}
|
||||
|
||||
OnBufferReleased();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the <see cref="SoundIoAudioTrack"/>
|
||||
/// </summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue