cf6cd71488
* IPC refactor part 2: Use ReplyAndReceive on HLE services and remove special handling from kernel * Fix for applet transfer memory + some nits * Keep handles if possible to avoid server handle table exhaustion * Fix IPC ZeroFill bug * am: Correctly implement CreateManagedDisplayLayer and implement CreateManagedDisplaySeparableLayer CreateManagedDisplaySeparableLayer is requires since 10.x+ when appletResourceUserId != 0 * Make it exit properly * Make ServiceNotImplementedException show the full message again * Allow yielding execution to avoid starving other threads * Only wait if active * Merge IVirtualMemoryManager and IAddressSpaceManager * Fix Ro loading data from the wrong process Co-authored-by: Thog <me@thog.eu>
68 lines
2.3 KiB
C#
68 lines
2.3 KiB
C#
using Ryujinx.HLE.HOS.Services.Audio.HardwareOpusDecoderManager;
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Audio
|
|
{
|
|
[Service("hwopus")]
|
|
class IHardwareOpusDecoderManager : IpcService
|
|
{
|
|
public IHardwareOpusDecoderManager(ServiceCtx context) { }
|
|
|
|
[Command(0)]
|
|
// Initialize(bytes<8, 4>, u32, handle<copy>) -> object<nn::codec::detail::IHardwareOpusDecoder>
|
|
public ResultCode Initialize(ServiceCtx context)
|
|
{
|
|
int sampleRate = context.RequestData.ReadInt32();
|
|
int channelsCount = context.RequestData.ReadInt32();
|
|
|
|
MakeObject(context, new IHardwareOpusDecoder(sampleRate, channelsCount));
|
|
|
|
// Close transfer memory immediately as we don't use it.
|
|
context.Device.System.KernelContext.Syscall.CloseHandle(context.Request.HandleDesc.ToCopy[0]);
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
[Command(1)]
|
|
// GetWorkBufferSize(bytes<8, 4>) -> u32
|
|
public ResultCode GetWorkBufferSize(ServiceCtx context)
|
|
{
|
|
// Note: The sample rate is ignored because it is fixed to 48KHz.
|
|
int sampleRate = context.RequestData.ReadInt32();
|
|
int channelsCount = context.RequestData.ReadInt32();
|
|
|
|
context.ResponseData.Write(GetOpusDecoderSize(channelsCount));
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
private static int GetOpusDecoderSize(int channelsCount)
|
|
{
|
|
const int silkDecoderSize = 0x2198;
|
|
|
|
if (channelsCount < 1 || channelsCount > 2)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
int celtDecoderSize = GetCeltDecoderSize(channelsCount);
|
|
|
|
int opusDecoderSize = (channelsCount * 0x800 + 0x4807) & -0x800 | 0x50;
|
|
|
|
return opusDecoderSize + silkDecoderSize + celtDecoderSize;
|
|
}
|
|
|
|
private static int GetCeltDecoderSize(int channelsCount)
|
|
{
|
|
const int decodeBufferSize = 0x2030;
|
|
const int celtDecoderSize = 0x58;
|
|
const int celtSigSize = 0x4;
|
|
const int overlap = 120;
|
|
const int eBandsCount = 21;
|
|
|
|
return (decodeBufferSize + overlap * 4) * channelsCount +
|
|
eBandsCount * 16 +
|
|
celtDecoderSize +
|
|
celtSigSize;
|
|
}
|
|
}
|
|
} |