diff --git a/include/devices/OpenCloseDevice.h b/include/devices/OpenCloseDevice.h index 5d163da..2048396 100644 --- a/include/devices/OpenCloseDevice.h +++ b/include/devices/OpenCloseDevice.h @@ -18,11 +18,12 @@ /** * @file OpenCloseDevice.h - * @ingroup plugin + * @ingroup devices * The OpenCloseDevice class. */ #include +#include #include "devices/SoftwareDevice.h" @@ -37,27 +38,27 @@ private: /** * Whether the device is opened. */ - bool m_device_opened; + bool m_device_opened{false}; /** * Whether there is currently playback. */ - bool m_playing; + bool m_playing{false}; /** - * Thread used to release the device after time delay. + * Whether thread released the device. */ - std::thread m_delayed_close_thread; + bool m_delayed_close_finished{false}; /** - * How long to wait until closing the device.. + * Thread used to release the device after time delay. */ - std::chrono::milliseconds m_device_close_delay; + std::thread m_delayed_close_thread; /** - * Whether thread released the device. + * How long to wait until closing the device.. */ - bool m_delayed_close_finished; + std::chrono::milliseconds m_device_close_delay{std::chrono::milliseconds(10000)}; /** * Time when playback has stopped. @@ -80,7 +81,7 @@ private: AUD_LOCAL virtual void stop() = 0; /** - * Acquires the device. + * Acquires the device. */ AUD_LOCAL virtual void open() = 0; @@ -94,13 +95,9 @@ private: OpenCloseDevice& operator=(const OpenCloseDevice&) = delete; protected: - virtual void playing(bool playing); + OpenCloseDevice() = default; - /** - * Empty default constructor. To setup the device call the function create() - * and to uninitialize call destroy(). - */ - OpenCloseDevice() : m_device_opened(false), m_delayed_close_finished(false), m_playing(false), m_device_close_delay(std::chrono::milliseconds(10000)) {} + virtual void playing(bool playing); }; AUD_NAMESPACE_END diff --git a/plugins/coreaudio/CoreAudioDevice.cpp b/plugins/coreaudio/CoreAudioDevice.cpp index 8896fe5..340b22b 100644 --- a/plugins/coreaudio/CoreAudioDevice.cpp +++ b/plugins/coreaudio/CoreAudioDevice.cpp @@ -145,6 +145,13 @@ void CoreAudioDevice::open() } } +void CoreAudioDevice::close() +{ + AudioOutputUnitStop(m_audio_unit); + AudioUnitUninitialize(m_audio_unit); + AudioComponentInstanceDispose(m_audio_unit); +} + CoreAudioDevice::CoreAudioDevice(DeviceSpecs specs, int buffersize) : m_playback(false), m_audio_unit(nullptr) @@ -162,13 +169,6 @@ m_audio_unit(nullptr) create(); } -void CoreAudioDevice::close() -{ - AudioOutputUnitStop(m_audio_unit); - AudioUnitUninitialize(m_audio_unit); - AudioComponentInstanceDispose(m_audio_unit); -} - CoreAudioDevice::~CoreAudioDevice() { close(); diff --git a/plugins/coreaudio/CoreAudioDevice.h b/plugins/coreaudio/CoreAudioDevice.h index 2575946..c70a49d 100644 --- a/plugins/coreaudio/CoreAudioDevice.h +++ b/plugins/coreaudio/CoreAudioDevice.h @@ -26,9 +26,7 @@ * The CoreAudioDevice class. */ -#include #include -#include #include