/// <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(); }
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); }
internal AudioStreamTrack(string label, AudioTrackSource source) : this(WebRTC.Context.CreateAudioTrack(label, source.self)) { _source = source; }