コード例 #1
0
        public CommandGenerator(CommandBuffer commandBuffer, RendererSystemContext rendererContext, VoiceContext voiceContext, MixContext mixContext, EffectContext effectContext, SinkContext sinkContext, SplitterContext splitterContext, PerformanceManager performanceManager)
        {
            _commandBuffer      = commandBuffer;
            _rendererContext    = rendererContext;
            _voiceContext       = voiceContext;
            _mixContext         = mixContext;
            _effectContext      = effectContext;
            _sinkContext        = sinkContext;
            _splitterContext    = splitterContext;
            _performanceManager = performanceManager;

            _commandBuffer.GenerateClearMixBuffer(Constants.InvalidNodeId);
        }
コード例 #2
0
ファイル: AudioRenderSystem.cs プロジェクト: jms-c/Ryujinx
        public AudioRenderSystem(AudioRendererManager manager, IWritableEvent systemEvent)
        {
            _manager            = manager;
            _terminationEvent   = new ManualResetEvent(false);
            _dspMemoryPoolState = MemoryPoolState.Create(MemoryPoolState.LocationType.Dsp);
            _voiceContext       = new VoiceContext();
            _mixContext         = new MixContext();
            _sinkContext        = new SinkContext();
            _splitterContext    = new SplitterContext();
            _effectContext      = new EffectContext();

            _commandProcessingTimeEstimator = null;
            _systemEvent      = systemEvent;
            _behaviourContext = new BehaviourContext();

            _totalElapsedTicksUpdating = 0;
            _sessionId = 0;
        }
コード例 #3
0
        /// <summary>
        /// Update the mix connection on the adjacency matrix.
        /// </summary>
        /// <param name="edgeMatrix">The adjacency matrix.</param>
        /// <param name="parameter">The input parameter of the mix.</param>
        /// <param name="splitterContext">The splitter context.</param>
        /// <returns>Return true, new connections were done on the adjacency matrix.</returns>
        private bool UpdateConnection(EdgeMatrix edgeMatrix, ref MixParameter parameter, ref SplitterContext splitterContext)
        {
            bool hasNewConnections;

            if (DestinationSplitterId == UnusedSplitterId)
            {
                hasNewConnections = false;
            }
            else
            {
                ref SplitterState splitter = ref splitterContext.GetState((int)DestinationSplitterId);

                hasNewConnections = splitter.HasNewConnection;
            }
コード例 #4
0
        // GetWorkBufferSize(nn::audio::detail::AudioRendererParameterInternal) -> u64
        public ResultCode GetAudioRendererWorkBufferSize(ServiceCtx context)
        {
            AudioRendererParameter parameters = GetAudioRendererParameter(context);

            if (AudioRendererCommon.CheckValidRevision(parameters))
            {
                BehaviorInfo behaviorInfo = new BehaviorInfo();

                behaviorInfo.SetUserLibRevision(parameters.Revision);

                long size;

                int totalMixCount = parameters.SubMixCount + 1;

                size = BitUtils.AlignUp(parameters.MixBufferCount * 4, AudioRendererConsts.BufferAlignment) +
                       parameters.SubMixCount * 0x400 +
                       totalMixCount * 0x940 +
                       parameters.VoiceCount * 0x3F0 +
                       BitUtils.AlignUp(totalMixCount * 8, 16) +
                       BitUtils.AlignUp(parameters.VoiceCount * 8, 16) +
                       BitUtils.AlignUp(((parameters.SinkCount + parameters.SubMixCount) * 0x3C0 + parameters.SampleCount * 4) *
                                        (parameters.MixBufferCount + 6), AudioRendererConsts.BufferAlignment) +
                       (parameters.SinkCount + parameters.SubMixCount) * 0x2C0 +
                       (parameters.EffectCount + parameters.VoiceCount * 4) * 0x30 +
                       0x50;

                if (behaviorInfo.IsSplitterSupported())
                {
                    size += BitUtils.AlignUp(NodeStates.GetWorkBufferSize(totalMixCount) + EdgeMatrix.GetWorkBufferSize(totalMixCount), 16);
                }

                size = parameters.SinkCount * 0x170 +
                       (parameters.SinkCount + parameters.SubMixCount) * 0x280 +
                       parameters.EffectCount * 0x4C0 +
                       ((size + SplitterContext.CalcWorkBufferSize(behaviorInfo, parameters) + 0x30 * parameters.EffectCount + (4 * parameters.VoiceCount) + 0x8F) & ~0x3FL) +
                       ((parameters.VoiceCount << 8) | 0x40);

                if (parameters.PerformanceManagerCount >= 1)
                {
                    size += (PerformanceManager.GetRequiredBufferSizeForPerformanceMetricsPerFrame(behaviorInfo, parameters) *
                             (parameters.PerformanceManagerCount + 1) + 0xFF) & ~0x3FL;
                }

                if (behaviorInfo.IsVariadicCommandBufferSizeSupported())
                {
                    size += CommandGenerator.CalculateCommandBufferSize(parameters) + 0x7E;
                }
                else
                {
                    size += 0x1807E;
                }

                size = BitUtils.AlignUp(size, 0x1000);

                context.ResponseData.Write(size);

                Logger.PrintDebug(LogClass.ServiceAudio, $"WorkBufferSize is 0x{size:x16}.");

                return(ResultCode.Success);
            }
            else
            {
                context.ResponseData.Write(0L);

                Logger.PrintWarning(LogClass.ServiceAudio, $"Library Revision REV{AudioRendererCommon.GetRevisionVersion(parameters.Revision)} is not supported!");

                return(ResultCode.UnsupportedRevision);
            }
        }
コード例 #5
0
        public static void Sort(string filePath, Comparison <string> comparator)
        {
            string tempFile1 = filePath + "__temp1.txt";
            string tempFile2 = filePath + "__temp2.txt";

            bool doProcess = true;

            while (doProcess)
            {
                // split src file
                using (var fs = new StreamReader(filePath, Config.Encoding))
                    using (var fs1 = new StreamWriter(tempFile1, false, Config.Encoding))
                        using (var fs2 = new StreamWriter(tempFile2, false, Config.Encoding))
                        {
#if DEBUG
                            fs1.AutoFlush = true;
                            fs2.AutoFlush = true;
#endif
                            var context = new SplitterContext(fs1, fs2);
                            var writer  = context.Writer;

                            string last = fs.ReadLine();
                            string line = fs.ReadLine();

                            writer.WriteLine(last);
                            while (!fs.EndOfStream)
                            {
                                if (comparator(last, line) > 0)
                                {
                                    writer = context.Switch();
                                }

                                writer.WriteLine(line);

                                last = line;
                                line = fs.ReadLine();
                            }

                            // flush buffer
                            writer.WriteLine(line);

                            //// calc doProcess
                            //fs1.Flush();
                            //fs2.Flush();
                            //doProcess = fs1.BaseStream.Length != 0 && fs2.BaseStream.Length != 0;

                            // add synthetic end of block markers
                            fs1.WriteLine(string.Empty);
                            fs2.WriteLine(string.Empty);
                        }

                if (!doProcess)
                {
#if !DEBUG
                    File.Delete(tempFile1);
                    File.Delete(tempFile2);
#endif
                    break;
                }

                // merge splitted files
                using (var fs = new StreamWriter(filePath, false, Config.Encoding))
                    using (var fs1 = new StreamReader(tempFile1, Config.Encoding))
                        using (var fs2 = new StreamReader(tempFile2, Config.Encoding))
                        {
#if DEBUG
                            fs.AutoFlush = true;
#endif
                            var reader1 = new MergerBlockContext(fs1, comparator);
                            var reader2 = new MergerBlockContext(fs2, comparator);

                            string line1 = reader1.BeginRead();
                            string line2 = reader2.BeginRead();

                            long destBlocksCount = 0;
                            while (!fs1.EndOfStream && !fs2.EndOfStream)
                            {
                                destBlocksCount++;
                                reader1.BeginBlock();
                                reader2.BeginBlock();

                                // merge current blocks
                                while (!reader1.IsBlockComplete && !reader2.IsBlockComplete)
                                {
                                    if (comparator(line1, line2) < 0)
                                    {
                                        fs.WriteLine(line1);
                                        line1 = reader1.ReadLine();
                                    }
                                    else
                                    {
                                        fs.WriteLine(line2);
                                        line2 = reader2.ReadLine();
                                    }
                                }

                                // flush block for file1
                                while (!reader1.IsBlockComplete)
                                {
                                    fs.WriteLine(line1);
                                    line1 = reader1.ReadLine();
                                }

                                // flush block for file2
                                while (!reader2.IsBlockComplete)
                                {
                                    fs.WriteLine(line2);
                                    line2 = reader2.ReadLine();
                                }
                            }

                            bool hasExtBlock = false;

                            // flush remained block for file1
                            reader1.BeginBlock();
                            while (!fs1.EndOfStream && !reader1.IsBlockComplete)
                            {
                                fs.WriteLine(line1);
                                line1       = reader1.ReadLine();
                                hasExtBlock = true;
                            }

                            // flush remained block for file2
                            reader2.BeginBlock();
                            while (!fs2.EndOfStream && !reader2.IsBlockComplete)
                            {
                                fs.WriteLine(line2);
                                line2       = reader2.ReadLine();
                                hasExtBlock = true;
                            }

                            doProcess = destBlocksCount > 1 || hasExtBlock;
                        }
            }
        }