fix webcam capture sometimes not working

parent 796e168e
......@@ -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()
......
......@@ -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:
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment