From cfe51d73494b36559dabe27a540f180e8894d20e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 12 Apr 2021 13:35:45 -0400 Subject: [PATCH] Disconnect if we call loadMonitor a second time. --- src/zm_stream.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/zm_stream.cpp b/src/zm_stream.cpp index ee7ce26a7..30f8e40d3 100644 --- a/src/zm_stream.cpp +++ b/src/zm_stream.cpp @@ -50,6 +50,10 @@ bool StreamBase::loadMonitor(int p_monitor_id) { return false; } + if ( monitor->isConnected() ) { + monitor->disconnect(); + } + if ( !monitor->connect() ) { Error("Unable to connect to monitor id %d for streaming", monitor_id); monitor->disconnect(); @@ -60,15 +64,15 @@ bool StreamBase::loadMonitor(int p_monitor_id) { } bool StreamBase::checkInitialised() { - if ( !monitor ) { + if (!monitor) { Error("Cannot stream, not initialised"); return false; } - if ( monitor->GetFunction() == Monitor::NONE ) { + if (monitor->GetFunction() == Monitor::NONE) { Info("Monitor %d has function NONE. Will not be able to connect to it.", monitor_id); return false; } - if ( !monitor->ShmValid() ) { + if (!monitor->ShmValid()) { Error("Monitor shm is not connected"); return false; }