| @@ -235,6 +235,7 @@ private: | |||||
| SharedResourcePointer<AudioSessionHolder> sessionHolder; | SharedResourcePointer<AudioSessionHolder> sessionHolder; | ||||
| JUCE_DECLARE_WEAK_REFERENCEABLE (iOSAudioIODeviceType) | |||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (iOSAudioIODeviceType) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (iOSAudioIODeviceType) | ||||
| }; | }; | ||||
| @@ -242,7 +243,7 @@ private: | |||||
| struct iOSAudioIODevice::Pimpl : public AudioPlayHead, | struct iOSAudioIODevice::Pimpl : public AudioPlayHead, | ||||
| public AsyncUpdater | public AsyncUpdater | ||||
| { | { | ||||
| Pimpl (iOSAudioIODeviceType& ioDeviceType, iOSAudioIODevice& ioDevice) | |||||
| Pimpl (iOSAudioIODeviceType* ioDeviceType, iOSAudioIODevice& ioDevice) | |||||
| : deviceType (ioDeviceType), | : deviceType (ioDeviceType), | ||||
| owner (ioDevice) | owner (ioDevice) | ||||
| { | { | ||||
| @@ -416,7 +417,8 @@ struct iOSAudioIODevice::Pimpl : public AudioPlayHead, | |||||
| updateAvailableSampleRates(); | updateAvailableSampleRates(); | ||||
| updateAvailableBufferSizes(); | updateAvailableBufferSizes(); | ||||
| deviceType.callDeviceChangeListeners(); | |||||
| if (deviceType != nullptr) | |||||
| deviceType->callDeviceChangeListeners(); | |||||
| } | } | ||||
| void setTargetSampleRateAndBufferSize() | void setTargetSampleRateAndBufferSize() | ||||
| @@ -1310,7 +1312,7 @@ struct iOSAudioIODevice::Pimpl : public AudioPlayHead, | |||||
| MidiMessageCollector* messageCollector = nullptr; | MidiMessageCollector* messageCollector = nullptr; | ||||
| iOSAudioIODeviceType& deviceType; | |||||
| WeakReference<iOSAudioIODeviceType> deviceType; | |||||
| iOSAudioIODevice& owner; | iOSAudioIODevice& owner; | ||||
| CriticalSection callbackLock; | CriticalSection callbackLock; | ||||
| @@ -1330,7 +1332,7 @@ struct iOSAudioIODevice::Pimpl : public AudioPlayHead, | |||||
| }; | }; | ||||
| //============================================================================== | //============================================================================== | ||||
| iOSAudioIODevice::iOSAudioIODevice (iOSAudioIODeviceType& ioDeviceType, const String&, const String&) | |||||
| iOSAudioIODevice::iOSAudioIODevice (iOSAudioIODeviceType* ioDeviceType, const String&, const String&) | |||||
| : AudioIODevice (iOSAudioDeviceName, iOSAudioDeviceName), | : AudioIODevice (iOSAudioDeviceName, iOSAudioDeviceName), | ||||
| pimpl (new Pimpl (ioDeviceType, *this)) | pimpl (new Pimpl (ioDeviceType, *this)) | ||||
| { | { | ||||
| @@ -1404,7 +1406,7 @@ bool iOSAudioIODeviceType::hasSeparateInputsAndOutputs() const { retu | |||||
| AudioIODevice* iOSAudioIODeviceType::createDevice (const String& outputDeviceName, const String& inputDeviceName) | AudioIODevice* iOSAudioIODeviceType::createDevice (const String& outputDeviceName, const String& inputDeviceName) | ||||
| { | { | ||||
| return new iOSAudioIODevice (*this, outputDeviceName, inputDeviceName); | |||||
| return new iOSAudioIODevice (this, outputDeviceName, inputDeviceName); | |||||
| } | } | ||||
| void iOSAudioIODeviceType::handleRouteChange (AVAudioSessionRouteChangeReason) | void iOSAudioIODeviceType::handleRouteChange (AVAudioSessionRouteChangeReason) | ||||
| @@ -77,7 +77,7 @@ public: | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| iOSAudioIODevice (iOSAudioIODeviceType&, const String&, const String&); | |||||
| iOSAudioIODevice (iOSAudioIODeviceType*, const String&, const String&); | |||||
| //============================================================================== | //============================================================================== | ||||
| friend class iOSAudioIODeviceType; | friend class iOSAudioIODeviceType; | ||||
| @@ -887,7 +887,9 @@ private: | |||||
| case kAudioDevicePropertyDeviceHasChanged: | case kAudioDevicePropertyDeviceHasChanged: | ||||
| case kAudioObjectPropertyOwnedObjects: | case kAudioObjectPropertyOwnedObjects: | ||||
| intern->owner.restart(); | intern->owner.restart(); | ||||
| intern->owner.deviceType.triggerAsyncAudioDeviceListChange(); | |||||
| if (intern->owner.deviceType != nullptr) | |||||
| intern->owner.deviceType->triggerAsyncAudioDeviceListChange(); | |||||
| break; | break; | ||||
| case kAudioDevicePropertyBufferSizeRange: | case kAudioDevicePropertyBufferSizeRange: | ||||
| @@ -946,7 +948,7 @@ class CoreAudioIODevice : public AudioIODevice, | |||||
| private Timer | private Timer | ||||
| { | { | ||||
| public: | public: | ||||
| CoreAudioIODevice (CoreAudioIODeviceType& dt, | |||||
| CoreAudioIODevice (CoreAudioIODeviceType* dt, | |||||
| const String& deviceName, | const String& deviceName, | ||||
| AudioDeviceID inputDeviceId, const int inputIndex_, | AudioDeviceID inputDeviceId, const int inputIndex_, | ||||
| AudioDeviceID outputDeviceId, const int outputIndex_) | AudioDeviceID outputDeviceId, const int outputIndex_) | ||||
| @@ -1109,7 +1111,8 @@ public: | |||||
| void audioDeviceListChanged() | void audioDeviceListChanged() | ||||
| { | { | ||||
| deviceType.audioDeviceListChanged(); | |||||
| if (deviceType != nullptr) | |||||
| deviceType->audioDeviceListChanged(); | |||||
| } | } | ||||
| void restart() | void restart() | ||||
| @@ -1146,7 +1149,7 @@ public: | |||||
| deviceWrapperRestartCallback = cb; | deviceWrapperRestartCallback = cb; | ||||
| } | } | ||||
| CoreAudioIODeviceType& deviceType; | |||||
| WeakReference<CoreAudioIODeviceType> deviceType; | |||||
| int inputIndex, outputIndex; | int inputIndex, outputIndex; | ||||
| private: | private: | ||||
| @@ -1199,7 +1202,7 @@ class AudioIODeviceCombiner : public AudioIODevice, | |||||
| private Timer | private Timer | ||||
| { | { | ||||
| public: | public: | ||||
| AudioIODeviceCombiner (const String& deviceName, CoreAudioIODeviceType& deviceType) | |||||
| AudioIODeviceCombiner (const String& deviceName, CoreAudioIODeviceType* deviceType) | |||||
| : AudioIODevice (deviceName, "CoreAudio"), | : AudioIODevice (deviceName, "CoreAudio"), | ||||
| Thread (deviceName), | Thread (deviceName), | ||||
| owner (deviceType) | owner (deviceType) | ||||
| @@ -1553,7 +1556,7 @@ public: | |||||
| } | } | ||||
| private: | private: | ||||
| CoreAudioIODeviceType& owner; | |||||
| WeakReference<CoreAudioIODeviceType> owner; | |||||
| CriticalSection callbackLock; | CriticalSection callbackLock; | ||||
| AudioIODeviceCallback* callback = nullptr; | AudioIODeviceCallback* callback = nullptr; | ||||
| AudioIODeviceCallback* previousCallback = nullptr; | AudioIODeviceCallback* previousCallback = nullptr; | ||||
| @@ -1775,8 +1778,8 @@ private: | |||||
| } | } | ||||
| } | } | ||||
| if (anySampleRateChanges) | |||||
| owner.audioDeviceListChanged(); | |||||
| if (anySampleRateChanges && owner != nullptr) | |||||
| owner->audioDeviceListChanged(); | |||||
| if (callback != nullptr) | if (callback != nullptr) | ||||
| callback->audioDeviceAboutToStart (device); | callback->audioDeviceAboutToStart (device); | ||||
| @@ -2160,20 +2163,20 @@ public: | |||||
| : outputDeviceName; | : outputDeviceName; | ||||
| if (inputDeviceID == outputDeviceID) | if (inputDeviceID == outputDeviceID) | ||||
| return new CoreAudioIODevice (*this, combinedName, inputDeviceID, inputIndex, outputDeviceID, outputIndex); | |||||
| return new CoreAudioIODevice (this, combinedName, inputDeviceID, inputIndex, outputDeviceID, outputIndex); | |||||
| std::unique_ptr<CoreAudioIODevice> in, out; | std::unique_ptr<CoreAudioIODevice> in, out; | ||||
| if (inputDeviceID != 0) | if (inputDeviceID != 0) | ||||
| in.reset (new CoreAudioIODevice (*this, inputDeviceName, inputDeviceID, inputIndex, 0, -1)); | |||||
| in.reset (new CoreAudioIODevice (this, inputDeviceName, inputDeviceID, inputIndex, 0, -1)); | |||||
| if (outputDeviceID != 0) | if (outputDeviceID != 0) | ||||
| out.reset (new CoreAudioIODevice (*this, outputDeviceName, 0, -1, outputDeviceID, outputIndex)); | |||||
| out.reset (new CoreAudioIODevice (this, outputDeviceName, 0, -1, outputDeviceID, outputIndex)); | |||||
| if (in == nullptr) return out.release(); | if (in == nullptr) return out.release(); | ||||
| if (out == nullptr) return in.release(); | if (out == nullptr) return in.release(); | ||||
| std::unique_ptr<AudioIODeviceCombiner> combo (new AudioIODeviceCombiner (combinedName, *this)); | |||||
| std::unique_ptr<AudioIODeviceCombiner> combo (new AudioIODeviceCombiner (combinedName, this)); | |||||
| combo->addDevice (in.release(), true, false); | combo->addDevice (in.release(), true, false); | ||||
| combo->addDevice (out.release(), false, true); | combo->addDevice (out.release(), false, true); | ||||
| return combo.release(); | return combo.release(); | ||||
| @@ -2235,6 +2238,7 @@ private: | |||||
| audioDeviceListChanged(); | audioDeviceListChanged(); | ||||
| } | } | ||||
| JUCE_DECLARE_WEAK_REFERENCEABLE (CoreAudioIODeviceType) | |||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CoreAudioIODeviceType) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CoreAudioIODeviceType) | ||||
| }; | }; | ||||
| @@ -1518,7 +1518,7 @@ private: | |||||
| class ChangeNotificationClient : public ComBaseClassHelper<IMMNotificationClient> | class ChangeNotificationClient : public ComBaseClassHelper<IMMNotificationClient> | ||||
| { | { | ||||
| public: | public: | ||||
| ChangeNotificationClient (WASAPIAudioIODeviceType& d) | |||||
| ChangeNotificationClient (WASAPIAudioIODeviceType* d) | |||||
| : ComBaseClassHelper<IMMNotificationClient> (0), device (d) {} | : ComBaseClassHelper<IMMNotificationClient> (0), device (d) {} | ||||
| HRESULT STDMETHODCALLTYPE OnDeviceAdded (LPCWSTR) { return notify(); } | HRESULT STDMETHODCALLTYPE OnDeviceAdded (LPCWSTR) { return notify(); } | ||||
| @@ -1528,9 +1528,15 @@ private: | |||||
| HRESULT STDMETHODCALLTYPE OnPropertyValueChanged (LPCWSTR, const PROPERTYKEY) { return notify(); } | HRESULT STDMETHODCALLTYPE OnPropertyValueChanged (LPCWSTR, const PROPERTYKEY) { return notify(); } | ||||
| private: | private: | ||||
| WASAPIAudioIODeviceType& device; | |||||
| WeakReference<WASAPIAudioIODeviceType> device; | |||||
| HRESULT notify() { device.triggerAsyncDeviceChangeCallback(); return S_OK; } | |||||
| HRESULT notify() | |||||
| { | |||||
| if (device != nullptr) | |||||
| device->triggerAsyncDeviceChangeCallback(); | |||||
| return S_OK; | |||||
| } | |||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChangeNotificationClient) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChangeNotificationClient) | ||||
| }; | }; | ||||
| @@ -1571,7 +1577,7 @@ private: | |||||
| if (! check (enumerator.CoCreateInstance (__uuidof (MMDeviceEnumerator)))) | if (! check (enumerator.CoCreateInstance (__uuidof (MMDeviceEnumerator)))) | ||||
| return; | return; | ||||
| notifyClient = new ChangeNotificationClient (*this); | |||||
| notifyClient = new ChangeNotificationClient (this); | |||||
| enumerator->RegisterEndpointNotificationCallback (notifyClient); | enumerator->RegisterEndpointNotificationCallback (notifyClient); | ||||
| } | } | ||||
| @@ -1660,6 +1666,7 @@ private: | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| JUCE_DECLARE_WEAK_REFERENCEABLE (WASAPIAudioIODeviceType) | |||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WASAPIAudioIODeviceType) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WASAPIAudioIODeviceType) | ||||
| }; | }; | ||||