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