Remove lastNotifyTime throttle. Could ignore last device notification.
Will bring back if necessary, but seemed like overkill.
Make isInputDevice const for safety.
Make isDefaultDevice atomic. Allows it to be accessed simultaneously
from settings and notification callback threads. Race between setting
change in OBS and Windows is not a problem, a signal will be sent after
both to consolidate. Worst that should happen is a redundant reconnect
cycle.
Only read/write default_id from notification callback for thread safety.
Do not store IAudioClient and IAudioCaptureClient onto the source object
until initialization is almost complete, right before the capture thread
is created. We don't to retain objects from failed attempts. Also clear
them when stopping.
The previous monitor recovery logic touches the source monitoring type,
resets the monitor even if the output device hasn't been invalidated,
and was susceptible to races. Monitor invalidation should live within
the monitor abstraction.
Probably long time coming, but when the user changes their default audio
device in Windows sound settings, OBS will now detect it and change the
audio device automatically to the new device if it was set to use the
"Default" device.
As os_gettime_ns() gets large the current scaling methods, mostly by casting
to uint64_t, may lead to numerical overflows. Sweep the code and use
util_mul_div64() where applicable.
Signed-off-by: Hans Petter Selasky <hps@selasky.org>
Not all devices return PKEY_AudioEngine_DeviceFormat properties.
Per MSDN, if the PROPERTYKEY referenced in key is not present in
the property store, this method returns S_OK and the vt member of
the structure pointed to by pv is set to VT_EMPTY.
Code submissions have continually suffered from formatting
inconsistencies that constantly have to be addressed. Using
clang-format simplifies this by making code formatting more consistent,
and allows automation of the code formatting so that maintainers can
focus more on the code itself instead of code formatting.
Remove KSAUDIO_SPEAKER_2POINT1 because it is included in the Windows
SDK. (I'm guessing it wasn't before.)
Redefine 4POINT1 as KSAUDIO_SPEAKER_SURROUND|SPEAKER_LOW_FREQUENCY
instead of KSAUDIO_SPEAKER_QUAD|SPEAKER_LOW_FREQUENCY. See definitions:
FFmpeg 4.1: FL+FR+FC+LFE+BC
WASAPI QUAD: FL+FR+BL+BR (looks wrong)
WASAPI SURROUND: FL+FR+FC+BC
WASAPI LOW_FREQUENCY: LFE
This commit fixes a bug where the user would have to restart OBS when
certain types of devices are unplugged and plugged back in again
(particularly USB devices). A wait interval is required
(RECONNECT_INTERVAL) because Windows does not send any events to
IAudioCaptureClient on device invalidation.