Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Runtime error R6025 when using SoundRecorder in WinForms app  (Read 3932 times)

0 Members and 1 Guest are viewing this topic.

Conduit

  • Newbie
  • *
  • Posts: 30
    • View Profile
Runtime error R6025 when using SoundRecorder in WinForms app
« 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, 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.
« Last Edit: April 01, 2015, 05:36:30 am by Conduit »

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Runtime error R6025 when using SoundRecorder in WinForms app
« Reply #1 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.
« Last Edit: April 01, 2015, 01:16:56 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Conduit

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Runtime error R6025 when using SoundRecorder in WinForms app
« Reply #2 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).
« Last Edit: April 01, 2015, 06:03:43 pm by Conduit »

Conduit

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Runtime error R6025 when using SoundRecorder in WinForms app
« Reply #3 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.

 

anything