Skip to content

Commit

Permalink
Do not emit any event if no property were changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
hipersayanX committed Feb 11, 2025
1 parent 3c76afb commit 78853fc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
18 changes: 14 additions & 4 deletions cmio/VCamIPC/src/ipcbridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ namespace AkVCam
std::map<std::string, BroadcastSlot> m_broadcasts;
std::mutex m_broadcastsMutex;
std::map<int, Slot> m_messageSlots;
std::vector<std::string> m_devices;
std::string m_picture;

explicit IpcBridgePrivate(IpcBridge *self);
~IpcBridgePrivate();
Expand Down Expand Up @@ -684,7 +686,10 @@ bool AkVCam::IpcBridgePrivate::devicesUpdated(const Message &message)
for (size_t i = 0; i < nCameras; i++)
devices.push_back(Preferences::cameraId(i));

AKVCAM_EMIT(this->self, DevicesChanged, devices)
if (this->m_devices != devices) {
this->m_devices = devices;
AKVCAM_EMIT(this->self, DevicesChanged, devices)
}

return this->m_messageSlots[AKVCAM_SERVICE_MSG_DEVICES_UPDATED].run;
}
Expand All @@ -693,7 +698,11 @@ bool AkVCam::IpcBridgePrivate::pictureUpdated(const Message &message)
{
AkLogFunction();
auto picture = MsgPictureUpdated(message).picture();
AKVCAM_EMIT(this->self, PictureChanged, picture)

if (this->m_picture != picture) {
this->m_picture = picture;
AKVCAM_EMIT(this->self, PictureChanged, picture)
}

return this->m_messageSlots[AKVCAM_SERVICE_MSG_PICTURE_UPDATED].run;
}
Expand All @@ -715,9 +724,10 @@ bool AkVCam::IpcBridgePrivate::controlsUpdated(const Message &message)
AkLogDebug() << control.id << ": " << controls[control.id] << std::endl;
}

AKVCAM_EMIT(this->self, ControlsChanged, deviceId, controls)
if (!deviceId.empty() && !controls.empty())
AKVCAM_EMIT(this->self, ControlsChanged, deviceId, controls)

return true;
return this->m_messageSlots[AKVCAM_SERVICE_MSG_CONTROLS_UPDATED].run;
}

bool AkVCam::IpcBridgePrivate::frameRequired(const std::string &deviceId,
Expand Down
16 changes: 13 additions & 3 deletions dshow/VCamIPC/src/ipcbridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ namespace AkVCam
std::map<std::string, BroadcastSlot> m_broadcasts;
std::mutex m_broadcastsMutex;
std::map<int, Slot> m_messageSlots;
std::vector<std::string> m_devices;
std::string m_picture;

explicit IpcBridgePrivate(IpcBridge *self);
~IpcBridgePrivate();
Expand Down Expand Up @@ -743,7 +745,10 @@ bool AkVCam::IpcBridgePrivate::devicesUpdated(const Message &message)
for (size_t i = 0; i < nCameras; i++)
devices.push_back(Preferences::cameraId(i));

AKVCAM_EMIT(this->self, DevicesChanged, devices)
if (this->m_devices != devices) {
this->m_devices = devices;
AKVCAM_EMIT(this->self, DevicesChanged, devices)
}

return this->m_messageSlots[AKVCAM_SERVICE_MSG_DEVICES_UPDATED].run;
}
Expand All @@ -752,7 +757,11 @@ bool AkVCam::IpcBridgePrivate::pictureUpdated(const Message &message)
{
AkLogFunction();
auto picture = MsgPictureUpdated(message).picture();
AKVCAM_EMIT(this->self, PictureChanged, picture)

if (this->m_picture != picture) {
this->m_picture = picture;
AKVCAM_EMIT(this->self, PictureChanged, picture)
}

return this->m_messageSlots[AKVCAM_SERVICE_MSG_PICTURE_UPDATED].run;
}
Expand All @@ -774,7 +783,8 @@ bool AkVCam::IpcBridgePrivate::controlsUpdated(const Message &message)
AkLogDebug() << control.id << ": " << controls[control.id] << std::endl;
}

AKVCAM_EMIT(this->self, ControlsChanged, deviceId, controls)
if (!deviceId.empty() && !controls.empty())
AKVCAM_EMIT(this->self, ControlsChanged, deviceId, controls)

return this->m_messageSlots[AKVCAM_SERVICE_MSG_CONTROLS_UPDATED].run;
}
Expand Down

0 comments on commit 78853fc

Please sign in to comment.