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

Thumbnailer: Reduce the amount of shared_ptr copies

parent bba19da1
...@@ -70,14 +70,14 @@ File::ParserStep VLCThumbnailer::step() const ...@@ -70,14 +70,14 @@ File::ParserStep VLCThumbnailer::step() const
parser::Task::Status VLCThumbnailer::run( parser::Task& task ) parser::Task::Status VLCThumbnailer::run( parser::Task& task )
{ {
auto media = task.media; auto media = task.media.get();
auto file = task.file; auto file = task.file.get();
if ( media->type() == IMedia::Type::Audio ) if ( media->type() == IMedia::Type::Audio )
{ {
// There's no point in generating a thumbnail for a non-video media. // There's no point in generating a thumbnail for a non-video media.
task.file->markStepCompleted( File::ParserStep::Thumbnailer ); file->markStepCompleted( File::ParserStep::Thumbnailer );
task.file->saveParserStep(); file->saveParserStep();
return parser::Task::Status::Success; return parser::Task::Status::Success;
} }
...@@ -112,10 +112,10 @@ parser::Task::Status VLCThumbnailer::run( parser::Task& task ) ...@@ -112,10 +112,10 @@ parser::Task::Status VLCThumbnailer::run( parser::Task& task )
if ( res != parser::Task::Status::Success ) if ( res != parser::Task::Status::Success )
{ {
// If the media became an audio file, it's not an error // If the media became an audio file, it's not an error
if ( task.media->type() == Media::Type::Audio ) if ( media->type() == Media::Type::Audio )
{ {
task.file->markStepCompleted( File::ParserStep::Thumbnailer ); file->markStepCompleted( File::ParserStep::Thumbnailer );
task.file->saveParserStep(); file->saveParserStep();
LOG_INFO( file->mrl(), " type has changed to Audio. Skipping thumbnail generation" ); LOG_INFO( file->mrl(), " type has changed to Audio. Skipping thumbnail generation" );
return parser::Task::Status::Success; return parser::Task::Status::Success;
} }
...@@ -137,8 +137,9 @@ parser::Task::Status VLCThumbnailer::run( parser::Task& task ) ...@@ -137,8 +137,9 @@ parser::Task::Status VLCThumbnailer::run( parser::Task& task )
res = takeThumbnail( media, file, mp ); res = takeThumbnail( media, file, mp );
if ( res != parser::Task::Status::Success ) if ( res != parser::Task::Status::Success )
return res; return res;
task.file->markStepCompleted( File::ParserStep::Thumbnailer ); file->markStepCompleted( File::ParserStep::Thumbnailer );
task.file->saveParserStep(); file->saveParserStep();
m_notifier->notifyMediaModification( task.media );
return parser::Task::Status::Success; return parser::Task::Status::Success;
} }
...@@ -261,7 +262,7 @@ void VLCThumbnailer::setupVout( VLC::MediaPlayer& mp ) ...@@ -261,7 +262,7 @@ void VLCThumbnailer::setupVout( VLC::MediaPlayer& mp )
); );
} }
parser::Task::Status VLCThumbnailer::takeThumbnail( std::shared_ptr<Media> media, std::shared_ptr<File> file, VLC::MediaPlayer &mp ) parser::Task::Status VLCThumbnailer::takeThumbnail( Media* media, File* file, VLC::MediaPlayer &mp )
{ {
// lock, signal that we want a thumbnail, and wait. // lock, signal that we want a thumbnail, and wait.
{ {
...@@ -281,7 +282,7 @@ parser::Task::Status VLCThumbnailer::takeThumbnail( std::shared_ptr<Media> media ...@@ -281,7 +282,7 @@ parser::Task::Status VLCThumbnailer::takeThumbnail( std::shared_ptr<Media> media
return compress( media, file ); return compress( media, file );
} }
parser::Task::Status VLCThumbnailer::compress( std::shared_ptr<Media> media, std::shared_ptr<File> file ) parser::Task::Status VLCThumbnailer::compress( Media* media, File* file )
{ {
auto path = m_ml->thumbnailPath(); auto path = m_ml->thumbnailPath();
path += "/"; path += "/";
...@@ -303,7 +304,6 @@ parser::Task::Status VLCThumbnailer::compress( std::shared_ptr<Media> media, std ...@@ -303,7 +304,6 @@ parser::Task::Status VLCThumbnailer::compress( std::shared_ptr<Media> media, std
if ( file->saveParserStep() == false ) if ( file->saveParserStep() == false )
return parser::Task::Status::Fatal; return parser::Task::Status::Fatal;
t->commit(); t->commit();
m_notifier->notifyMediaModification( media );
return parser::Task::Status::Success; return parser::Task::Status::Success;
} }
......
...@@ -45,8 +45,8 @@ private: ...@@ -45,8 +45,8 @@ private:
parser::Task::Status startPlayback( parser::Task& task, VLC::MediaPlayer& mp ); parser::Task::Status startPlayback( parser::Task& task, VLC::MediaPlayer& mp );
parser::Task::Status seekAhead( VLC::MediaPlayer &mp ); parser::Task::Status seekAhead( VLC::MediaPlayer &mp );
void setupVout( VLC::MediaPlayer &mp ); void setupVout( VLC::MediaPlayer &mp );
parser::Task::Status takeThumbnail( std::shared_ptr<Media> media, std::shared_ptr<File> file, VLC::MediaPlayer &mp ); parser::Task::Status takeThumbnail( Media* media, File* file, VLC::MediaPlayer &mp );
parser::Task::Status compress( std::shared_ptr<Media> media, std::shared_ptr<File> file ); parser::Task::Status compress( Media* media, File* file );
virtual const char* name() const override; virtual const char* name() const override;
virtual uint8_t nbThreads() const override; virtual uint8_t nbThreads() const override;
......
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