History

Add option to auto mute microphone after lose face tracking

David Rowe committed 11 years ago

Commit ff7b2011 parent 95a56564 files · +26 −1Browse files

Showing the changes to interface/src/Application.cpp (1 of 4 files). Show all

Unified · Split

interface/src/Application.cpp+22−1
@@ -339,7 +339,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 338 unmodified lines
339339 _aboutToQuit(false),
340340 _notifiedPacketVersionMismatchThisDomain(false),
341341 _domainConnectionRefusals(QList<QString>()),
342− _maxOctreePPS(maxOctreePacketsPerSecond.get())
342+ _maxOctreePPS(maxOctreePacketsPerSecond.get()),
343+ _lastFaceTrackerUpdate(0)
343344 {
344345 setInstance(this);
345346 #ifdef Q_OS_WIN
@@ -2409,7 +2410,27 @@ void Application::update(float deltaTime) { · 2063 unmodified lines
24092410 FaceTracker* tracker = getActiveFaceTracker();
24102411 if (tracker && !tracker->isMuted()) {
24112412 tracker->update(deltaTime);
2413+
2414+ // Auto-mute microphone after losing face tracking?
2415+ if (tracker->isTracking()) {
2416+ _lastFaceTrackerUpdate = usecTimestampNow();
2417+ } else {
2418+ const quint64 MUTE_MICROPHONE_AFTER_USECS = 5000000; //5 secs
2419+ Menu* menu = Menu::getInstance();
2420+ if (menu->isOptionChecked(MenuOption::AutoMuteAudio) && !menu->isOptionChecked(MenuOption::MuteAudio)) {
2421+ if (_lastFaceTrackerUpdate > 0
2422+ && ((usecTimestampNow() - _lastFaceTrackerUpdate) > MUTE_MICROPHONE_AFTER_USECS)) {
2423+ menu->triggerOption(MenuOption::MuteAudio);
2424+ _lastFaceTrackerUpdate = 0;
2425+ }
2426+ } else {
2427+ _lastFaceTrackerUpdate = 0;
2428+ }
2429+ }
2430+ } else {
2431+ _lastFaceTrackerUpdate = 0;
24122432 }
2433+
24132434 SixenseManager::getInstance().update(deltaTime);
24142435 JoystickScriptingInterface::getInstance().update();
24152436 }