In my small application I have an algorithm real-time processing the line-input of the sound card. I added a button in the application which opens the audioDeviceManager configuration window. When chosing another soundcard than the deafult one the program breaks; I believe this could be solved by stopping the processing of the line-in stream when the configuration window is opened and when the configuration has been carried out the streaming should be started again (or maybe I should just do a reset). I might be wrong here!
If I’m not how can I do this (I couldn’t find a halt/stop member function of the audioDeviceManager class)?
[quote=“jules”]When you say it ‘breaks’, what do you mean? Just that it glitches? (which is kind of inevitable when you change device!)
If you need to smooth it out, why not just disconnect your own source from the processing chain, and reconnect it after the dialog has been closed?[/quote]
Hi Jules,
Sorry I know I’m not very elaborate here. With ‘Breaks’ I refer to when Visual Express 2008 prompts: “unhandled
exception at 0xsomething in juce applica…”
I just tried to do as you suggest (by disconnecting before the dialog and reconnect after) but that didn’t
work out much better…although now the program doesn’t break when the dialog window opens but it does when
it is closed.
I added a boolean (runAlgo) which is set to false when the dialog window is opened and set to true when closing
allowing the algorithm to run again. See code below!
THIS MIGHT BE COMPLETE NONSENSE - I hope I’m not waisting your time here…your replies are highly appreciated!
Ok, I see… well, you clearly have a few things to learn about multithreading! What I meant was actually to remove the audio callback before showing the dialog and put it back afterwards, which would be safer than what you’re attempting there. But really, if it’s crashing, you probably just need to find out what’s messing up and fix it. If your code is robust, you shouldn’t have to do anything special to cope with changing devices.
Like I said, if your code’s not robust, then trying to work around it by starting/stopping the manager is probably pointless. Find out why it’s crashing and fix it!