Example #1
0
        /// <summary>
        /// This API will run the TAudioKernelUpdate on the target DSPNode asynchronously. Also returns
        /// a <typeparamref name="DSPNodeUpdateRequest"/> that can be used to track the progress of
        /// the update.
        /// </summary>
        /// <remarks>
        /// The <typeparamref name="DSPNodeUpdateRequest"/> returned allow access to the update structure
        /// after it has updated the DSP kernel. This can be used to retrieve information from the DSP kernel
        /// and process it on the main thread.
        /// </remarks>
        /// <typeparam name="TAudioKernelUpdate">The update kernel type</typeparam>
        /// <typeparam name="TParameters">Enum type of the parameters of the node</typeparam>
        /// <typeparam name="TProviders">Enum type of the sample providers of the node</typeparam>
        /// <typeparam name="TAudioKernel">The kernel type of the node</typeparam>
        /// <param name="updateJob">The structure used to update the running DSP kernel</param>
        /// <param name="node">The node that this update should operate on</param>
        /// <param name="callback">This will be executed on the main thread after the update job has run asynchronously</param>
        /// <returns>A struct that can query status and also retrieve the update structure after it has updated the node</returns>
        public DSPNodeUpdateRequest <TAudioKernelUpdate, TParameters, TProviders, TAudioKernel> CreateUpdateRequest <TAudioKernelUpdate, TParameters, TProviders, TAudioKernel>(
            TAudioKernelUpdate updateJob, DSPNode node, Action <DSPNodeUpdateRequest <TAudioKernelUpdate, TParameters, TProviders, TAudioKernel> > callback)
            where TAudioKernelUpdate : struct, IAudioKernelUpdate <TParameters, TProviders, TAudioKernel>
            where TParameters        : unmanaged, Enum
            where TProviders         : unmanaged, Enum
            where TAudioKernel       : struct, IAudioKernel <TParameters, TProviders>
        {
            AssertSameGraphAsNode(node);

            AudioKernelExtensions.GetReflectionData <TAudioKernel, TParameters, TProviders>(out void *nodeReflectionData, out AudioKernelExtensions.ParameterDescriptionData dummy);
            AudioKernelUpdateExtensions.GetReflectionData <TAudioKernelUpdate, TParameters, TProviders, TAudioKernel>(out void *updateJobReflectionData);

            var request = new DSPNodeUpdateRequest <TAudioKernelUpdate, TParameters, TProviders, TAudioKernel>(node);

            m_Graph.RegisterUpdateRequest(request, DSPGraphExtensions.WrapAction(callback, request));

            QueueCommand(new UpdateAudioKernelRequestCommand
            {
                m_Type   = DSPCommandType.UpdateAudioKernelRequest,
                m_Graph  = m_Graph,
                m_Handle = m_Handle,
                m_Node   = node.Handle,
                m_UpdateRequestHandle  = request.Handle,
                m_JobStructMemory      = Utility.CopyToPersistentAllocation(ref updateJob),
                m_JobReflectionData    = nodeReflectionData,
                m_UpdateReflectionData = updateJobReflectionData,
            });

            return(request);
        }