]> git.sesse.net Git - kdenlive/commitdiff
Merge remote-tracking branch 'origin/master' into bugfix/jogshuttle
authorEd Rogalsky <ed.rogalsky@googlemail.com>
Tue, 20 Nov 2012 09:40:20 +0000 (10:40 +0100)
committerEd Rogalsky <ed.rogalsky@googlemail.com>
Tue, 20 Nov 2012 09:40:20 +0000 (10:40 +0100)
1  2 
src/jogshuttle.cpp
src/jogshuttle.h
src/kdenlivesettingsdialog.cpp
src/mainwindow.cpp

diff --combined src/jogshuttle.cpp
index 1cde287f80e4e780c2ed27bb9f49195736a986ad,16fd171f4d0e17ce80a982a84c1647716de610db..f9049511dceefcc568ecf037e33c2fdec5b3ea0c
@@@ -73,7 -73,7 +73,7 @@@ void ShuttleThread::init(QObject *paren
      stop_me = false;
      m_isWorking = false;
      shuttlevalue = 0xffff;
-     shuttlechange = false;
+     shuttlecounter = 0;
      jogvalue = 0xffff;
  }
  
@@@ -149,15 -149,17 +149,17 @@@ void ShuttleThread::shuttle(int value
      //gettimeofday( &last_shuttle, 0 );
      //need_synthetic_shuttle = value != 0;
  
-     if (value == shuttlevalue)
+     if (value == shuttlevalue) {
+       shuttlecounter = 1;
          return;
+     }
  
      if (value > MAX_SHUTTLE_RANGE || value < -MAX_SHUTTLE_RANGE) {
          fprintf(stderr, "Jog Shuttle returned value of %d (should be between -%d ad +%d)", value, MAX_SHUTTLE_RANGE, MAX_SHUTTLE_RANGE);
          return;
      }
      shuttlevalue = value;
-     shuttlechange = true;
+     shuttlecounter = 1;
      QApplication::postEvent(m_parent, new QEvent((QEvent::Type) (JOG_STOP + value)));
  }
  
@@@ -184,14 -186,16 +186,16 @@@ void ShuttleThread::jog(unsigned int va
              QApplication::postEvent(m_parent, new QEvent((QEvent::Type) JOG_BACK1));
          else if ((forward && !wrap) || (rewind && wrap))
              QApplication::postEvent(m_parent, new QEvent((QEvent::Type) JOG_FWD1));
-         else if (!forward && !rewind && !shuttlechange)
+         else if (!forward && !rewind && shuttlecounter > 2) {
              // An event without changing the jog value is sent after each shuttle change.
              // As the shuttle rest position does not get a shuttle event, only a non-position-changing jog event.
              // Hence we stop on this when we see 2 non-position-changing jog events in a row.
+           shuttlecounter = 0;
              QApplication::postEvent(m_parent, new QEvent((QEvent::Type) JOG_STOP));
+       }
      }
      jogvalue = value;
-     shuttlechange = false;
+     if (shuttlecounter > 0) shuttlecounter++;
  }
  
  
@@@ -203,7 -207,7 +207,7 @@@ JogShuttle::JogShuttle(QString device, 
  
  JogShuttle::~JogShuttle()
  {
 -    if (m_shuttleProcess.isRunning()) m_shuttleProcess.exit();
 +      stopDevice();
  }
  
  void JogShuttle::initDevice(QString device)
  
  void JogShuttle::stopDevice()
  {
 -    if (m_shuttleProcess.isRunning())
 +    if (m_shuttleProcess.isRunning()) {
 +      /* the read fd is in blocking mode => stop_me is broken at the moment */
          m_shuttleProcess.stop_me = true;
 +        m_shuttleProcess.exit();
 +        /* give the thread some time to shutdown */
 +        m_shuttleProcess.wait(100);
 +
 +        /* if still running - do it in the hardcore way */
 +        if (m_shuttleProcess.isRunning()) {
 +              m_shuttleProcess.terminate();
 +            kDebug() << "/// terminate jogshuttle process\n";
 +        }
 +    }
  }
  
  void JogShuttle::customEvent(QEvent* e)
diff --combined src/jogshuttle.h
index f2523cc93c56ec6e20a38092ac050258541a8aa7,34673fa65348c697c1b622ae749606273a1c8f64..9a6ecc0287c5dbb01483b724f49c492e6dc411c7
@@@ -37,10 -37,10 +37,10 @@@ public
      void init(QObject *parent, QString device);
      QObject *m_parent;
      int shuttlevalue;
-     bool shuttlechange;
+     int shuttlecounter;
      unsigned short jogvalue;
      bool isWorking();
 -    bool stop_me;
 +    volatile bool stop_me;
      QString m_device;
  
  private:
index adb12e5848c5cd0f8c96addef90f06325d32073b,58d713769f8bd6de11b58c5d3b02a74cd44f2e7a..c42b1d7946d8a51e13ef2ccd23df9c30822f2155
@@@ -137,22 -137,11 +137,22 @@@ KdenliveSettingsDialog::KdenliveSetting
      m_configShuttle.shuttledisabled->hide();
  
      // Store the button pointers into an array for easier handling them in the other functions.
 +    // TODO: impl enumerator or live with cut and paste :-)))
      m_shuttle_buttons.push_back(m_configShuttle.shuttle1);
      m_shuttle_buttons.push_back(m_configShuttle.shuttle2);
      m_shuttle_buttons.push_back(m_configShuttle.shuttle3);
      m_shuttle_buttons.push_back(m_configShuttle.shuttle4);
      m_shuttle_buttons.push_back(m_configShuttle.shuttle5);
 +    m_shuttle_buttons.push_back(m_configShuttle.shuttle6);
 +    m_shuttle_buttons.push_back(m_configShuttle.shuttle7);
 +    m_shuttle_buttons.push_back(m_configShuttle.shuttle8);
 +    m_shuttle_buttons.push_back(m_configShuttle.shuttle9);
 +    m_shuttle_buttons.push_back(m_configShuttle.shuttle10);
 +    m_shuttle_buttons.push_back(m_configShuttle.shuttle11);
 +    m_shuttle_buttons.push_back(m_configShuttle.shuttle12);
 +    m_shuttle_buttons.push_back(m_configShuttle.shuttle13);
 +    m_shuttle_buttons.push_back(m_configShuttle.shuttle14);
 +    m_shuttle_buttons.push_back(m_configShuttle.shuttle15);
  
      // populate the buttons with the current configuration. The items are sorted
      // according to the user-selected language, so they do not appear in random order.
@@@ -544,7 -533,7 +544,7 @@@ void KdenliveSettingsDialog::slotCheckS
          int fd;
          for (int i = 0; i < 30; i++) {
              QString filename = baseName + QString::number(i);
-             kDebug() << "/// CHECKING OFR: " << filename;
+             kDebug() << "/// CHECKING device: " << filename;
  
              char name[256] = "unknown";
              fd = KDE_open((char *) filename.toUtf8().data(), O_RDONLY);
diff --combined src/mainwindow.cpp
index ee580bce7cf228ec777431a6f187fccbb0048ccb,f22a0e4412349016d55a043ffa039f8083b019eb..f9d5900be0d2a9cd872b9d3974acde4ae8144caf
@@@ -676,12 -676,6 +676,12 @@@ MainWindow::~MainWindow(
      if (m_stopmotion) {
          delete m_stopmotion;
      }
 +
 +#ifdef USE_JOGSHUTTLE
 +    if (m_jogProcess)
 +      delete m_jogProcess;
 +#endif
 +
      m_effectStack->slotClipItemSelected(NULL);
      m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
  
@@@ -2193,7 -2187,6 +2193,6 @@@ void MainWindow::doOpenFile(const KUrl 
      }
      m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
      trackView->setDuration(trackView->duration());
-     trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
  
      if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
      slotGotProgressInfo(QString(), -1);
@@@ -2583,7 -2576,7 +2582,7 @@@ void MainWindow::connectDocument(TrackV
      connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
  
      connect(trackView->projectView(), SIGNAL(importKeyframes(GRAPHICSRECTITEM, const QString&, int)), this, SLOT(slotProcessImportKeyframes(GRAPHICSRECTITEM, const QString&, int)));
-     
      connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
      connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
      connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));