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