public void OnAudioOutFrameFloat(float[] data) { if (disposed) { return; } if (proc == IntPtr.Zero) { return; } foreach (var reverseBufFloat in reverseFramer.Frame(data)) { if (reverseBufFloat.Length != reverseBuf.Length) { Voice.AudioUtil.ResampleAndConvert(reverseBufFloat, reverseBuf, reverseBuf.Length, this.reverseChannels); } else { Voice.AudioUtil.Convert(reverseBufFloat, reverseBuf, reverseBuf.Length); } int err = webrtc_audio_processor_process_reverse(proc, reverseBuf, reverseBuf.Length); if (lastProcessReverseErr != err) { lastProcessReverseErr = err; this.logger.LogError("WebRTCAudioProcessor OnAudioOutFrameFloat: webrtc_audio_processor_process_reverse() error {0}", err); } } }
public void OnAudioOutFrame(float[] data, int outChannels) { if (disposed) { return; } lock (this) if (stEcho == IntPtr.Zero) { return; } if (outChannels != playChannels) { logger.LogError("SpeexProcessor AEC: OnAudioOutFrame channel count {0} != {1} AudioSettings.speakerMode channel count.", outChannels, playChannels); return; } if (_AECLatencyDetect) { this.detectPlay.Process(data); } foreach (var playbackBufFloat in playFramer.Frame(data)) { lock (playBufQueue) { // make sure that queue does not grow if buffers not consumed in Process if (playBufQueue.Count > playDelayMaxFrames) { logger.LogWarning("SpeexProcessor AEC: playbackBufQueue overrun: {0}", playBufQueue.Count); while (playBufQueue.Count > playDelayMaxFrames) { playbackBufPool.Release(playBufQueue.Dequeue()); } } } var playbackBuf = playbackBufPool.AcquireOrCreate(); if (playbackBufFloat.Length != playbackBuf.Length) { Voice.AudioUtil.ResampleAndConvert(playbackBufFloat, playbackBuf, playbackBuf.Length, outChannels); } else { Voice.AudioUtil.Convert(playbackBufFloat, playbackBuf, playbackBuf.Length); } lock (playBufQueue) { playBufQueue.Enqueue(playbackBuf); frameCntPlay++; } } }