[VCM]Only use File Watchers if module is enabled (#22757)

This commit is contained in:
Jaime Bernardo 2022-12-13 17:35:23 +00:00 committed by GitHub
parent d50b89262c
commit 150f26731c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 7 deletions

View File

@ -311,11 +311,7 @@ void VideoConferenceModule::onMicrophoneConfigurationChanged()
} }
} }
VideoConferenceModule::VideoConferenceModule() : VideoConferenceModule::VideoConferenceModule()
_generalSettingsWatcher{ PTSettingsHelper::get_powertoys_general_save_file_location(), [this] {
toolbar.scheduleGeneralSettingsUpdate();
} },
_moduleSettingsWatcher{ PTSettingsHelper::get_module_save_file_location(get_key()), [this] { toolbar.scheduleModuleSettingsUpdate(); } }
{ {
init_settings(); init_settings();
_settingsUpdateChannel = _settingsUpdateChannel =
@ -524,6 +520,15 @@ void VideoConferenceModule::enable()
{ {
if (!_enabled) if (!_enabled)
{ {
_generalSettingsWatcher = std::make_unique<FileWatcher> (
PTSettingsHelper::get_powertoys_general_save_file_location(), [this] {
toolbar.scheduleGeneralSettingsUpdate();
});
_moduleSettingsWatcher = std::make_unique<FileWatcher> (
PTSettingsHelper::get_module_save_file_location(get_key()), [this] {
toolbar.scheduleModuleSettingsUpdate();
});
toggleProxyCamRegistration(true); toggleProxyCamRegistration(true);
toolbar.setMicrophoneMute(getMicrophoneMuteState()); toolbar.setMicrophoneMute(getMicrophoneMuteState());
toolbar.setCameraMute(getVirtualCameraMuteState()); toolbar.setCameraMute(getVirtualCameraMuteState());
@ -572,6 +577,8 @@ void VideoConferenceModule::disable()
{ {
if (_enabled) if (_enabled)
{ {
_generalSettingsWatcher.reset();
_moduleSettingsWatcher.reset();
toggleProxyCamRegistration(false); toggleProxyCamRegistration(false);
if (hook_handle) if (hook_handle)
{ {

View File

@ -88,8 +88,8 @@ private:
std::optional<SerializedSharedMemory> _imageOverlayChannel; std::optional<SerializedSharedMemory> _imageOverlayChannel;
std::optional<SerializedSharedMemory> _settingsUpdateChannel; std::optional<SerializedSharedMemory> _settingsUpdateChannel;
FileWatcher _generalSettingsWatcher; std::unique_ptr<FileWatcher> _generalSettingsWatcher;
FileWatcher _moduleSettingsWatcher; std::unique_ptr<FileWatcher> _moduleSettingsWatcher;
static VideoConferenceSettings settings; static VideoConferenceSettings settings;
static Toolbar toolbar; static Toolbar toolbar;