Merge pull request #152 from greggameplayer/patch-5
Implement ListAudioOutsAuto & OpenAudioOutAuto
This commit is contained in:
commit
3c4dafff3f
1 changed files with 46 additions and 23 deletions
|
@ -21,15 +21,44 @@ namespace Ryujinx.HLE.OsHle.Services.Aud
|
||||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||||
{
|
{
|
||||||
{ 0, ListAudioOuts },
|
{ 0, ListAudioOuts },
|
||||||
{ 1, OpenAudioOut }
|
{ 1, OpenAudioOut },
|
||||||
|
{ 2, ListAudioOutsAuto },
|
||||||
|
{ 3, OpenAudioOutAuto }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public long ListAudioOuts(ServiceCtx Context)
|
public long ListAudioOuts(ServiceCtx Context)
|
||||||
{
|
{
|
||||||
long Position = Context.Request.ReceiveBuff[0].Position;
|
ListAudioOutsMethod(Context, Context.Request.ReceiveBuff[0].Position, Context.Request.ReceiveBuff[0].Size);
|
||||||
long Size = Context.Request.ReceiveBuff[0].Size;
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long OpenAudioOut(ServiceCtx Context)
|
||||||
|
{
|
||||||
|
OpenAudioOutMethod(Context, Context.Request.SendBuff[0].Position, Context.Request.SendBuff[0].Size,
|
||||||
|
Context.Request.ReceiveBuff[0].Position, Context.Request.ReceiveBuff[0].Size);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long ListAudioOutsAuto(ServiceCtx Context)
|
||||||
|
{
|
||||||
|
ListAudioOutsMethod(Context, Context.Request.GetBufferType0x22().Position, Context.Request.GetBufferType0x22().Size);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long OpenAudioOutAuto(ServiceCtx Context)
|
||||||
|
{
|
||||||
|
OpenAudioOutMethod(Context, Context.Request.GetBufferType0x21().Position, Context.Request.GetBufferType0x21().Size,
|
||||||
|
Context.Request.GetBufferType0x22().Position, Context.Request.GetBufferType0x22().Size);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ListAudioOutsMethod(ServiceCtx Context, long Position, long Size)
|
||||||
|
{
|
||||||
int NameCount = 0;
|
int NameCount = 0;
|
||||||
|
|
||||||
byte[] DeviceNameBuffer = Encoding.ASCII.GetBytes(DefaultAudioOutput + "\0");
|
byte[] DeviceNameBuffer = Encoding.ASCII.GetBytes(DefaultAudioOutput + "\0");
|
||||||
|
@ -46,36 +75,32 @@ namespace Ryujinx.HLE.OsHle.Services.Aud
|
||||||
}
|
}
|
||||||
|
|
||||||
Context.ResponseData.Write(NameCount);
|
Context.ResponseData.Write(NameCount);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long OpenAudioOut(ServiceCtx Context)
|
public void OpenAudioOutMethod(ServiceCtx Context, long SendPosition, long SendSize, long ReceivePosition, long ReceiveSize)
|
||||||
{
|
{
|
||||||
IAalOutput AudioOut = Context.Ns.AudioOut;
|
IAalOutput AudioOut = Context.Ns.AudioOut;
|
||||||
|
|
||||||
string DeviceName = AMemoryHelper.ReadAsciiString(
|
string DeviceName = AMemoryHelper.ReadAsciiString(
|
||||||
Context.Memory,
|
Context.Memory,
|
||||||
Context.Request.SendBuff[0].Position,
|
SendPosition,
|
||||||
Context.Request.SendBuff[0].Size);
|
SendSize
|
||||||
|
);
|
||||||
|
|
||||||
if (DeviceName == string.Empty)
|
if (DeviceName == string.Empty)
|
||||||
{
|
{
|
||||||
DeviceName = DefaultAudioOutput;
|
DeviceName = DefaultAudioOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
long Position = Context.Request.ReceiveBuff[0].Position;
|
|
||||||
long Size = Context.Request.ReceiveBuff[0].Size;
|
|
||||||
|
|
||||||
byte[] DeviceNameBuffer = Encoding.ASCII.GetBytes(DeviceName + "\0");
|
byte[] DeviceNameBuffer = Encoding.ASCII.GetBytes(DeviceName + "\0");
|
||||||
|
|
||||||
if ((ulong)DeviceNameBuffer.Length <= (ulong)Size)
|
if ((ulong)DeviceNameBuffer.Length <= (ulong)ReceiveSize)
|
||||||
{
|
{
|
||||||
Context.Memory.WriteBytes(Position, DeviceNameBuffer);
|
Context.Memory.WriteBytes(ReceivePosition, DeviceNameBuffer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Context.Ns.Log.PrintError(LogClass.ServiceAudio, $"Output buffer size {Size} too small!");
|
Context.Ns.Log.PrintError(LogClass.ServiceAudio, $"Output buffer size {ReceiveSize} too small!");
|
||||||
}
|
}
|
||||||
|
|
||||||
int SampleRate = Context.RequestData.ReadInt32();
|
int SampleRate = Context.RequestData.ReadInt32();
|
||||||
|
@ -108,8 +133,6 @@ namespace Ryujinx.HLE.OsHle.Services.Aud
|
||||||
Context.ResponseData.Write(Channels);
|
Context.ResponseData.Write(Channels);
|
||||||
Context.ResponseData.Write((int)Format);
|
Context.ResponseData.Write((int)Format);
|
||||||
Context.ResponseData.Write((int)PlaybackState.Stopped);
|
Context.ResponseData.Write((int)PlaybackState.Stopped);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue