|
@@ -820,8 +820,8 @@ public: |
|
|
const int oldBufferSize = bufferSize;
|
|
|
const int oldBufferSize = bufferSize;
|
|
|
|
|
|
|
|
|
if (! updateDetailsFromDevice())
|
|
|
if (! updateDetailsFromDevice())
|
|
|
owner.stop();
|
|
|
|
|
|
else if (oldBufferSize != bufferSize || oldSampleRate != sampleRate)
|
|
|
|
|
|
|
|
|
owner.stopInternal();
|
|
|
|
|
|
else if ((oldBufferSize != bufferSize || oldSampleRate != sampleRate) && owner.shouldRestartDevice())
|
|
|
owner.restart();
|
|
|
owner.restart();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
@@ -955,9 +955,7 @@ public: |
|
|
: AudioIODevice (deviceName, "CoreAudio"),
|
|
|
: AudioIODevice (deviceName, "CoreAudio"),
|
|
|
deviceType (dt),
|
|
|
deviceType (dt),
|
|
|
inputIndex (inputIndex_),
|
|
|
inputIndex (inputIndex_),
|
|
|
outputIndex (outputIndex_),
|
|
|
|
|
|
isOpen_ (false),
|
|
|
|
|
|
isStarted (false)
|
|
|
|
|
|
|
|
|
outputIndex (outputIndex_)
|
|
|
{
|
|
|
{
|
|
|
CoreAudioInternal* device = nullptr;
|
|
|
CoreAudioInternal* device = nullptr;
|
|
|
|
|
|
|
|
@@ -1084,6 +1082,8 @@ public: |
|
|
|
|
|
|
|
|
void stop() override
|
|
|
void stop() override
|
|
|
{
|
|
|
{
|
|
|
|
|
|
restartDevice = false;
|
|
|
|
|
|
|
|
|
if (isStarted)
|
|
|
if (isStarted)
|
|
|
{
|
|
|
{
|
|
|
AudioIODeviceCallback* const lastCallback = internal->callback;
|
|
|
AudioIODeviceCallback* const lastCallback = internal->callback;
|
|
@@ -1096,6 +1096,12 @@ public: |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void stopInternal()
|
|
|
|
|
|
{
|
|
|
|
|
|
stop();
|
|
|
|
|
|
restartDevice = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
bool isPlaying() override
|
|
|
bool isPlaying() override
|
|
|
{
|
|
|
{
|
|
|
if (internal->callback == nullptr)
|
|
|
if (internal->callback == nullptr)
|
|
@@ -1131,7 +1137,7 @@ public: |
|
|
if (internal->callback != nullptr)
|
|
|
if (internal->callback != nullptr)
|
|
|
previousCallback = internal->callback;
|
|
|
previousCallback = internal->callback;
|
|
|
|
|
|
|
|
|
stop();
|
|
|
|
|
|
|
|
|
stopInternal();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1149,12 +1155,14 @@ public: |
|
|
deviceWrapperRestartCallback = cb;
|
|
|
deviceWrapperRestartCallback = cb;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool shouldRestartDevice() const noexcept { return restartDevice; }
|
|
|
|
|
|
|
|
|
WeakReference<CoreAudioIODeviceType> deviceType;
|
|
|
WeakReference<CoreAudioIODeviceType> deviceType;
|
|
|
int inputIndex, outputIndex;
|
|
|
int inputIndex, outputIndex;
|
|
|
|
|
|
|
|
|
private:
|
|
|
private:
|
|
|
std::unique_ptr<CoreAudioInternal> internal;
|
|
|
std::unique_ptr<CoreAudioInternal> internal;
|
|
|
bool isOpen_, isStarted;
|
|
|
|
|
|
|
|
|
bool isOpen_ = false, isStarted = false, restartDevice = true;
|
|
|
String lastError;
|
|
|
String lastError;
|
|
|
AudioIODeviceCallback* previousCallback = nullptr;
|
|
|
AudioIODeviceCallback* previousCallback = nullptr;
|
|
|
std::function<void()> deviceWrapperRestartCallback = nullptr;
|
|
|
std::function<void()> deviceWrapperRestartCallback = nullptr;
|
|
@@ -1167,7 +1175,7 @@ private: |
|
|
{
|
|
|
{
|
|
|
stopTimer();
|
|
|
stopTimer();
|
|
|
|
|
|
|
|
|
stop();
|
|
|
|
|
|
|
|
|
stopInternal();
|
|
|
|
|
|
|
|
|
internal->updateDetailsFromDevice();
|
|
|
internal->updateDetailsFromDevice();
|
|
|
|
|
|
|
|
@@ -1649,7 +1657,7 @@ private: |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
for (auto* d : devices)
|
|
|
for (auto* d : devices)
|
|
|
d->device->stop();
|
|
|
|
|
|
|
|
|
d->device->stopInternal();
|
|
|
|
|
|
|
|
|
if (lastCallback != nullptr)
|
|
|
if (lastCallback != nullptr)
|
|
|
{
|
|
|
{
|
|
|