SFML community forums

Bindings - other languages => DotNet => Topic started by: Conduit on April 01, 2015, 05:33:31 am

Title: Runtime error R6025 when using SoundRecorder in WinForms app
Post by: Conduit on April 01, 2015, 05:33:31 am
I'm building a WinForms control which uses a SoundRecorder subclass to provide Fast Fourier Transform data to my application. When closing my test application an error window appears stating:
Quote
Microsoft Visual C++ Runtime Library
---------------------------------------------------
Runtime Error!
[filepath]
R6025
- pure virtual function call
The error is not caused by an exception that can be caught by managed C#.

Having researched this error a bit (http://support.microsoft.com/en-us/kb/125749), I believe this might be caused by an issue with the destructor for SoundRecorder - I am too unfamiliar with the nuances of connecting managed C# to unmanaged C/C++ to say whether this is surely the case. I will be actively working on a more minimal example, hoping to post tomorrow if no one is able to solve this sooner.
Title: Re: Runtime error R6025 when using SoundRecorder in WinForms app
Post by: zsbzsb on April 01, 2015, 12:56:11 pm
Which doesn't make much sense considering the dtor is empty.

https://github.com/SFML/SFML/blob/master/src/SFML/Audio/SoundRecorder.cpp#L60

Quote
I will be actively working on a more minimal example

That would definitely be required to get anywhere.
Title: Re: Runtime error R6025 when using SoundRecorder in WinForms app
Post by: Conduit on April 01, 2015, 05:53:00 pm
Quote
Which doesn't make much sense considering the dtor is empty.

Hmm... there is the possibly that this is a problem with my implementation, since it appears that SoundRecorder::OnProcessSamples is the only abstract function in the class and that SoundRecorder is the root of that portion of the class hierarchy.

I don't know how or why this error would occur, though, since I've provided an override for the function within my class. Given the contents of the error and the fact that it occurs during cleanup, it seems that destroying the object somehow results in the processing thread calling the abstract SoundRecorder::OnProcessSamples instead of my override - I'm never calling the function outside the processing thread.

I'll begin working on a test case within an hour or so. If I'm unable to make one I'll put my code up somewhere, as it's nothing sensitive (just a little bulky due to the FFT logic).
Title: Re: Runtime error R6025 when using SoundRecorder in WinForms app
Post by: Conduit on April 02, 2015, 12:03:17 am
I haven't been able to produce a short, verifiable example, but it is looking like this might be related to using SoundRecorder instances as members of a form (likely WinForms being a pain, I figure?). Adding the following to the form's closing event fixes the issue:

private void FFTWindow_FormClosing(object sender, FormClosingEventArgs e)
{
    this.sampler.Stop();
}

As long as the processing thread is stopped directly as above, no trouble. Not entirely sure why this would happen, but I don't mind needing this workaround.