AudioDeviceManager bug when createXmlState()


#1

Hi Jules,
In taking a break from the recording issue I’m having, I tried using AudioDeviceManager::createXmlState tonight and came across an issue which might be a bug. I think I may have also Identified the problem… Ideally, at my program shutdown I’d like to save whatever the AudioDeviceManager settings are set, and to try to reload them on next program launch. In the destructor of my maincomponent i attempt to write the AudioDeviceManagers settings…

ScopedPointer<XmlElement> saveAudioDeviceXmlElement(audioDeviceManager.createStateXml());
	saveAudioDeviceXmlElement->writeToFile(File(File::getSpecialLocation(File::commonApplicationDataDirectory).getFullPathName() 
												+ "/FlipMu/Nuance/lastAudioConfig.xml"), String::empty, "UTF-8", 200);

When I close my app, I hit an error and the file never finishes being created (just an unfinished temp file). The debugger seems to be stuck on am empty string I think. I tried editing AudioDeviceManager and calling AudioDeviceManager::updateXml() at the end of AudioDeviceManager::initialise to ensure that the values were being stored, and that fixed it from crashing, however, the resulting xml is basically empty–

<?xml version="1.0" encoding="UTF-8"?>

<DEVICESETUP deviceType="CoreAudio" audioOutputDeviceName="" audioInputDeviceName=""/>

If I open up an AudioDeviceSelectorComponent and change the audio input device, they input/output device names and samplerate get stored in the xml file properly, but not the enabled input/output channels. If I manually disable and re-enable those, they then get stored properly. Buffer-size never seems to store…

Just thought I’d give you a heads up in case its an actual bug and not some silly mistake on my part!

Cheers


#2

you don’t seem to be checking whether createStateXml() returns a null pointer? If the audio setup has just been left as the default, then it won’t actually return any settings.


#3

oops, my bad. I was looking at it thinking it never returned a null pointer, but it makes perfect sense. Just added the check to make sure it isn’t a nullptr before trying to save, and quickly added a line to create a new XmlDocument from the file in my constructor, passing the main document node into my initialise and its working great. Thanks!