Hi,
I met runtime error R6025 while programming tiny audio player. The error occurs when I close the application.
The program do simple job. Open the audio file, play or pause or stop it. Following variables are in the class.
private://[UserVariables] -- You can add your own custom variables in this section.
AudioDeviceManager _audioDeviceManager;AudioFormatManager _audioFormatManager;
ScopedPointer<AudioFormatReaderSource> _audioFormatReaderSource;
AudioTransportSource _audioTransportSource;
AudioSourcePlayer _audioSourcePlayer;
The program has 4 button to open and play the audio file, and following is body of the function "ButtonClicked"
void MainEditor::buttonClicked (Button* buttonThatWasClicked)
{
//[UserbuttonClicked_Pre]
//[/UserbuttonClicked_Pre]
if (buttonThatWasClicked == openButton)
{
//[UserButtonCode_openButton] -- add your button handler code here..
FileChooser chooser("Select a Wave file to play...", File::nonexistent, "*.wav");
if (chooser.browseForFileToOpen())
{
File file(chooser.getResult());
_audioFormatReaderSource = new AudioFormatReaderSource(
_audioFormatManager.createReaderFor(file), true);
_audioTransportSource.setSource(_audioFormatReaderSource);
playButton->setEnabled(true);
}
//[/UserButtonCode_openButton]
}
else if (buttonThatWasClicked == playButton)
{
//[UserButtonCode_playButton] -- add your button handler code here..
if ((Stopped == _state) || (Paused == _state))
{
changeState(Starting);
}
else if (Playing == _state)
{
changeState(Pausing);
}
//[/UserButtonCode_playButton]
}
else if (buttonThatWasClicked == stopButton)
{
//[UserButtonCode_stopButton] -- add your button handler code here..
if (Paused == _state)
{
changeState(Stopped);
}
else
{
changeState(Stopping);
}
//[/UserButtonCode_stopButton]
}
else if (buttonThatWasClicked == settingsButton)
{
//[UserButtonCode_settingsButton] -- add your button handler code here..
bool showMIDIInputOptions = false;
bool showMIDIOutputSelector = false;
bool showChannelAsStereoPairs = true;
bool hideAdvancedOptions = false;
AudioDeviceSelectorComponent settings(_audioDeviceManager,
0, 0, 1, 2,
showMIDIInputOptions,
showMIDIOutputSelector,
showChannelAsStereoPairs,
hideAdvancedOptions);
settings.setSize(500, 400);
DialogWindow::showModalDialog(juce::String("Audio Settings"),
&settings,
TopLevelWindow::getTopLevelWindow(0),
Colours::white,
true);
//[/UserButtonCode_settingsButton]
}
//[UserbuttonClicked_Post]
//[/UserbuttonClicked_Post]
}
And this is changeListenerCallback().
void MainEditor::changeListenerCallback(ChangeBroadcaster * src)
{
if (&_audioDeviceManager == src)
{
AudioDeviceManager::AudioDeviceSetup setup;
_audioDeviceManager.getAudioDeviceSetup(setup);
if (setup.outputChannels.isZero())
{
_audioSourcePlayer.setSource(nullptr);
}
else
{
_audioSourcePlayer.setSource(&_audioTransportSource);
}
}
else if (&_audioTransportSource == src)
{
if (_audioTransportSource.isPlaying())
{
changeState(Playing);
}
else
{
if ((Stopping == _state) || (Playing == _state))
{
changeState(Stopped);
}
else if (Pausing == _state)
{
changeState(Paused);
}
}
}
}
Plus, this is some part of the constructor.
//[Constructor] You can add your own custom stuff here..
playButton->setEnabled(false);
stopButton->setEnabled(false);
_audioFormatManager.registerBasicFormats();
_audioSourcePlayer.setSource(&_audioTransportSource);
_audioDeviceManager.addAudioCallback(&_audioSourcePlayer);
_audioDeviceManager.initialise(0, 2, nullptr, true);
_audioDeviceManager.addChangeListener(this);
_audioTransportSource.addChangeListener(this);
//[/Constructor]
The code I referenced was from the book "Getting statred with JUCE", Chapter 4 : "Adding audio file playback support".
There's sample code of the book so compiled it and met same error.
I need some help not only to fix this but also tell this issue to the book publisher to fix it.
Can you get what's the problem?
