stop_me = false;
m_isWorking = false;
shuttlevalue = 0xffff;
- shuttlechange = false;
+ shuttlecounter = 0;
jogvalue = 0xffff;
}
//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)));
}
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++;
}
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)
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:
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.
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);
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);
}
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);
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()));