2020-08-18 03:49:37 +02:00
|
|
|
|
using Ryujinx.Common.Logging;
|
|
|
|
|
using Ryujinx.Cpu;
|
2018-08-17 01:47:36 +02:00
|
|
|
|
using Ryujinx.HLE.HOS.Ipc;
|
2018-12-18 06:33:36 +01:00
|
|
|
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
2023-01-04 23:15:45 +01:00
|
|
|
|
using Ryujinx.Horizon.Common;
|
2018-09-23 20:11:46 +02:00
|
|
|
|
using System;
|
2018-03-12 20:29:06 +01:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
2020-08-18 03:49:37 +02:00
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Audio.AudioRenderer
|
2018-03-12 20:29:06 +01:00
|
|
|
|
{
|
2020-08-18 03:49:37 +02:00
|
|
|
|
class AudioDeviceServer : IpcService
|
2018-03-12 20:29:06 +01:00
|
|
|
|
{
|
2020-08-18 03:49:37 +02:00
|
|
|
|
private const int AudioDeviceNameSize = 0x100;
|
2018-04-18 03:52:20 +02:00
|
|
|
|
|
2020-08-18 03:49:37 +02:00
|
|
|
|
private IAudioDevice _impl;
|
2018-04-19 05:19:22 +02:00
|
|
|
|
|
2020-08-18 03:49:37 +02:00
|
|
|
|
public AudioDeviceServer(IAudioDevice impl)
|
|
|
|
|
{
|
|
|
|
|
_impl = impl;
|
2018-03-12 20:29:06 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(0)]
|
2019-07-12 03:13:43 +02:00
|
|
|
|
// ListAudioDeviceName() -> (u32, buffer<bytes, 6>)
|
2019-07-14 21:04:38 +02:00
|
|
|
|
public ResultCode ListAudioDeviceName(ServiceCtx context)
|
2018-03-12 20:29:06 +01:00
|
|
|
|
{
|
2020-08-18 03:49:37 +02:00
|
|
|
|
string[] deviceNames = _impl.ListAudioDeviceName();
|
2018-03-12 20:29:06 +01:00
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
ulong position = context.Request.ReceiveBuff[0].Position;
|
|
|
|
|
ulong size = context.Request.ReceiveBuff[0].Size;
|
2018-03-12 20:29:06 +01:00
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
ulong basePosition = position;
|
2018-03-12 20:29:06 +01:00
|
|
|
|
|
2020-08-18 03:49:37 +02:00
|
|
|
|
int count = 0;
|
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
|
foreach (string name in deviceNames)
|
2018-03-12 20:29:06 +01:00
|
|
|
|
{
|
2020-08-18 03:49:37 +02:00
|
|
|
|
byte[] buffer = Encoding.ASCII.GetBytes(name);
|
2018-03-12 20:29:06 +01:00
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
if ((position - basePosition) + (ulong)buffer.Length > size)
|
2018-03-12 20:29:06 +01:00
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
context.Memory.Write(position, buffer);
|
|
|
|
|
MemoryHelper.FillWithZeros(context.Memory, position + (ulong)buffer.Length, AudioDeviceNameSize - buffer.Length);
|
2018-03-12 20:29:06 +01:00
|
|
|
|
|
2020-08-18 03:49:37 +02:00
|
|
|
|
position += AudioDeviceNameSize;
|
|
|
|
|
count++;
|
2018-03-12 20:29:06 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-08-18 03:49:37 +02:00
|
|
|
|
context.ResponseData.Write(count);
|
|
|
|
|
|
2019-07-14 21:04:38 +02:00
|
|
|
|
return ResultCode.Success;
|
2018-03-12 20:29:06 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(1)]
|
2020-08-18 03:49:37 +02:00
|
|
|
|
// SetAudioDeviceOutputVolume(f32 volume, buffer<bytes, 5> name)
|
2019-07-14 21:04:38 +02:00
|
|
|
|
public ResultCode SetAudioDeviceOutputVolume(ServiceCtx context)
|
2018-03-12 20:29:06 +01:00
|
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
|
float volume = context.RequestData.ReadSingle();
|
2018-03-12 20:29:06 +01:00
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
ulong position = context.Request.SendBuff[0].Position;
|
|
|
|
|
ulong size = context.Request.SendBuff[0].Size;
|
2018-03-12 20:29:06 +01:00
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
string deviceName = MemoryHelper.ReadAsciiString(context.Memory, position, (long)size);
|
2018-04-24 22:14:26 +02:00
|
|
|
|
|
2020-08-18 03:49:37 +02:00
|
|
|
|
return _impl.SetAudioDeviceOutputVolume(deviceName, volume);
|
|
|
|
|
}
|
2018-03-12 20:29:06 +01:00
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(2)]
|
2020-08-18 03:49:37 +02:00
|
|
|
|
// GetAudioDeviceOutputVolume(buffer<bytes, 5> name) -> f32 volume
|
|
|
|
|
public ResultCode GetAudioDeviceOutputVolume(ServiceCtx context)
|
|
|
|
|
{
|
2021-04-24 12:16:01 +02:00
|
|
|
|
ulong position = context.Request.SendBuff[0].Position;
|
|
|
|
|
ulong size = context.Request.SendBuff[0].Size;
|
2018-04-17 02:24:42 +02:00
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
string deviceName = MemoryHelper.ReadAsciiString(context.Memory, position, (long)size);
|
2020-08-18 03:49:37 +02:00
|
|
|
|
|
|
|
|
|
ResultCode result = _impl.GetAudioDeviceOutputVolume(deviceName, out float volume);
|
|
|
|
|
|
|
|
|
|
if (result == ResultCode.Success)
|
|
|
|
|
{
|
|
|
|
|
context.ResponseData.Write(volume);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
2018-03-12 20:29:06 +01:00
|
|
|
|
}
|
2018-04-18 03:52:20 +02:00
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(3)]
|
2019-07-12 03:13:43 +02:00
|
|
|
|
// GetActiveAudioDeviceName() -> buffer<bytes, 6>
|
2019-07-14 21:04:38 +02:00
|
|
|
|
public ResultCode GetActiveAudioDeviceName(ServiceCtx context)
|
2018-04-22 06:21:49 +02:00
|
|
|
|
{
|
2020-08-18 03:49:37 +02:00
|
|
|
|
string name = _impl.GetActiveAudioDeviceName();
|
2018-04-22 06:21:49 +02:00
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
ulong position = context.Request.ReceiveBuff[0].Position;
|
|
|
|
|
ulong size = context.Request.ReceiveBuff[0].Size;
|
2018-04-22 06:21:49 +02:00
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
|
byte[] deviceNameBuffer = Encoding.ASCII.GetBytes(name + "\0");
|
2018-04-22 06:21:49 +02:00
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
if ((ulong)deviceNameBuffer.Length <= size)
|
2018-04-24 22:14:26 +02:00
|
|
|
|
{
|
2021-04-24 12:16:01 +02:00
|
|
|
|
context.Memory.Write(position, deviceNameBuffer);
|
2018-04-24 22:14:26 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-08-04 01:32:53 +02:00
|
|
|
|
Logger.Error?.Print(LogClass.ServiceAudio, $"Output buffer size {size} too small!");
|
2018-04-24 22:14:26 +02:00
|
|
|
|
}
|
2018-04-22 06:21:49 +02:00
|
|
|
|
|
2019-07-14 21:04:38 +02:00
|
|
|
|
return ResultCode.Success;
|
2018-04-22 06:21:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(4)]
|
2019-07-12 03:13:43 +02:00
|
|
|
|
// QueryAudioDeviceSystemEvent() -> handle<copy, event>
|
2019-07-14 21:04:38 +02:00
|
|
|
|
public ResultCode QueryAudioDeviceSystemEvent(ServiceCtx context)
|
2018-04-18 03:52:20 +02:00
|
|
|
|
{
|
2020-08-18 03:49:37 +02:00
|
|
|
|
KEvent deviceSystemEvent = _impl.QueryAudioDeviceSystemEvent();
|
|
|
|
|
|
2023-01-04 23:15:45 +01:00
|
|
|
|
if (context.Process.HandleTable.GenerateHandle(deviceSystemEvent.ReadableEvent, out int handle) != Result.Success)
|
2018-09-23 20:11:46 +02:00
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("Out of handles!");
|
|
|
|
|
}
|
2018-04-18 03:52:20 +02:00
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
|
2018-04-18 03:52:20 +02:00
|
|
|
|
|
2020-08-04 01:32:53 +02:00
|
|
|
|
Logger.Stub?.PrintStub(LogClass.ServiceAudio);
|
2018-04-18 03:52:20 +02:00
|
|
|
|
|
2019-07-14 21:04:38 +02:00
|
|
|
|
return ResultCode.Success;
|
2018-04-18 03:52:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(5)]
|
2019-07-12 03:13:43 +02:00
|
|
|
|
// GetActiveChannelCount() -> u32
|
2019-07-14 21:04:38 +02:00
|
|
|
|
public ResultCode GetActiveChannelCount(ServiceCtx context)
|
2018-04-18 03:52:20 +02:00
|
|
|
|
{
|
2020-08-18 03:49:37 +02:00
|
|
|
|
context.ResponseData.Write(_impl.GetActiveChannelCount());
|
2018-04-18 03:52:20 +02:00
|
|
|
|
|
2020-08-04 01:32:53 +02:00
|
|
|
|
Logger.Stub?.PrintStub(LogClass.ServiceAudio);
|
2018-04-18 03:52:20 +02:00
|
|
|
|
|
2019-07-14 21:04:38 +02:00
|
|
|
|
return ResultCode.Success;
|
2018-04-18 03:52:20 +02:00
|
|
|
|
}
|
2018-06-03 00:46:09 +02:00
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(6)] // 3.0.0+
|
2019-07-12 03:13:43 +02:00
|
|
|
|
// ListAudioDeviceNameAuto() -> (u32, buffer<bytes, 0x22>)
|
2019-07-14 21:04:38 +02:00
|
|
|
|
public ResultCode ListAudioDeviceNameAuto(ServiceCtx context)
|
2018-06-03 00:46:09 +02:00
|
|
|
|
{
|
2020-08-18 03:49:37 +02:00
|
|
|
|
string[] deviceNames = _impl.ListAudioDeviceName();
|
2018-06-03 00:46:09 +02:00
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
(ulong position, ulong size) = context.Request.GetBufferType0x22();
|
2018-06-03 00:46:09 +02:00
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
ulong basePosition = position;
|
2018-06-03 00:46:09 +02:00
|
|
|
|
|
2020-08-18 03:49:37 +02:00
|
|
|
|
int count = 0;
|
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
|
foreach (string name in deviceNames)
|
2018-06-03 00:46:09 +02:00
|
|
|
|
{
|
2020-08-18 03:49:37 +02:00
|
|
|
|
byte[] buffer = Encoding.ASCII.GetBytes(name);
|
2018-06-03 00:46:09 +02:00
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
if ((position - basePosition) + (ulong)buffer.Length > size)
|
2018-06-03 00:46:09 +02:00
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
context.Memory.Write(position, buffer);
|
|
|
|
|
MemoryHelper.FillWithZeros(context.Memory, position + (ulong)buffer.Length, AudioDeviceNameSize - buffer.Length);
|
2018-06-03 00:46:09 +02:00
|
|
|
|
|
2020-08-18 03:49:37 +02:00
|
|
|
|
position += AudioDeviceNameSize;
|
|
|
|
|
count++;
|
2018-06-03 00:46:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-08-18 03:49:37 +02:00
|
|
|
|
context.ResponseData.Write(count);
|
|
|
|
|
|
2019-07-14 21:04:38 +02:00
|
|
|
|
return ResultCode.Success;
|
2018-06-03 00:46:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(7)] // 3.0.0+
|
2020-08-18 03:49:37 +02:00
|
|
|
|
// SetAudioDeviceOutputVolumeAuto(f32 volume, buffer<bytes, 0x21> name)
|
2019-07-14 21:04:38 +02:00
|
|
|
|
public ResultCode SetAudioDeviceOutputVolumeAuto(ServiceCtx context)
|
2018-06-03 00:46:09 +02:00
|
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
|
float volume = context.RequestData.ReadSingle();
|
2018-06-03 00:46:09 +02:00
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
(ulong position, ulong size) = context.Request.GetBufferType0x21();
|
2018-06-03 00:46:09 +02:00
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
string deviceName = MemoryHelper.ReadAsciiString(context.Memory, position, (long)size);
|
2018-06-03 00:46:09 +02:00
|
|
|
|
|
2020-08-18 03:49:37 +02:00
|
|
|
|
return _impl.SetAudioDeviceOutputVolume(deviceName, volume);
|
2018-06-03 00:46:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(8)] // 3.0.0+
|
2020-08-18 03:49:37 +02:00
|
|
|
|
// GetAudioDeviceOutputVolumeAuto(buffer<bytes, 0x21> name) -> f32
|
2019-07-14 21:04:38 +02:00
|
|
|
|
public ResultCode GetAudioDeviceOutputVolumeAuto(ServiceCtx context)
|
2018-06-03 00:46:09 +02:00
|
|
|
|
{
|
2021-04-24 12:16:01 +02:00
|
|
|
|
(ulong position, ulong size) = context.Request.GetBufferType0x21();
|
2018-06-03 00:46:09 +02:00
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
string deviceName = MemoryHelper.ReadAsciiString(context.Memory, position, (long)size);
|
2020-08-18 03:49:37 +02:00
|
|
|
|
|
|
|
|
|
ResultCode result = _impl.GetAudioDeviceOutputVolume(deviceName, out float volume);
|
|
|
|
|
|
|
|
|
|
if (result == ResultCode.Success)
|
|
|
|
|
{
|
|
|
|
|
context.ResponseData.Write(volume);
|
|
|
|
|
}
|
2018-06-03 00:46:09 +02:00
|
|
|
|
|
2019-07-14 21:04:38 +02:00
|
|
|
|
return ResultCode.Success;
|
2018-06-03 00:46:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(10)] // 3.0.0+
|
2019-07-12 03:13:43 +02:00
|
|
|
|
// GetActiveAudioDeviceNameAuto() -> buffer<bytes, 0x22>
|
2019-07-14 21:04:38 +02:00
|
|
|
|
public ResultCode GetActiveAudioDeviceNameAuto(ServiceCtx context)
|
2018-06-03 00:46:09 +02:00
|
|
|
|
{
|
2020-08-18 03:49:37 +02:00
|
|
|
|
string name = _impl.GetActiveAudioDeviceName();
|
2018-06-03 00:46:09 +02:00
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
(ulong position, ulong size) = context.Request.GetBufferType0x22();
|
2018-06-03 00:46:09 +02:00
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
|
byte[] deviceNameBuffer = Encoding.UTF8.GetBytes(name + '\0');
|
2018-06-03 00:46:09 +02:00
|
|
|
|
|
2021-04-24 12:16:01 +02:00
|
|
|
|
if ((ulong)deviceNameBuffer.Length <= size)
|
2018-06-03 00:46:09 +02:00
|
|
|
|
{
|
2021-04-24 12:16:01 +02:00
|
|
|
|
context.Memory.Write(position, deviceNameBuffer);
|
2018-06-03 00:46:09 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-08-04 01:32:53 +02:00
|
|
|
|
Logger.Error?.Print(LogClass.ServiceAudio, $"Output buffer size {size} too small!");
|
2018-06-03 00:46:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-14 21:04:38 +02:00
|
|
|
|
return ResultCode.Success;
|
2018-06-03 00:46:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(11)] // 3.0.0+
|
2019-07-12 03:13:43 +02:00
|
|
|
|
// QueryAudioDeviceInputEvent() -> handle<copy, event>
|
2019-07-14 21:04:38 +02:00
|
|
|
|
public ResultCode QueryAudioDeviceInputEvent(ServiceCtx context)
|
2018-06-03 00:46:09 +02:00
|
|
|
|
{
|
2020-08-18 03:49:37 +02:00
|
|
|
|
KEvent deviceInputEvent = _impl.QueryAudioDeviceInputEvent();
|
|
|
|
|
|
2023-01-04 23:15:45 +01:00
|
|
|
|
if (context.Process.HandleTable.GenerateHandle(deviceInputEvent.ReadableEvent, out int handle) != Result.Success)
|
2018-09-23 20:11:46 +02:00
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("Out of handles!");
|
|
|
|
|
}
|
2018-06-03 00:46:09 +02:00
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
|
2018-06-03 00:46:09 +02:00
|
|
|
|
|
2020-08-04 01:32:53 +02:00
|
|
|
|
Logger.Stub?.PrintStub(LogClass.ServiceAudio);
|
2018-06-03 00:46:09 +02:00
|
|
|
|
|
2019-07-14 21:04:38 +02:00
|
|
|
|
return ResultCode.Success;
|
2018-06-03 00:46:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 00:01:24 +02:00
|
|
|
|
[CommandHipc(12)] // 3.0.0+
|
2019-07-12 03:13:43 +02:00
|
|
|
|
// QueryAudioDeviceOutputEvent() -> handle<copy, event>
|
2019-07-14 21:04:38 +02:00
|
|
|
|
public ResultCode QueryAudioDeviceOutputEvent(ServiceCtx context)
|
2018-06-03 00:46:09 +02:00
|
|
|
|
{
|
2020-08-18 03:49:37 +02:00
|
|
|
|
KEvent deviceOutputEvent = _impl.QueryAudioDeviceOutputEvent();
|
|
|
|
|
|
2023-01-04 23:15:45 +01:00
|
|
|
|
if (context.Process.HandleTable.GenerateHandle(deviceOutputEvent.ReadableEvent, out int handle) != Result.Success)
|
2018-09-23 20:11:46 +02:00
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("Out of handles!");
|
|
|
|
|
}
|
2018-06-03 00:46:09 +02:00
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
|
2018-06-03 00:46:09 +02:00
|
|
|
|
|
2020-08-04 01:32:53 +02:00
|
|
|
|
Logger.Stub?.PrintStub(LogClass.ServiceAudio);
|
2018-06-03 00:46:09 +02:00
|
|
|
|
|
2019-07-14 21:04:38 +02:00
|
|
|
|
return ResultCode.Success;
|
2018-06-03 00:46:09 +02:00
|
|
|
|
}
|
2020-08-18 03:49:37 +02:00
|
|
|
|
|
2021-09-19 12:29:19 +02:00
|
|
|
|
[CommandHipc(13)] // 13.0.0+
|
|
|
|
|
// GetActiveAudioOutputDeviceName() -> buffer<bytes, 6>
|
|
|
|
|
public ResultCode GetActiveAudioOutputDeviceName(ServiceCtx context)
|
2020-08-18 03:49:37 +02:00
|
|
|
|
{
|
2021-09-19 12:29:19 +02:00
|
|
|
|
string name = _impl.GetActiveAudioOutputDeviceName();
|
2020-08-18 03:49:37 +02:00
|
|
|
|
|
2021-09-19 12:29:19 +02:00
|
|
|
|
ulong position = context.Request.ReceiveBuff[0].Position;
|
|
|
|
|
ulong size = context.Request.ReceiveBuff[0].Size;
|
2020-08-18 03:49:37 +02:00
|
|
|
|
|
2021-09-19 12:29:19 +02:00
|
|
|
|
byte[] deviceNameBuffer = Encoding.ASCII.GetBytes(name + "\0");
|
2020-08-18 03:49:37 +02:00
|
|
|
|
|
2021-09-19 12:29:19 +02:00
|
|
|
|
if ((ulong)deviceNameBuffer.Length <= size)
|
|
|
|
|
{
|
|
|
|
|
context.Memory.Write(position, deviceNameBuffer);
|
|
|
|
|
}
|
|
|
|
|
else
|
2020-08-18 03:49:37 +02:00
|
|
|
|
{
|
2021-09-19 12:29:19 +02:00
|
|
|
|
Logger.Error?.Print(LogClass.ServiceAudio, $"Output buffer size {size} too small!");
|
2020-08-18 03:49:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-19 12:29:19 +02:00
|
|
|
|
return ResultCode.Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[CommandHipc(14)] // 13.0.0+
|
|
|
|
|
// ListAudioOutputDeviceName() -> (u32, buffer<bytes, 6>)
|
|
|
|
|
public ResultCode ListAudioOutputDeviceName(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
string[] deviceNames = _impl.ListAudioOutputDeviceName();
|
|
|
|
|
|
|
|
|
|
ulong position = context.Request.ReceiveBuff[0].Position;
|
|
|
|
|
ulong size = context.Request.ReceiveBuff[0].Size;
|
|
|
|
|
|
|
|
|
|
ulong basePosition = position;
|
|
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
|
|
foreach (string name in deviceNames)
|
|
|
|
|
{
|
|
|
|
|
byte[] buffer = Encoding.ASCII.GetBytes(name);
|
|
|
|
|
|
|
|
|
|
if ((position - basePosition) + (ulong)buffer.Length > size)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
context.Memory.Write(position, buffer);
|
|
|
|
|
MemoryHelper.FillWithZeros(context.Memory, position + (ulong)buffer.Length, AudioDeviceNameSize - buffer.Length);
|
|
|
|
|
|
|
|
|
|
position += AudioDeviceNameSize;
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
context.ResponseData.Write(count);
|
|
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
2020-08-18 03:49:37 +02:00
|
|
|
|
}
|
2018-03-12 20:29:06 +01:00
|
|
|
|
}
|
2020-08-18 03:49:37 +02:00
|
|
|
|
}
|