QTfrontend/net/recorder.cpp
branchui-scaling
changeset 15304 c4fd2813b127
parent 13389 24b531dcebe7
parent 14650 8ffa0c27f434
--- a/QTfrontend/net/recorder.cpp	Wed May 16 18:22:28 2018 +0200
+++ b/QTfrontend/net/recorder.cpp	Wed Jul 31 23:14:27 2019 +0200
@@ -23,6 +23,7 @@
 #include "gameuiconfig.h"
 #include "hwconsts.h"
 #include "game.h"
+#include "util/MessageDialog.h"
 #include "LibavInteraction.h"
 
 // Encoding is memory expensive process, so we need to limit maximum number
@@ -33,12 +34,13 @@
 static QList<HWRecorder*> queue;
 
 HWRecorder::HWRecorder(GameUIConfig * config, const QString &prefix) :
-    TCPBase(false)
+    TCPBase(false, !config->language().isEmpty())
 {
     this->config = config;
     this->prefix = prefix;
     item = 0;
     finished = false;
+    aborted = false;
     name = prefix + "." + LibavInteraction::instance().getExtension(config->AVFormat());
 }
 
@@ -75,6 +77,16 @@
         case 'v':
             finished = true;
             break;
+        case 'E':
+            int size = msg.size();
+            emit ErrorMessage(
+                tr("A fatal ERROR occured while processing the video recording! "
+                "The video could not be saved.\n\n"
+                "As a workaround, you could try to reset the Hedgewars video recorder settings to the defaults.\n\n"
+                "To report this error, please click the 'Feedback' button in the main menu!\n\n"
+                "Last engine message:\n%1")
+                .arg(QString::fromUtf8(msg.mid(2).left(size - 4))));
+            return;
         }
     }
 }
@@ -140,7 +152,10 @@
 // Could use a field to use quality instead. maybe quality could override bitrate - or just pass (and set) both.
 // The library does support using both at once after all.
     arguments << QString::number(config->rec_Bitrate()*1024);
-    arguments << (config->recordAudio() ? config->audioCodec() : "no");
+    if (config->recordAudio() && (config->isSoundEnabled() || config->isMusicEnabled()))
+        arguments << config->audioCodec();
+    else
+        arguments << "no";
     arguments << "--chat-size";
     arguments << QString::number(config->chatSize());
 
@@ -151,3 +166,10 @@
 {
     return true;
 }
+
+void HWRecorder::abort()
+{
+    queue.removeOne(this);
+    aborted = true;
+    deleteLater();
+}