Browse Source

CoreAudioIODevice: Fix stale channel information after device information change

Until this commit CoreAudioIODevice could report inconsistent information in its
getActiveOutputChannels() and getOutputChannelNames() functions, and for
inputs as well. The reason for this was that a sudden configuration change
would immediately be reflected by the CoreAudioInternal::Stream::chanNames
member because those are read in the Stream's constructor. The activeChan
member would however just store stale values, until the Stream was recreated
later during device reopen.

This issue could lead to the AudioPluginHost crashing when opening a
Bluetooth headset.
v7.0.9
attila 3 years ago
parent
commit
9f99f02eb2
1 changed files with 7 additions and 10 deletions
  1. +7
    -10
      modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp

+ 7
- 10
modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp View File

@@ -622,12 +622,9 @@ public:
stop (false); stop (false);
const auto activeIns = BigInteger().setRange (0, jmin (ins .getHighestBit() + 1, getNumChannelNames (inStream)), true);
const auto activeOuts = BigInteger().setRange (0, jmin (outs.getHighestBit() + 1, getNumChannelNames (outStream)), true);
if (! setNominalSampleRate (newSampleRate)) if (! setNominalSampleRate (newSampleRate))
{ {
updateDetailsFromDevice (activeIns, activeOuts);
updateDetailsFromDevice (ins, outs);
error = "Couldn't change sample rate"; error = "Couldn't change sample rate";
} }
else else
@@ -637,7 +634,7 @@ public:
juceAudioObjectPropertyElementMain }, juceAudioObjectPropertyElementMain },
static_cast<UInt32> (bufferSizeSamples), err2log())) static_cast<UInt32> (bufferSizeSamples), err2log()))
{ {
updateDetailsFromDevice (activeIns, activeOuts);
updateDetailsFromDevice (ins, outs);
error = "Couldn't change buffer size"; error = "Couldn't change buffer size";
} }
else else
@@ -646,7 +643,7 @@ public:
// correctly report their new settings until some random time in the future, so // correctly report their new settings until some random time in the future, so
// after calling updateDetailsFromDevice, we need to manually bodge these values // after calling updateDetailsFromDevice, we need to manually bodge these values
// to make sure we're using the correct numbers.. // to make sure we're using the correct numbers..
updateDetailsFromDevice (activeIns, activeOuts);
updateDetailsFromDevice (ins, outs);
sampleRate = newSampleRate; sampleRate = newSampleRate;
bufferSize = bufferSizeSamples; bufferSize = bufferSizeSamples;
@@ -837,13 +834,13 @@ public:
//============================================================================== //==============================================================================
struct Stream struct Stream
{ {
Stream (bool isInput, CoreAudioInternal& parent, const BigInteger& active)
Stream (bool isInput, CoreAudioInternal& parent, const BigInteger& activeRequested)
: input (isInput), : input (isInput),
latency (getLatencyFromDevice (isInput, parent)), latency (getLatencyFromDevice (isInput, parent)),
bitDepth (getBitDepthFromDevice (isInput, parent)), bitDepth (getBitDepthFromDevice (isInput, parent)),
activeChans (active),
chanNames (getChannelNames (isInput, parent)), chanNames (getChannelNames (isInput, parent)),
channelInfo (getChannelInfos (isInput, parent, active)),
activeChans (BigInteger().setRange (0, jmin (activeRequested.getHighestBit() + 1, chanNames.size()), true)),
channelInfo (getChannelInfos (isInput, parent, activeChans)),
channels (static_cast<int> (channelInfo.size())) channels (static_cast<int> (channelInfo.size()))
{} {}
@@ -984,8 +981,8 @@ public:
const bool input; const bool input;
const int latency; const int latency;
const int bitDepth; const int bitDepth;
const BigInteger activeChans;
const StringArray chanNames; const StringArray chanNames;
const BigInteger activeChans;
const Array<CallbackDetailsForChannel> channelInfo; const Array<CallbackDetailsForChannel> channelInfo;
const int channels = 0; const int channels = 0;
Float64 previousSampleTime; Float64 previousSampleTime;


Loading…
Cancel
Save