aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Audio/IAalOutput.cs
blob: ddb1492c6c51706527a508023a794dfcf0f70725 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;

namespace Ryujinx.Audio
{
    public interface IAalOutput : IDisposable
    {
        bool SupportsChannelCount(int channels);

        private int SelectHardwareChannelCount(int targetChannelCount)
        {
            if (SupportsChannelCount(targetChannelCount))
            {
                return targetChannelCount;
            }

            return targetChannelCount switch
            {
                6 => SelectHardwareChannelCount(2),
                2 => SelectHardwareChannelCount(1),
                1 => throw new ArgumentException("No valid channel configuration found!"),
                _ => throw new ArgumentException($"Invalid targetChannelCount {targetChannelCount}"),
            };
        }

        int OpenTrack(int sampleRate, int channels, ReleaseCallback callback)
        {
            return OpenHardwareTrack(sampleRate, SelectHardwareChannelCount(channels), channels, callback);
        }

        int OpenHardwareTrack(int sampleRate, int hardwareChannels, int virtualChannels, ReleaseCallback callback);

        void CloseTrack(int trackId);

        bool ContainsBuffer(int trackId, long bufferTag);

        long[] GetReleasedBuffers(int trackId, int maxCount);

        void AppendBuffer<T>(int trackId, long bufferTag, T[] buffer) where T : struct;

        void Start(int trackId);

        void Stop(int trackId);

        uint GetBufferCount(int trackId);

        ulong GetPlayedSampleCount(int trackId);

        bool FlushBuffers(int trackId);

        float GetVolume(int trackId);

        void SetVolume(int trackId, float volume);

        PlaybackState GetState(int trackId);
    }
}