aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Audio/AudioRendererManager/PerformanceManager.cs
blob: 1b8c8a7cc1fffeefc8e6cdd3ec95dba38bca4e7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using Ryujinx.Common.Logging;

namespace Ryujinx.HLE.HOS.Services.Audio.AudioRendererManager
{
    static class PerformanceManager
    {
        public static long GetRequiredBufferSizeForPerformanceMetricsPerFrame(BehaviorInfo behaviorInfo, AudioRendererParameter parameters)
        {
            int performanceMetricsDataFormat = behaviorInfo.GetPerformanceMetricsDataFormat();

            if (performanceMetricsDataFormat == 2)
            {
                return 24 * (parameters.VoiceCount  + 
                             parameters.EffectCount + 
                             parameters.SubMixCount + 
                             parameters.SinkCount   + 1) + 0x990;
            }

            if (performanceMetricsDataFormat != 1)
            {
                Logger.PrintWarning(LogClass.ServiceAudio, $"PerformanceMetricsDataFormat: {performanceMetricsDataFormat} is not supported!");
            }

            return (((parameters.VoiceCount  + 
                      parameters.EffectCount +
                      parameters.SubMixCount + 
                      parameters.SinkCount   + 1) << 32) >> 0x1C) + 0x658;
        }
    }
}