mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
CoreAudio: Return the correct index when the list of devices change
This commit is contained in:
parent
27fad0f975
commit
3540152d71
2 changed files with 11 additions and 14 deletions
|
|
@ -1207,12 +1207,10 @@ class CoreAudioIODevice : public AudioIODevice,
|
||||||
public:
|
public:
|
||||||
CoreAudioIODevice (CoreAudioIODeviceType* dt,
|
CoreAudioIODevice (CoreAudioIODeviceType* dt,
|
||||||
const String& deviceName,
|
const String& deviceName,
|
||||||
AudioDeviceID inputDeviceId, int inputIndex_,
|
AudioDeviceID inputDeviceId,
|
||||||
AudioDeviceID outputDeviceId, int outputIndex_)
|
AudioDeviceID outputDeviceId)
|
||||||
: AudioIODevice (deviceName, "CoreAudio"),
|
: AudioIODevice (deviceName, "CoreAudio"),
|
||||||
deviceType (dt),
|
deviceType (dt)
|
||||||
inputIndex (inputIndex_),
|
|
||||||
outputIndex (outputIndex_)
|
|
||||||
{
|
{
|
||||||
internal = [this, &inputDeviceId, &outputDeviceId]
|
internal = [this, &inputDeviceId, &outputDeviceId]
|
||||||
{
|
{
|
||||||
|
|
@ -1260,7 +1258,7 @@ public:
|
||||||
int getCurrentBufferSizeSamples() override { return internal->getBufferSize(); }
|
int getCurrentBufferSizeSamples() override { return internal->getBufferSize(); }
|
||||||
int getXRunCount() const noexcept override { return internal->xruns; }
|
int getXRunCount() const noexcept override { return internal->xruns; }
|
||||||
|
|
||||||
int getIndexOfDevice (bool asInput) const { return asInput ? inputIndex : outputIndex; }
|
int getIndexOfDevice (bool asInput) const { return deviceType->getDeviceNames (asInput).indexOf (getName()); }
|
||||||
|
|
||||||
int getDefaultBufferSize() override
|
int getDefaultBufferSize() override
|
||||||
{
|
{
|
||||||
|
|
@ -1389,7 +1387,6 @@ public:
|
||||||
bool shouldRestartDevice() const noexcept { return restartDevice; }
|
bool shouldRestartDevice() const noexcept { return restartDevice; }
|
||||||
|
|
||||||
WeakReference<CoreAudioIODeviceType> deviceType;
|
WeakReference<CoreAudioIODeviceType> deviceType;
|
||||||
int inputIndex, outputIndex;
|
|
||||||
bool hadDiscontinuity;
|
bool hadDiscontinuity;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -2265,12 +2262,12 @@ public:
|
||||||
: outputDeviceName;
|
: outputDeviceName;
|
||||||
|
|
||||||
if (inputDeviceID == outputDeviceID)
|
if (inputDeviceID == outputDeviceID)
|
||||||
return std::make_unique<CoreAudioIODevice> (this, combinedName, inputDeviceID, inputIndex, outputDeviceID, outputIndex).release();
|
return std::make_unique<CoreAudioIODevice> (this, combinedName, inputDeviceID, outputDeviceID).release();
|
||||||
|
|
||||||
auto in = inputDeviceID != 0 ? std::make_unique<CoreAudioIODevice> (this, inputDeviceName, inputDeviceID, inputIndex, 0, -1)
|
auto in = inputDeviceID != 0 ? std::make_unique<CoreAudioIODevice> (this, inputDeviceName, inputDeviceID, 0)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
|
||||||
auto out = outputDeviceID != 0 ? std::make_unique<CoreAudioIODevice> (this, outputDeviceName, 0, -1, outputDeviceID, outputIndex)
|
auto out = outputDeviceID != 0 ? std::make_unique<CoreAudioIODevice> (this, outputDeviceName, 0, outputDeviceID)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
|
||||||
if (in == nullptr) return out.release();
|
if (in == nullptr) return out.release();
|
||||||
|
|
|
||||||
|
|
@ -227,6 +227,8 @@ public:
|
||||||
type.scanForDevices();
|
type.scanForDevices();
|
||||||
|
|
||||||
setup.manager->addChangeListener (this);
|
setup.manager->addChangeListener (this);
|
||||||
|
|
||||||
|
updateAllControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
~AudioDeviceSettingsPanel() override
|
~AudioDeviceSettingsPanel() override
|
||||||
|
|
@ -1154,10 +1156,8 @@ void AudioDeviceSelectorComponent::updateAllControls()
|
||||||
details.maxNumOutputChannels = maxOutputChannels;
|
details.maxNumOutputChannels = maxOutputChannels;
|
||||||
details.useStereoPairs = showChannelsAsStereoPairs;
|
details.useStereoPairs = showChannelsAsStereoPairs;
|
||||||
|
|
||||||
auto sp = std::make_unique<AudioDeviceSettingsPanel> (*type, details, hideAdvancedOptionsWithButton);
|
audioDeviceSettingsComp = std::make_unique<AudioDeviceSettingsPanel> (*type, details, hideAdvancedOptionsWithButton);
|
||||||
addAndMakeVisible (*sp);
|
addAndMakeVisible (audioDeviceSettingsComp.get());
|
||||||
sp->updateAllControls();
|
|
||||||
audioDeviceSettingsComp = std::move (sp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue