Commit 372863b9 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Import: Handle errors in case libvlc send us the appropriate event.

parent 80224804
......@@ -98,6 +98,9 @@ ImportController::ImportController(QWidget *parent) :
m_mediaListController, SLOT( clipAdded( Clip* ) ) ); //StackViewController
connect( m_stackNav, SIGNAL( previousButtonPushed() ),
this, SLOT( restoreContext() ) );
connect( MetaDataManager::getInstance(), SIGNAL( failedToCompute( Media* ) ),
this, SLOT( failedToLoad( Media* ) ) );
}
ImportController::~ImportController()
......@@ -443,3 +446,9 @@ ImportController::mediaLoaded()
}
}
void
ImportController::failedToLoad( Media *media )
{
mediaDeletion( media->getUuid() );
}
......@@ -102,6 +102,7 @@ class ImportController : public QDialog
void treeViewClicked( const QModelIndex& index );
void treeViewDoubleClicked( const QModelIndex& index );
void mediaLoaded();
void failedToLoad( Media* media );
signals:
void mediaSelected( Media* );
......
......@@ -119,6 +119,7 @@ void MediaPlayer::callbacks( const libvlc_event_t* ev
case libvlc_MediaPlayerEncounteredError:
qDebug() << "libvlc_MediaPlayerEncounteredError received."
<< "This is not looking good...";
self->emit errorEncountered();
break ;
case libvlc_MediaPlayerSeekableChanged:
case libvlc_MediaPlayerPausableChanged:
......
......@@ -80,6 +80,7 @@ namespace LibVLCpp
void endReached();
void positionChanged( float );
void lengthChanged( qint64 );
void errorEncountered();
};
}
......
......@@ -49,6 +49,9 @@ void MetaDataManager::launchComputing( Media *media )
connect( worker, SIGNAL( computed() ),
this, SLOT( computingCompleted() ),
Qt::DirectConnection );
connect( worker, SIGNAL( failed( Media* ) ),
this, SLOT( computingFailed( Media* ) ),
Qt::DirectConnection );
worker->compute();
}
......@@ -64,7 +67,15 @@ void MetaDataManager::computingCompleted()
launchComputing( m_mediaToCompute.dequeue() );
}
void MetaDataManager::computeMediaMetadata( Media *media )
void
MetaDataManager::computingFailed( Media* media )
{
emit failedToCompute( media );
computingCompleted();
}
void
MetaDataManager::computeMediaMetadata( Media *media )
{
QMutexLocker lock( m_computingMutex );
......
......@@ -56,6 +56,10 @@ class MetaDataManager : public QObject, public Singleton<MetaDataManager>
private slots:
void computingCompleted();
void computingFailed( Media* media );
signals:
void failedToCompute( Media* );
};
#endif //METADATAMANAGER_H
......@@ -63,6 +63,7 @@ MetaDataWorker::compute()
m_mediaPlayer->setMedia( m_media->getVLCMedia() );
connect( m_mediaPlayer, SIGNAL( playing() ),
this, SLOT( entrypointPlaying() ), Qt::QueuedConnection );
connect( m_mediaPlayer, SIGNAL( errorEncountered() ), this, SLOT( failure() ) );
m_mediaPlayer->play();
m_media->flushVolatileParameters();
}
......@@ -285,3 +286,10 @@ MetaDataWorker::addAudioValue( int value )
{
m_media->getAudioValues()->append( value );
}
void
MetaDataWorker::failure()
{
emit failed( m_media );
deleteLater();
}
......@@ -73,9 +73,11 @@ class MetaDataWorker : public QObject
void entrypointPlaying();
void entrypointLengthChanged( qint64 );
void generateAudioSpectrum();
void failure();
signals:
void computed();
void failed( Media* media );
};
#endif // METADATAWORKER_H
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