aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <[email protected]>2015-02-24 07:25:27 +0100
committerJean-Baptiste Mardelle <[email protected]>2015-02-24 07:29:02 +0100
commit1d60b732cb5a4592020d59cdc79c79ca85125d01 (patch)
treeede13f43c81761877e409d237a1d81d0340b8d24
parent796e168edae58de2d120a0117c32fdff15fd392f (diff)
fix webcam capture sometimes not workingnext
-rw-r--r--src/capture/mltdevicecapture.cpp14
-rw-r--r--src/capture/mltdevicecapture.h5
-rw-r--r--src/monitor/recmonitor.cpp9
3 files changed, 21 insertions, 7 deletions
diff --git a/src/capture/mltdevicecapture.cpp b/src/capture/mltdevicecapture.cpp
index 4f052f6..6f2f101 100644
--- a/src/capture/mltdevicecapture.cpp
+++ b/src/capture/mltdevicecapture.cpp
@@ -93,7 +93,7 @@ MltDeviceCapture::~MltDeviceCapture()
if (m_mltProfile) delete m_mltProfile;
}
-void MltDeviceCapture::buildConsumer(const QString &profileName)
+bool MltDeviceCapture::buildConsumer(const QString &profileName)
{
if (!profileName.isEmpty()) m_activeProfile = profileName;
@@ -148,6 +148,12 @@ void MltDeviceCapture::buildConsumer(const QString &profileName)
//m_mltConsumer->set("progressive", 0);
//m_mltConsumer->set("buffer", 1);
//m_mltConsumer->set("real_time", 0);
+ if (!m_mltConsumer->is_valid()) {
+ delete m_mltConsumer;
+ m_mltConsumer = NULL;
+ return false;
+ }
+ return true;
}
void MltDeviceCapture::pause()
@@ -278,7 +284,7 @@ void MltDeviceCapture::showAudio(Mlt::Frame& frame)
bool MltDeviceCapture::slotStartPreview(const QString &producer, bool xmlFormat)
{
if (m_mltConsumer == NULL) {
- buildConsumer();
+ if (!buildConsumer()) return false;
}
char *tmp = qstrdup(producer.toUtf8().constData());
if (xmlFormat) m_mltProducer = new Mlt::Producer(*m_mltProfile, "xml-string", tmp);
@@ -297,11 +303,11 @@ bool MltDeviceCapture::slotStartPreview(const QString &producer, bool xmlFormat)
if (m_mltConsumer->start() == -1) {
delete m_mltConsumer;
m_mltConsumer = NULL;
- return 0;
+ return false;
}
m_droppedFramesTimer.start();
//connect(this, SIGNAL(imageReady(QImage)), this, SIGNAL(frameUpdated(QImage)));
- return 1;
+ return true;
}
void MltDeviceCapture::slotCheckDroppedFrames()
diff --git a/src/capture/mltdevicecapture.h b/src/capture/mltdevicecapture.h
index e7058a7..074aedc 100644
--- a/src/capture/mltdevicecapture.h
+++ b/src/capture/mltdevicecapture.h
@@ -124,8 +124,9 @@ private:
QMutex m_mutex;
/** @brief Build the MLT Consumer object with initial settings.
- * @param profileName The MLT profile to use for the consumer */
- void buildConsumer(const QString &profileName = QString());
+ * @param profileName The MLT profile to use for the consumer
+ * @returns true if consumer is valid */
+ bool buildConsumer(const QString &profileName = QString());
private slots:
diff --git a/src/monitor/recmonitor.cpp b/src/monitor/recmonitor.cpp
index 3c4c2a5..9197529 100644
--- a/src/monitor/recmonitor.cpp
+++ b/src/monitor/recmonitor.cpp
@@ -483,7 +483,13 @@ void RecMonitor::slotStartPreview(bool play)
QStringList dvargs = KdenliveSettings::dvgrabextra().simplified().split(' ', QString::SkipEmptyParts);
int ix = device_selector->currentIndex();
bool isXml;
- videoBox->setHidden(ix != Video4Linux && ix != BlackMagic && ix != Firewire);
+ if (ix != Video4Linux && ix != BlackMagic && ix != Firewire) {
+ // no need for sdl preview
+ videoBox->setHidden(true);
+ } else {
+ videoBox->setHidden(false);
+ videoBox->show();
+ }
switch (ix) {
case Firewire:
switch (KdenliveSettings::firewireformat()) {
@@ -1044,6 +1050,7 @@ void RecMonitor::buildMltDevice(const QString &path)
m_captureDevice->sendFrameForAnalysis = m_analyse;
m_monitorManager->updateScopeSource();
}
+ videoSurface->show();
}
void RecMonitor::slotChangeRecordingPreview(bool enable)