I have some AudioSink which is assigned to some CaptureSource.
CaptureSource captureSource = new CaptureSource() {
VideoCaptureDevice = null,
AudioCaptureDevice = CaptureDeviceConfiguration.GetDefaultAudioCaptureDevice()
};
SampleAudioSink audioSink = new SampleAudioSink() {
CaptureSource = captureSource
};
captureSource.Start();
The AudioSink implementation simply logs the called function to see that it works properly. However, the OnSamples method stops being called after 37 samples.
- OnCaptureStarted
- OnFormatChange
- OnSamples (1)
- OnSamples (2)
- OnSamples (3)
- [...]
- OnSamples (35)
- OnSamples (36)
- OnSamples (37)
OnCaptureStopped is never called; the CaptureSource should continuously call this function. The CaptureSource also does 开发者_Go百科not invoke the CaptureFailed event.
What could produce this strange behaviour and what attempts could I take to fix it?
I have uploaded a complete source code which produces the problem to Pastebin
The problem was that the garbage collector deleted the AudioSink after 18 seconds...
Adding the AudioSink as a class member solved the problem.
[...]
TextBox log;
SampleAudioSink audioSink; // to prevent garbage collector from collection
private void Application_Startup (object sender, StartupEventArgs e) {
[...]
}
[...]
加载中,请稍侯......
精彩评论