Fix buffer size read from header and check

This commit is contained in:
gdkchan 2018-11-16 23:34:18 -03:00
commit 0c8697636a
4 changed files with 24 additions and 18 deletions

View file

@ -5,5 +5,6 @@ namespace Ryujinx.HLE.HOS.Services.Aud
public const int DeviceNotFound = 1; public const int DeviceNotFound = 1;
public const int UnsupportedRevision = 2; public const int UnsupportedRevision = 2;
public const int UnsupportedSampleRate = 3; public const int UnsupportedSampleRate = 3;
public const int OpusInvalidInput = 6;
} }
} }

View file

@ -1,10 +1,10 @@
using Concentus.Structs; using Concentus.Structs;
using Ryujinx.HLE.OsHle.Ipc; using Ryujinx.HLE.HOS.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
using static Ryujinx.HLE.OsHle.ErrorCode; using static Ryujinx.HLE.HOS.ErrorCode;
namespace Ryujinx.HLE.OsHle.Services.Aud namespace Ryujinx.HLE.HOS.Services.Aud
{ {
class IHardwareOpusDecoder : IpcService class IHardwareOpusDecoder : IpcService
{ {
@ -23,7 +23,8 @@ namespace Ryujinx.HLE.OsHle.Services.Aud
{ {
m_Commands = new Dictionary<int, ServiceProcessRequest>() m_Commands = new Dictionary<int, ServiceProcessRequest>()
{ {
{ 0, DecodeInterleaved } { 0, DecodeInterleaved },
{ 4, DecodeInterleavedWithPerf }
}; };
this.SampleRate = SampleRate; this.SampleRate = SampleRate;
@ -32,6 +33,17 @@ namespace Ryujinx.HLE.OsHle.Services.Aud
Decoder = new OpusDecoder(FixedSampleRate, ChannelsCount); Decoder = new OpusDecoder(FixedSampleRate, ChannelsCount);
} }
public long DecodeInterleavedWithPerf(ServiceCtx Context)
{
long Result = DecodeInterleaved(Context);
//TODO: Figure out what this value is.
//According to switchbrew, it is now used.
Context.ResponseData.Write(0L);
return Result;
}
public long DecodeInterleaved(ServiceCtx Context) public long DecodeInterleaved(ServiceCtx Context)
{ {
long InPosition = Context.Request.SendBuff[0].Position; long InPosition = Context.Request.SendBuff[0].Position;
@ -47,12 +59,12 @@ namespace Ryujinx.HLE.OsHle.Services.Aud
byte[] OpusData = Context.Memory.ReadBytes(InPosition, InSize); byte[] OpusData = Context.Memory.ReadBytes(InPosition, InSize);
int Processed = ((OpusData[0] << 0) | int Processed = ((OpusData[0] << 24) |
(OpusData[1] << 8) | (OpusData[1] << 16) |
(OpusData[2] << 16) | (OpusData[2] << 8) |
(OpusData[3] << 24)) + 8; (OpusData[3] << 0)) + 8;
if (Processed > InSize) if ((uint)Processed > (ulong)InSize)
{ {
return MakeError(ErrorModule.Audio, AudErr.OpusInvalidInput); return MakeError(ErrorModule.Audio, AudErr.OpusInvalidInput);
} }

View file

@ -1,7 +1,7 @@
using Ryujinx.HLE.OsHle.Ipc; using Ryujinx.HLE.HOS.Ipc;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.HLE.OsHle.Services.Aud namespace Ryujinx.HLE.HOS.Services.Aud
{ {
class IHardwareOpusDecoderManager : IpcService class IHardwareOpusDecoderManager : IpcService
{ {

View file

@ -1,7 +0,0 @@
namespace Ryujinx.HLE.OsHle.Services.Aud
{
static class AudErr
{
public const int OpusInvalidInput = 6;
}
}