Пример #1
0
        /// <summary>
        ///
        /// </summary>
        public override void Dispose()
        {
            if (this.disposed)
            {
                return;
            }

            if (self != IntPtr.Zero && !WebRTC.Context.IsNull)
            {
                if (_audioCapturer != null)
                {
                    // Unity API must be called from main thread.
                    _audioCapturer.onAudioRead -= SetData;
                    WebRTC.DestroyOnMainThread(_audioCapturer);
                }
                if (_streamRenderer != null)
                {
                    _streamRenderer?.Dispose();
                    _streamRenderer = null;
                }
                _trackSource?.Dispose();
                _trackSource = null;
            }
            base.Dispose();
        }
Пример #2
0
 static void ProcessAudio(AudioTrackSource source, IntPtr array, int sampleRate, int channels, int frames)
 {
     if (sampleRate == 0 || channels == 0 || frames == 0)
     {
         throw new ArgumentException($"arguments are invalid values " +
                                     $"sampleRate={sampleRate}, " +
                                     $"channels={channels}, " +
                                     $"frames={frames}");
     }
     source.Update(array, sampleRate, channels, frames);
 }
Пример #3
0
 internal AudioStreamTrack(string label, AudioTrackSource source)
     : this(WebRTC.Context.CreateAudioTrack(label, source.self))
 {
     _source = source;
 }