mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-06-02 21:28:46 +02:00
d4d0a48bfe
* Migrate audren to new IPC * Migrate audout * Migrate audin * Migrate hwopus * Bye bye old audio service * Switch volume control to IHardwareDeviceDriver * Somewhat unrelated changes * Remove Concentus reference from HLE * Implement OpenAudioRendererForManualExecution * Remove SetVolume/GetVolume methods that are not necessary * Remove SetVolume/GetVolume methods that are not necessary (2) * Fix incorrect volume update * PR feedback * PR feedback * Stub audrec * Init outParameter * Make FinalOutputRecorderParameter/Internal readonly * Make FinalOutputRecorder IDisposable * Fix HardwareOpusDecoderManager parameter buffers * Opus work buffer size and error handling improvements * Add AudioInProtocolName enum * Fix potential divisions by zero
94 lines
3.2 KiB
C#
94 lines
3.2 KiB
C#
using Ryujinx.Audio;
|
|
using Ryujinx.Audio.Common;
|
|
using Ryujinx.Audio.Output;
|
|
using Ryujinx.Horizon.Common;
|
|
using Ryujinx.Horizon.Sdk.Applet;
|
|
using Ryujinx.Horizon.Sdk.Sf;
|
|
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
|
using System;
|
|
|
|
namespace Ryujinx.Horizon.Sdk.Audio.Detail
|
|
{
|
|
partial class AudioOutManager : IAudioOutManager
|
|
{
|
|
private readonly AudioOutputManager _impl;
|
|
|
|
public AudioOutManager(AudioOutputManager impl)
|
|
{
|
|
_impl = impl;
|
|
}
|
|
|
|
[CmifCommand(0)]
|
|
public Result ListAudioOuts(out int count, [Buffer(HipcBufferFlags.Out | HipcBufferFlags.MapAlias)] Span<DeviceName> names)
|
|
{
|
|
string[] deviceNames = _impl.ListAudioOuts();
|
|
|
|
count = 0;
|
|
|
|
foreach (string deviceName in deviceNames)
|
|
{
|
|
if (count >= names.Length)
|
|
{
|
|
break;
|
|
}
|
|
|
|
names[count++] = new DeviceName(deviceName);
|
|
}
|
|
|
|
return Result.Success;
|
|
}
|
|
|
|
[CmifCommand(1)]
|
|
public Result OpenAudioOut(
|
|
out AudioOutputConfiguration outputConfig,
|
|
out IAudioOut audioOut,
|
|
[Buffer(HipcBufferFlags.Out | HipcBufferFlags.MapAlias)] Span<DeviceName> outName,
|
|
AudioInputConfiguration parameter,
|
|
AppletResourceUserId appletResourceId,
|
|
[CopyHandle] int processHandle,
|
|
[Buffer(HipcBufferFlags.In | HipcBufferFlags.MapAlias)] ReadOnlySpan<DeviceName> name,
|
|
[ClientProcessId] ulong pid)
|
|
{
|
|
var clientMemoryManager = HorizonStatic.Syscall.GetMemoryManagerByProcessHandle(processHandle);
|
|
|
|
ResultCode rc = _impl.OpenAudioOut(
|
|
out string outputDeviceName,
|
|
out outputConfig,
|
|
out AudioOutputSystem outSystem,
|
|
clientMemoryManager,
|
|
name.Length > 0 ? name[0].ToString() : string.Empty,
|
|
SampleFormat.PcmInt16,
|
|
ref parameter);
|
|
|
|
if (rc == ResultCode.Success && outName.Length > 0)
|
|
{
|
|
outName[0] = new DeviceName(outputDeviceName);
|
|
}
|
|
|
|
audioOut = new AudioOut(outSystem, processHandle);
|
|
|
|
return new Result((int)rc);
|
|
}
|
|
|
|
[CmifCommand(2)] // 3.0.0+
|
|
public Result ListAudioOutsAuto(out int count, [Buffer(HipcBufferFlags.Out | HipcBufferFlags.AutoSelect)] Span<DeviceName> names)
|
|
{
|
|
return ListAudioOuts(out count, names);
|
|
}
|
|
|
|
[CmifCommand(3)] // 3.0.0+
|
|
public Result OpenAudioOutAuto(
|
|
out AudioOutputConfiguration outputConfig,
|
|
out IAudioOut audioOut,
|
|
[Buffer(HipcBufferFlags.Out | HipcBufferFlags.AutoSelect)] Span<DeviceName> outName,
|
|
AudioInputConfiguration parameter,
|
|
AppletResourceUserId appletResourceId,
|
|
[CopyHandle] int processHandle,
|
|
[Buffer(HipcBufferFlags.In | HipcBufferFlags.AutoSelect)] ReadOnlySpan<DeviceName> name,
|
|
[ClientProcessId] ulong pid)
|
|
{
|
|
return OpenAudioOut(out outputConfig, out audioOut, outName, parameter, appletResourceId, processHandle, name, pid);
|
|
}
|
|
}
|
|
}
|