From 4f3c4a531227fec3ea77e5ee6978e676240f53e0 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 10 Aug 2015 12:52:47 -0700 Subject: [PATCH] Tidy up handling of eye tracker streaming --- interface/src/devices/EyeTracker.cpp | 14 +++++++++----- interface/src/devices/EyeTracker.h | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/interface/src/devices/EyeTracker.cpp b/interface/src/devices/EyeTracker.cpp index 9a35448bd0..7620dc070f 100644 --- a/interface/src/devices/EyeTracker.cpp +++ b/interface/src/devices/EyeTracker.cpp @@ -29,9 +29,11 @@ static void CALLBACK eyeTrackerCallback(smi_CallbackDataStruct* data) { EyeTracker::~EyeTracker() { #ifdef HAVE_IVIEWHMD - int result = smi_quit(); - if (result != SMI_RET_SUCCESS) { - qCWarning(interfaceapp) << "Eye Tracker: Error terminating tracking:" << smiReturnValueToString(result); + if (_isStreaming) { + int result = smi_quit(); + if (result != SMI_RET_SUCCESS) { + qCWarning(interfaceapp) << "Eye Tracker: Error terminating tracking:" << smiReturnValueToString(result); + } } #endif } @@ -131,16 +133,18 @@ void EyeTracker::setEnabled(bool enabled, bool simulate) { qCDebug(interfaceapp) << "Eye Tracker: Set enabled =" << enabled << ", simulate =" << simulate; bool success = true; int result = 0; - if (enabled) { + if (enabled && !_isStreaming) { // There is no smi_stopStreaming() method so keep streaming once started in case tracking is re-enabled after stopping. result = smi_startStreaming(simulate); if (result != SMI_RET_SUCCESS) { qCWarning(interfaceapp) << "Eye Tracker: Error starting streaming:" << smiReturnValueToString(result); success = false; } + + _isStreaming = success; } - _isEnabled = enabled && success; + _isEnabled = enabled && _isStreaming; _isSimulating = _isEnabled && simulate; if (!success && result != SMI_ERROR_HMD_NOT_SUPPORTED) { diff --git a/interface/src/devices/EyeTracker.h b/interface/src/devices/EyeTracker.h index 4976c14d08..b1c71c0303 100644 --- a/interface/src/devices/EyeTracker.h +++ b/interface/src/devices/EyeTracker.h @@ -50,6 +50,7 @@ private: QString smiReturnValueToString(int value); bool _isInitialized = false; + bool _isStreaming = false; bool _isEnabled = false; bool _isSimulating = false;