mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
This commit is contained in:
parent
b3aabd8c2f
commit
5a40751a83
2 changed files with 62 additions and 3 deletions
|
|
@ -106,7 +106,7 @@ const String AudioDeviceManager::initialise (const int numInputChannelsNeeded,
|
|||
setMidiInputEnabled (allMidiIns[i], enabledMidiIns.contains (allMidiIns[i]));
|
||||
|
||||
if (error.isNotEmpty() && selectDefaultDeviceOnFailure)
|
||||
error = initialise (numInputChannelsNeeded, numOutputChannelsNeeded, 0,
|
||||
error = initialise (numInputChannelsNeeded, numOutputChannelsNeeded, 0,
|
||||
false, preferredDefaultDeviceName);
|
||||
|
||||
setDefaultMidiOutput (e->getStringAttribute (T("defaultMidiOutput")));
|
||||
|
|
@ -357,6 +357,44 @@ void AudioDeviceManager::stopDevice()
|
|||
currentAudioDevice->stop();
|
||||
}
|
||||
|
||||
void AudioDeviceManager::closeAudioDevice()
|
||||
{
|
||||
if (currentAudioDevice != 0)
|
||||
{
|
||||
lastRunningDevice = currentAudioDevice->getName();
|
||||
lastRunningBlockSize = currentAudioDevice->getCurrentBufferSizeSamples();
|
||||
lastRunningSampleRate = currentAudioDevice->getCurrentSampleRate();
|
||||
lastRunningIns = inputChannels;
|
||||
lastRunningOuts = outputChannels;
|
||||
|
||||
stopDevice();
|
||||
|
||||
setAudioDevice (String::empty, 0, 0, 0, 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
void AudioDeviceManager::restartLastAudioDevice()
|
||||
{
|
||||
if (currentAudioDevice == 0)
|
||||
{
|
||||
if (lastRunningDevice.isEmpty())
|
||||
{
|
||||
// This method will only reload the last device that was running
|
||||
// before closeAudioDevice() was called - you need to actually open
|
||||
// one first, with setAudioDevice().
|
||||
jassertfalse
|
||||
return;
|
||||
}
|
||||
|
||||
setAudioDevice (lastRunningDevice,
|
||||
lastRunningBlockSize,
|
||||
lastRunningSampleRate,
|
||||
&lastRunningIns,
|
||||
&lastRunningOuts,
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
void AudioDeviceManager::setInputChannels (const BitArray& newEnabledChannels,
|
||||
const bool treatAsChosenDevice)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -109,12 +109,12 @@ public:
|
|||
fails to open, then a default device will be used
|
||||
instead. If false, then on failure, no device is
|
||||
opened.
|
||||
@param preferredDefaultDeviceName if this is not empty, and there's a device with this
|
||||
@param preferredDefaultDeviceName if this is not empty, and there's a device with this
|
||||
name, then that will be used as the default device
|
||||
(assuming that there wasn't one specified in the XML).
|
||||
The string can actually be a simple wildcard, containing "*"
|
||||
and "?" characters
|
||||
|
||||
|
||||
@returns an error message if anything went wrong, or an empty string if it worked ok.
|
||||
*/
|
||||
const String initialise (const int numInputChannelsNeeded,
|
||||
|
|
@ -195,6 +195,23 @@ public:
|
|||
const BitArray* outputChans,
|
||||
const bool treatAsChosenDevice);
|
||||
|
||||
/** Closes the currently-open device.
|
||||
|
||||
You can call restartLastAudioDevice() later to reopen it in the same state
|
||||
that it was just in.
|
||||
*/
|
||||
void closeAudioDevice();
|
||||
|
||||
/** Tries to reload the last audio device that was running.
|
||||
|
||||
Note that this only reloads the last device that was running before
|
||||
closeAudioDevice() was called - it doesn't reload any kind of saved-state,
|
||||
and can only be called after a device has been opened with SetAudioDevice().
|
||||
|
||||
If a device is already open, this call will do nothing.
|
||||
*/
|
||||
void restartLastAudioDevice();
|
||||
|
||||
/** Returns the name of the currently selected audio device.
|
||||
|
||||
This will be an empty string if none is active.
|
||||
|
|
@ -384,6 +401,10 @@ private:
|
|||
};
|
||||
|
||||
CallbackHandler callbackHandler;
|
||||
String lastRunningDevice;
|
||||
int lastRunningBlockSize;
|
||||
double lastRunningSampleRate;
|
||||
BitArray lastRunningIns, lastRunningOuts;
|
||||
|
||||
friend class CallbackHandler;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue