Refactor source IsConnected() and connected notification.

This commit is contained in:
Peter Johnson
2016-12-04 09:50:01 -08:00
parent 81fd0eefac
commit 7c2f994a66
6 changed files with 16 additions and 20 deletions

View File

@@ -11,6 +11,7 @@
#include <cstring>
#include "Log.h"
#include "Notifier.h"
using namespace cs;
@@ -44,6 +45,14 @@ llvm::StringRef SourceImpl::GetDescription(
return llvm::StringRef{buf.data(), buf.size()};
}
void SourceImpl::SetConnected(bool connected) {
bool wasConnected = m_connected.exchange(connected);
if (wasConnected && !connected)
Notifier::GetInstance().NotifySource(*this, CS_SOURCE_DISCONNECTED);
else if (!wasConnected && connected)
Notifier::GetInstance().NotifySource(*this, CS_SOURCE_CONNECTED);
}
uint64_t SourceImpl::GetCurFrameTime() {
std::unique_lock<std::mutex> lock{m_frameMutex};
return m_frame.time();