Fix buffer size read from header and check
This commit is contained in:
parent
75180521e9
commit
0c8697636a
4 changed files with 24 additions and 18 deletions
|
@ -5,5 +5,6 @@ namespace Ryujinx.HLE.HOS.Services.Aud
|
|||
public const int DeviceNotFound = 1;
|
||||
public const int UnsupportedRevision = 2;
|
||||
public const int UnsupportedSampleRate = 3;
|
||||
public const int OpusInvalidInput = 6;
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
using Concentus.Structs;
|
||||
using Ryujinx.HLE.OsHle.Ipc;
|
||||
using Ryujinx.HLE.HOS.Ipc;
|
||||
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
|
||||
{
|
||||
|
@ -23,7 +23,8 @@ namespace Ryujinx.HLE.OsHle.Services.Aud
|
|||
{
|
||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||
{
|
||||
{ 0, DecodeInterleaved }
|
||||
{ 0, DecodeInterleaved },
|
||||
{ 4, DecodeInterleavedWithPerf }
|
||||
};
|
||||
|
||||
this.SampleRate = SampleRate;
|
||||
|
@ -32,6 +33,17 @@ namespace Ryujinx.HLE.OsHle.Services.Aud
|
|||
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)
|
||||
{
|
||||
long InPosition = Context.Request.SendBuff[0].Position;
|
||||
|
@ -47,12 +59,12 @@ namespace Ryujinx.HLE.OsHle.Services.Aud
|
|||
|
||||
byte[] OpusData = Context.Memory.ReadBytes(InPosition, InSize);
|
||||
|
||||
int Processed = ((OpusData[0] << 0) |
|
||||
(OpusData[1] << 8) |
|
||||
(OpusData[2] << 16) |
|
||||
(OpusData[3] << 24)) + 8;
|
||||
int Processed = ((OpusData[0] << 24) |
|
||||
(OpusData[1] << 16) |
|
||||
(OpusData[2] << 8) |
|
||||
(OpusData[3] << 0)) + 8;
|
||||
|
||||
if (Processed > InSize)
|
||||
if ((uint)Processed > (ulong)InSize)
|
||||
{
|
||||
return MakeError(ErrorModule.Audio, AudErr.OpusInvalidInput);
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
using Ryujinx.HLE.OsHle.Ipc;
|
||||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.OsHle.Services.Aud
|
||||
namespace Ryujinx.HLE.HOS.Services.Aud
|
||||
{
|
||||
class IHardwareOpusDecoderManager : IpcService
|
||||
{
|
|
@ -1,7 +0,0 @@
|
|||
namespace Ryujinx.HLE.OsHle.Services.Aud
|
||||
{
|
||||
static class AudErr
|
||||
{
|
||||
public const int OpusInvalidInput = 6;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue