コード例 #1
0
        private async Task <PPError> ConfigureAsyncCore(MediaStreamAudioTrackAttributes attributes, MessageLoop messageLoop = null)
        {
            var tcs = new TaskCompletionSource <PPError>();
            EventHandler <PPError> handler = (s, e) => { tcs.TrySetResult(e); };

            try
            {
                HandleConfigure += handler;

                if (MessageLoop == null && messageLoop == null)
                {
                    Configure(attributes);
                }
                else
                {
                    Action <PPError> action = new Action <PPError>((e) =>
                    {
                        var result = (PPError)PPBMediaStreamAudioTrack.Configure(this, attributes.ToAttributes(),
                                                                                 new BlockUntilComplete()
                                                                                 );
                        tcs.TrySetResult(result);
                    }
                                                                   );

                    InvokeHelper(action, messageLoop);
                }
                return(await tcs.Task);
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
                tcs.SetException(exc);
                return(PPError.Aborted);
            }
            finally
            {
                HandleConfigure -= handler;
            }
        }
コード例 #2
0
 /// <summary>
 /// Configures underlying buffer buffers for incoming audio samples.
 /// If the application doesn't want to drop samples, then the
 /// <code>Buffers</code> should be
 /// chosen such that inter-buffer processing time variability won't overrun
 /// all input buffers. If all buffers are filled, then samples will be
 /// dropped. The application can detect this by examining the timestamp on
 /// returned buffers. If <code>Configure()</code> is not called, default
 /// settings will be used. Calls to Configure while the plugin holds
 /// buffers will fail.
 /// Example usage from plugin code:
 /// <code>
 /// var attribs = new MediaStreamAudioTrackAttributes() {
 ///     Buffers = 4,
 ///     Duration, 10
 ///     };
 /// track.Configure(attribs);
 /// </code>
 /// </summary>
 /// <param name="attributes">A MediaStreamAudioTrackAttributes instance</param>
 /// <returns>Error code</returns>
 public PPError Configure(MediaStreamAudioTrackAttributes attributes)
 => (PPError)PPBMediaStreamVideoTrack.Configure(this, attributes.ToAttributes(), new CompletionCallback(OnConfigure));
コード例 #3
0
 /// <summary>
 /// Configures underlying buffer buffers for incoming audio samples asynchronously.
 /// If the application doesn't want to drop samples, then the
 /// <code>Buffers</code> should be
 /// chosen such that inter-buffer processing time variability won't overrun
 /// all input buffers. If all buffers are filled, then samples will be
 /// dropped. The application can detect this by examining the timestamp on
 /// returned buffers. If <code>Configure()</code> is not called, default
 /// settings will be used. Calls to Configure while the plugin holds
 /// buffers will fail.
 /// Example usage from plugin code:
 /// <code>
 /// var attribs = new MediaStreamAudioTrackAttributes() {
 ///     Buffers = 4,
 ///     Duration, 10
 ///     };
 /// track.Configure(attribs);
 /// </code>
 /// </summary>
 /// <param name="attributes">A MediaStreamAudioTrackAttributes instance</param>
 /// <param name="messageLoop">Optional MessageLoop instance that can be used to post the command to</param>
 /// <returns>Error code</returns>
 public Task <PPError> ConfigureAsync(MediaStreamAudioTrackAttributes attributes, MessageLoop messageLoop = null)
 => ConfigureAsyncCore(attributes, messageLoop);