aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services
diff options
context:
space:
mode:
authorAc_K <Acoustik666@gmail.com>2020-07-27 00:25:04 +0200
committerGitHub <noreply@github.com>2020-07-27 00:25:04 +0200
commitd8515b603bff4712fe0e84113d7f7823a84c85eb (patch)
treeb75b2ab1903ddc869f8a3ce4912cb3bf7025b56e /Ryujinx.HLE/HOS/Services
parent51fbc1fde4363760bb47a2a5c960476ffceeac17 (diff)
audin: Implement IAudioInManager ListAudioIns (#1419)
* audin: Implement IAudioInManager ListAudioIns This implement some calls of IAudioInManager: - ListAudioIns - ListAudioInsAuto - ListAudioInsAutoFiltered Accordingly to RE. Close #1056 * Fix count * Comment condition * Fix comment
Diffstat (limited to 'Ryujinx.HLE/HOS/Services')
-rw-r--r--Ryujinx.HLE/HOS/Services/Audio/IAudioInManager.cs80
1 files changed, 79 insertions, 1 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Audio/IAudioInManager.cs b/Ryujinx.HLE/HOS/Services/Audio/IAudioInManager.cs
index d8e1f468..9b3b951c 100644
--- a/Ryujinx.HLE/HOS/Services/Audio/IAudioInManager.cs
+++ b/Ryujinx.HLE/HOS/Services/Audio/IAudioInManager.cs
@@ -1,8 +1,86 @@
-namespace Ryujinx.HLE.HOS.Services.Audio
+using Ryujinx.Cpu;
+using System;
+using System.Text;
+
+namespace Ryujinx.HLE.HOS.Services.Audio
{
[Service("audin:u")]
class IAudioInManager : IpcService
{
+ private const string DefaultAudioInsName = "BuiltInHeadset";
+
public IAudioInManager(ServiceCtx context) { }
+
+ [Command(0)]
+ // ListAudioIns() -> (u32 count, buffer<bytes, 6> names)
+ public ResultCode ListAudioIns(ServiceCtx context)
+ {
+ long bufferPosition = context.Request.ReceiveBuff[0].Position;
+ long bufferSize = context.Request.ReceiveBuff[0].Size;
+
+ // NOTE: The service check if AudioInManager thread is started, if not it starts it.
+
+ uint count = ListAudioInsImpl(context.Memory, bufferPosition, bufferSize, false);
+
+ context.ResponseData.Write(count);
+
+ return ResultCode.Success;
+ }
+
+ [Command(3)] // 3.0.0+
+ // ListAudioInsAuto() -> (u32 count, buffer<bytes, 0x22> names)
+ public ResultCode ListAudioInsAuto(ServiceCtx context)
+ {
+ (long bufferPosition, long bufferSize) = context.Request.GetBufferType0x22();
+
+ // NOTE: The service check if AudioInManager thread is started, if not it starts it.
+
+ uint count = ListAudioInsImpl(context.Memory, bufferPosition, bufferSize, false);
+
+ context.ResponseData.Write(count);
+
+ return ResultCode.Success;
+ }
+
+ [Command(4)] // 3.0.0+
+ // ListAudioInsAutoFiltered() -> (u32 count, buffer<bytes, 0x22> names)
+ public ResultCode ListAudioInsAutoFiltered(ServiceCtx context)
+ {
+ (long bufferPosition, long bufferSize) = context.Request.GetBufferType0x22();
+
+ // NOTE: The service check if AudioInManager thread is started, if not it starts it.
+
+ uint count = ListAudioInsImpl(context.Memory, bufferPosition, bufferSize, true);
+
+ context.ResponseData.Write(count);
+
+ return ResultCode.Success;
+ }
+
+ private uint ListAudioInsImpl(MemoryManager memory, long bufferPosition, long bufferSize, bool filtered = false)
+ {
+ uint count = 0;
+
+ MemoryHelper.FillWithZeros(memory, bufferPosition, (int)bufferSize);
+
+ if (bufferSize > 0)
+ {
+ // NOTE: The service also check that the input target is enabled when in filtering mode, as audctl and most of the audin logic isn't supported, we don't support it.
+ if (!filtered)
+ {
+ byte[] deviceNameBuffer = Encoding.ASCII.GetBytes(DefaultAudioInsName + "\0");
+
+ memory.Write((ulong)bufferPosition, deviceNameBuffer);
+
+ count++;
+ }
+
+ // NOTE: The service adds other input devices names available in the buffer,
+ // every name is aligned to 0x100 bytes.
+ // Since we don't support it for now, it's fine to do nothing here.
+ }
+
+ return count;
+ }
}
} \ No newline at end of file