Merge branch 'BuddyFriendGuy/fixVolumeReset' into 'master'
authorAnt Zucaro <azucaro@gmail.com>
Tue, 23 Jun 2015 12:56:37 +0000 (12:56 +0000)
committerAnt Zucaro <azucaro@gmail.com>
Tue, 23 Jun 2015 12:56:37 +0000 (12:56 +0000)
fix volume value preservation bug in NexuizDemoRecorder

Symptom: In the original code, the user's original volume value is not preserved (the default behavior is to mute the volume during fast forward) so the program fails to set the correct volume value back -- in fact it sets it to an illegal variable name.

Code problem: This bug happens in the case of user choosing to record the demo early on, i.e. the loop enters the second stage right away, so injectAtStart was never executed. Besides, srvLoop and firstLoop seem to do the same thing.

Fix: Make sure injectAtStart is executed exactly once.

See merge request !12

misc/tools/NexuizDemoRecorder/main/pom.xml
misc/tools/NexuizDemoRecorder/main/src/main/java/com/nexuiz/demorecorder/application/democutter/DemoCutter.java
misc/tools/NexuizDemoRecorder/main/src/main/java/com/nexuiz/demorecorder/ui/swinggui/SwingGUI.java

index 039019416d9afafb8fbb9b33af07b470fdafec9e..821f0e09b52c26fde564ce212fff60c95fab3e9b 100644 (file)
@@ -4,7 +4,7 @@
        <groupId>NexuizDemoRecorder</groupId>
        <artifactId>NexuizDemoRecorder</artifactId>
        <packaging>jar</packaging>
-       <version>0.3</version>
+       <version>0.3.1</version>
        <name>NexuizDemoRecorder</name>
        <url>http://maven.apache.org</url>
        <dependencies>
index a1174e66fee17d0ff6e099f7d8982fb2bc3cd767..105ae12b4168b685427b3239429479de40690e87 100644 (file)
@@ -63,7 +63,6 @@ public class DemoCutter {
                boolean endIsReached = false;
                boolean finalInjectionDone = false;
                boolean disconnectIssued = false;
-               int svcLoops = 0;
                float firstSvcTime = -1;
                float lastSvcTime = -1;
                
@@ -96,42 +95,39 @@ public class DemoCutter {
                                        }
                                        lastSvcTime = svctime;
                                        
-                                       if (firstLoop) {
-                                               injectBuffer = "\011\n" + injectAtStart + ";slowmo " + ffwSpeedFirstStage + "\n\000";
-                                               firstLoop = false;
-                                       }
                                        if (demoStarted < 1 && svctime > (startTime - 50)) {
-                                               if (svcLoops == 0) {
-                                                       //make sure that for short demos (duration less than 50 sec)
-                                                       //the injectAtStart is still honored
-                                                       injectBuffer = "\011\n" + injectAtStart + ";slowmo " + ffwSpeedSecondStage + "\n\000";
-                                               } else {
-                                                       injectBuffer = "\011\nslowmo " + ffwSpeedSecondStage + "\n\000";
-                                               }
-                                               
+                                               injectBuffer = "slowmo " + ffwSpeedSecondStage;
                                                demoStarted = 1;
                                        }
                                        if (demoStarted < 2 && svctime > (startTime - 5)) {
-                                               injectBuffer = "\011\nslowmo 1;" + injectBeforeCap +"\n\000";
+                                               injectBuffer = "slowmo 1;" + injectBeforeCap;
                                                demoStarted = 2;
                                        }
                                        if (demoStarted < 3 && svctime > startTime) {
-                                               injectBuffer = "\011\ncl_capturevideo 1\n\000";
+                                               injectBuffer = "cl_capturevideo 1";
                                                demoStarted = 3;
                                        }
                                        if (!endIsReached && svctime > endTime) {
-                                               injectBuffer = "\011\ncl_capturevideo 0\n\000";
+                                               injectBuffer = "cl_capturevideo 0";
                                                endIsReached = true;
                                        }
                                        if (endIsReached && !finalInjectionDone && svctime > (endTime + 1)) {
-                                               injectBuffer = "\011\n" + injectAfterCap + "\n\000";
+                                               injectBuffer = injectAfterCap;
                                                finalInjectionDone = true;
                                        }
                                        if (finalInjectionDone && !disconnectIssued && svctime > (endTime + 2)) {
-                                               injectBuffer = "\011\ndisconnect\n\000";
+                                               injectBuffer = "disconnect";
                                                disconnectIssued = true;
                                        }
-                                       svcLoops++;
+                                       // ensure injectAtStart runs exactly once, before everything else
+                                       if (firstLoop) {
+                                               injectBuffer = injectAtStart + ";slowmo " + ffwSpeedFirstStage + ";" + injectBuffer;
+                                               firstLoop = false;
+                                       }
+                                       // add Buffer head and tail
+                                       if (injectAtStart.length() > 0) {
+                                               injectBuffer = "\011\n" + checkInjectString(injectBuffer) + "\n\000";
+                                       }
                                }
 
                                byte[] injectBufferAsBytes = null;
index bb662c7c4e4af2fb2cb13faa918b3d8bcb0974f8..a00de35b6863ae8e3a6ef34bd5eb44ceadc41dc3 100644 (file)
@@ -144,7 +144,7 @@ public class SwingGUI extends JFrame implements WindowListener, DemoRecorderUI {
        private static final String mainHelpSetName = "help/DemoRecorderHelp.hs";
 
        public SwingGUI(DemoRecorderApplication appLayer) {
-               super("Nexuiz Demo Recorder v0.3");
+               super("Nexuiz Demo Recorder v0.3.1");
                addWindowListener(this);
 
                this.appLayer = appLayer;