Diff of /branches/edit_controllers/rosegarden/src/sequencer/SequencerThread.cpp [r12984] .. [r12985] Maximize Restore

  Switch to side-by-side view

--- a/branches/edit_controllers/rosegarden/src/sequencer/SequencerThread.cpp
+++ b/branches/edit_controllers/rosegarden/src/sequencer/SequencerThread.cpp
@@ -19,7 +19,6 @@
 #include <unistd.h>
 #include <sys/time.h>
 
-
 #include <QDateTime>
 
 #include "base/Profiler.h"
@@ -33,7 +32,7 @@
 void
 SequencerThread::run()
 {
-    SEQUENCER_DEBUG << "SequencerThread::run" << endl;
+    SEQUENCER_DEBUG << "SequencerThread::run()";
 
     RosegardenSequencer &seq = *RosegardenSequencer::getInstance();
 
@@ -52,13 +51,13 @@
 
         bool atLeisure = true;
 
-//        std::cerr << "Sequencer status is " << seq.getStatus() << std::endl;
+        //SEQUENCER_DEBUG << "Sequencer status is " << seq.getStatus();
 
         switch (seq.getStatus()) {
-	    
-	case QUIT:
-	    exiting = true;
-	    break;
+
+        case QUIT:
+            exiting = true;
+            break;
 
         case STARTING_TO_PLAY:
             if (!seq.startPlaying()) {
@@ -108,25 +107,29 @@
                 // Still process these so we can send up
                 // audio levels as MappedEvents
                 //
-                seq.processAsynchronousEvents();
+                // Bug #3542166.  This line can occasionally steal MIDI
+                // events that are needed by processRecordedMidi().
+                // Need to track down what the above "audio levels" comment
+                // means and whether it is a serious issue.  If so, we need
+                // to address it in a different way.  This line probably
+                // never did anything as by the time it was run,
+                // processRecordedMidi() would have cleaned out all the
+                // incoming events.
+                //seq.processAsynchronousEvents();
             }
             break;
 
         case STOPPING:
-            // There's no call to roseSeq to actually process the
+            // There's no call to RosegardenSequencer to actually process the
             // stop, because this arises from a call from the GUI
-            // direct to roseSeq to start with
+            // direct to RosegardenSequencer to start with
             seq.setStatus(STOPPED);
 
-            SEQUENCER_DEBUG << "RosegardenSequencer - Stopped" << endl;
+            SEQUENCER_DEBUG << "SequencerThread::run() - Stopped";
             break;
 
         case RECORDING_ARMED:
-            SEQUENCER_DEBUG << "RosegardenSequencer - "
-			    << "Sequencer can't enter \""
-			    << "RECORDING_ARMED\" state - "
-			    << "internal error"
-			    << endl;
+            SEQUENCER_DEBUG << "SequencerThread::run() - Sequencer can't enter \"RECORDING_ARMED\" state - internal error";
             break;
 
         case STOPPED:
@@ -145,25 +148,26 @@
         seq.updateClocks();
 
         if (lastSeqStatus != seq.getStatus()) {
-            SEQUENCER_DEBUG << "Sequencer status changed from " << lastSeqStatus << " to " << seq.getStatus() << endl;
+            SEQUENCER_DEBUG << "Sequencer status changed from " << lastSeqStatus << " to " << seq.getStatus();
             lastSeqStatus = seq.getStatus();
             atLeisure = false;
         }
 
-	if (timer.elapsed() > 3000) {
-	    seq.checkForNewClients();
-	    timer.restart();
-	}
+        if (timer.elapsed() > 3000) {
+            seq.checkForNewClients();
+            timer.restart();
+        }
 
-	seq.unlock();
+        seq.unlock();
 
-	// permitting synchronised calls from the gui or wherever to
-	// be made now
+        // permitting synchronised calls from the gui or wherever to
+        // be made now
 
-	if (atLeisure)
+        // If the sequencer status hasn't changed, sleep for a bit
+        if (atLeisure)
             seq.sleep(sleepTime);
 
-	seq.lock();
+        seq.lock();
     }
 
     seq.unlock();