Commit 967bfbd5 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

MetaDataWorker: Delegate the snapshot handling to the GuiMedia.

This allows to remove dirty haks such as "emitSnapshotComputed"
Also, it breaks image snapshot computing for now.
parent 174c5699
......@@ -30,6 +30,22 @@ GUIMedia::GUIMedia() :
{
}
void GUIMedia::snapshotReady(const char *fileName)
{
QFile tmp( fileName );
QPixmap* pixmap = new QPixmap( fileName );
if ( pixmap->isNull() )
delete pixmap;
else
{
setSnapshot( pixmap );
emit snapshotComputed( qobject_cast<const Media*>( this ) );
}
tmp.remove();
}
GUIMedia::~GUIMedia()
{
if ( m_snapshot )
......@@ -59,9 +75,3 @@ GUIMedia::hasSnapshot() const
{
return ( m_snapshot != NULL );
}
void
GUIMedia::emitSnapshotComputed()
{
emit snapshotComputed( qobject_cast<const Media*>( this ) );
}
......@@ -38,7 +38,6 @@ public:
void setSnapshot( QPixmap* snapshot );
const QPixmap &snapshot() const;
bool hasSnapshot() const;
void emitSnapshotComputed();
protected:
//A GUIMedia shouldn't be constructed by something else than a media
......@@ -48,6 +47,9 @@ protected:
QPixmap* m_snapshot;
public slots:
void snapshotReady( const char *fileName );
signals:
void snapshotComputed( const Media* );
};
......
......@@ -43,6 +43,7 @@ MetaDataWorker::MetaDataWorker( LibVLCpp::MediaPlayer* mediaPlayer, Media* media
m_media( media ),
m_audioBuffer( NULL )
{
connect( this, SIGNAL( finished() ), this, SLOT( deleteLater() ) );
}
MetaDataWorker::~MetaDataWorker()
......@@ -138,9 +139,9 @@ MetaDataWorker::metaDataAvailable()
}
else if ( m_media->fileType() == Media::Image && m_media->hasSnapshot() == false )
{
QPixmap *pixmap = new QPixmap( m_media->fileInfo()->absoluteFilePath() );
m_media->setSnapshot( pixmap );
m_media->emitSnapshotComputed();
// QPixmap *pixmap = new QPixmap( m_media->fileInfo()->absoluteFilePath() );
// m_media->setSnapshot( pixmap );
// m_media->emitSnapshotComputed();
}
#endif
finalize();
......@@ -175,10 +176,12 @@ MetaDataWorker::computeSnapshot()
tmp.setAutoRemove( false );
// Although this function is synchrone, we have to be in the main thread to
// handle a QPixmap
// handle a QPixmap, hence the QueuedConnection
connect( m_mediaPlayer, SIGNAL( snapshotTaken( const char* ) ),
this, SLOT( renderSnapshot( const char* ) ) );
m_media, SLOT( snapshotReady( const char* ) ),
Qt::QueuedConnection );
m_mediaPlayer->takeSnapshot( tmp.fileName().toUtf8().constData(), 0, 0 );
finalize();
}
#endif
......@@ -186,7 +189,6 @@ void
MetaDataWorker::finalize()
{
emit computed();
deleteLater();
}
void
......@@ -196,21 +198,6 @@ MetaDataWorker::failure()
deleteLater();
}
void MetaDataWorker::renderSnapshot(const char* filename)
{
QFile tmp( filename );
QPixmap* pixmap = new QPixmap( filename );
if ( pixmap->isNull() )
delete pixmap;
else
m_media->setSnapshot( pixmap );
m_media->emitSnapshotComputed();
tmp.remove();
finalize();
}
//void
//MetaDataWorker::prepareAudioSpectrumComputing()
//{
......
......@@ -74,7 +74,6 @@ class MetaDataWorker : public QThread
private slots:
// void generateAudioSpectrum();
void failure();
void renderSnapshot(const char *filename);
signals:
void computed();
......
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