From 07a0a3df2d63d6f83b8d8342edac1b6706938a64 Mon Sep 17 00:00:00 2001
From: Thulinma <jaron@vietors.com>
Date: Fri, 4 Aug 2017 11:45:23 +0200
Subject: [PATCH] Moved STREAM_BUFFER EMPTY call from ~MistInBuffer() to
 finish()

---
 src/input/input_buffer.cpp | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/input/input_buffer.cpp b/src/input/input_buffer.cpp
index 209ab0bd..31c7894f 100644
--- a/src/input/input_buffer.cpp
+++ b/src/input/input_buffer.cpp
@@ -103,14 +103,6 @@ namespace Mist {
   inputBuffer::~inputBuffer() {
     config->is_active = false;
     if (myMeta.tracks.size()) {
-      /*LTS-START*/
-      if (myMeta.bufferWindow) {
-        if (Triggers::shouldTrigger("STREAM_BUFFER")) {
-          std::string payload = config->getString("streamname") + "\nEMPTY";
-          Triggers::doTrigger("STREAM_BUFFER", payload, config->getString("streamname"));
-        }
-      }
-      /*LTS-END*/
       DEBUG_MSG(DLVL_DEVEL, "Cleaning up, removing last keyframes");
       for (std::map<unsigned int, DTSC::Track>::iterator it = myMeta.tracks.begin(); it != myMeta.tracks.end(); it++) {
         std::map<unsigned long, DTSCPageData> & locations = bufferLocations[it->first];
@@ -432,6 +424,16 @@ namespace Mist {
   }
 
   void inputBuffer::finish() {
+    if (myMeta.tracks.size()) {
+      /*LTS-START*/
+      if (myMeta.bufferWindow) {
+        if (Triggers::shouldTrigger("STREAM_BUFFER")) {
+          std::string payload = config->getString("streamname") + "\nEMPTY";
+          Triggers::doTrigger("STREAM_BUFFER", payload, config->getString("streamname"));
+        }
+      }
+      /*LTS-END*/
+    }
     Input::finish();
     updateMeta();
     if (bufferLocations.size()) {