aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager.cs
blob: c45a485bc7810172f0fb38a120cf92e26841cd45 (plain) (blame)
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
using Ryujinx.Audio.Common;
using Ryujinx.Audio.Output;
using Ryujinx.HLE.HOS.Services.Audio.AudioOut;
using AudioOutManagerImpl = Ryujinx.Audio.Output.AudioOutputManager;

namespace Ryujinx.HLE.HOS.Services.Audio
{
    class AudioOutManager : IAudioOutManager
    {
        private readonly AudioOutManagerImpl _impl;

        public AudioOutManager(AudioOutManagerImpl impl)
        {
            _impl = impl;
        }

        public string[] ListAudioOuts()
        {
            return _impl.ListAudioOuts();
        }

        public ResultCode OpenAudioOut(ServiceCtx context, out string outputDeviceName, out AudioOutputConfiguration outputConfiguration, out IAudioOut obj, string inputDeviceName, ref AudioInputConfiguration parameter, ulong appletResourceUserId, uint processHandle, float volume)
        {
            var memoryManager = context.Process.HandleTable.GetKProcess((int)processHandle).CpuMemory;

            ResultCode result = (ResultCode)_impl.OpenAudioOut(out outputDeviceName, out outputConfiguration, out AudioOutputSystem outSystem, memoryManager, inputDeviceName, SampleFormat.PcmInt16, ref parameter, appletResourceUserId, processHandle, volume);

            if (result == ResultCode.Success)
            {
                obj = new AudioOut.AudioOut(outSystem, context.Device.System.KernelContext, processHandle);
            }
            else
            {
                obj = null;
            }

            return result;
        }
    }
}