diff options
| author | Ac_K <Acoustik666@gmail.com> | 2020-11-20 21:59:01 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-20 21:59:01 +0100 |
| commit | 57c4e6ef21d1f281b172aedcfd993a2ac43456ef (patch) | |
| tree | 8ee5e5b42ab14bd8df52e823f3fcb4027e5ed873 /Ryujinx.Audio/Renderers/OpenAL/OpenALAudioTrack.cs | |
| parent | 9493cdfe553d77d8f37927ef2acf87cfbab1c467 (diff) | |
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
Diffstat (limited to 'Ryujinx.Audio/Renderers/OpenAL/OpenALAudioTrack.cs')
| -rw-r--r-- | Ryujinx.Audio/Renderers/OpenAL/OpenALAudioTrack.cs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Ryujinx.Audio/Renderers/OpenAL/OpenALAudioTrack.cs b/Ryujinx.Audio/Renderers/OpenAL/OpenALAudioTrack.cs index 2f150998..6e016713 100644 --- a/Ryujinx.Audio/Renderers/OpenAL/OpenALAudioTrack.cs +++ b/Ryujinx.Audio/Renderers/OpenAL/OpenALAudioTrack.cs @@ -11,9 +11,12 @@ namespace Ryujinx.Audio public int SampleRate { get; private set; } public ALFormat Format { get; private set; } public PlaybackState State { get; set; } + public float Volume { get; private set; } public int HardwareChannels { get; } public int VirtualChannels { get; } + public uint BufferCount => (uint)_buffers.Count; + public ulong PlayedSampleCount { get; set; } private ReleaseCallback _callback; @@ -125,6 +128,34 @@ namespace Ryujinx.Audio } } + public bool FlushBuffers() + { + while (_queuedTagsQueue.TryDequeue(out long tag)) + { + _releasedTagsQueue.Enqueue(tag); + } + + _callback(); + + foreach (var buffer in _buffers) + { + AL.DeleteBuffer(buffer.Value); + } + + bool heldBuffers = _buffers.Count > 0; + + _buffers.Clear(); + + return heldBuffers; + } + + public void SetVolume(float volume) + { + Volume = volume; + + AL.Source(SourceId, ALSourcef.Gain, Volume); + } + public void Dispose() { Dispose(true); |
