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
|
|
@ -357,6 +357,44 @@ void AudioDeviceManager::stopDevice()
|
||||||
currentAudioDevice->stop();
|
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,
|
void AudioDeviceManager::setInputChannels (const BitArray& newEnabledChannels,
|
||||||
const bool treatAsChosenDevice)
|
const bool treatAsChosenDevice)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -195,6 +195,23 @@ public:
|
||||||
const BitArray* outputChans,
|
const BitArray* outputChans,
|
||||||
const bool treatAsChosenDevice);
|
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.
|
/** Returns the name of the currently selected audio device.
|
||||||
|
|
||||||
This will be an empty string if none is active.
|
This will be an empty string if none is active.
|
||||||
|
|
@ -384,6 +401,10 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
CallbackHandler callbackHandler;
|
CallbackHandler callbackHandler;
|
||||||
|
String lastRunningDevice;
|
||||||
|
int lastRunningBlockSize;
|
||||||
|
double lastRunningSampleRate;
|
||||||
|
BitArray lastRunningIns, lastRunningOuts;
|
||||||
|
|
||||||
friend class CallbackHandler;
|
friend class CallbackHandler;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue