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

ParserService: Rework completion detection

This allows us to force re-running a parser service even though it's
marked as completed.
This fixes a crash when re-launching a parsing which completed the
thumbnailer but not the metadata extraction/analysis
parent e2ce1cba
......@@ -480,7 +480,6 @@ bool MetadataParser::link( Media& media, std::shared_ptr<Album> album,
return true;
}
const char* MetadataParser::name() const
{
return "Metadata";
......@@ -496,9 +495,11 @@ uint8_t MetadataParser::nbThreads() const
return 1;
}
File::ParserStep MetadataParser::step() const
bool MetadataParser::isCompleted( const parser::Task& task ) const
{
return File::ParserStep::MetadataAnalysis;
// We always need to run this task if the metadata extraction isn't completed
return ( static_cast<uint8_t>( task.file->parserStep() ) &
static_cast<uint8_t>( File::ParserStep::MetadataAnalysis ) ) != 0;
}
}
......@@ -37,7 +37,7 @@ protected:
virtual parser::Task::Status run( parser::Task& task ) override;
virtual const char* name() const override;
virtual uint8_t nbThreads() const override;
virtual File::ParserStep step() const override;
bool isCompleted( const parser::Task& task ) const override;
bool parseAudioFile(parser::Task& task) const;
bool parseVideoFile(parser::Task& task) const;
......
......@@ -95,9 +95,11 @@ uint8_t VLCMetadataService::nbThreads() const
return 1;
}
File::ParserStep VLCMetadataService::step() const
bool VLCMetadataService::isCompleted( const parser::Task& task ) const
{
return File::ParserStep::MetadataExtraction;
// We always need to run this task if the metadata extraction isn't completed
return ( static_cast<uint8_t>( task.file->parserStep() ) &
static_cast<uint8_t>( File::ParserStep::MetadataAnalysis ) ) != 0;
}
}
......@@ -43,8 +43,7 @@ private:
virtual parser::Task::Status run( parser::Task& task ) override;
virtual const char* name() const override;
virtual uint8_t nbThreads() const override;
virtual File::ParserStep step() const override;
virtual bool isCompleted( const parser::Task& task ) const override;
private:
VLC::Instance m_instance;
......
......@@ -63,9 +63,10 @@ bool VLCThumbnailer::initialize()
return true;
}
File::ParserStep VLCThumbnailer::step() const
bool VLCThumbnailer::isCompleted( const parser::Task& task ) const
{
return File::ParserStep::Thumbnailer;
return ( static_cast<uint8_t>( task.file->parserStep() ) &
static_cast<uint8_t>( File::ParserStep::Thumbnailer ) ) != 0;
}
parser::Task::Status VLCThumbnailer::run( parser::Task& task )
......
......@@ -39,7 +39,7 @@ public:
virtual ~VLCThumbnailer() = default;
virtual parser::Task::Status run( parser::Task& task ) override;
virtual bool initialize() override;
virtual File::ParserStep step() const override;
virtual bool isCompleted( const parser::Task& task ) const override;
private:
parser::Task::Status startPlayback( parser::Task& task, VLC::MediaPlayer& mp );
......
......@@ -144,8 +144,7 @@ void ParserService::mainloop()
task = std::move( m_tasks.front() );
m_tasks.pop();
}
if ( ( static_cast<uint8_t>( task->file->parserStep() ) &
static_cast<uint8_t>( step() ) ) != 0 )
if ( isCompleted( *task ) == true )
{
LOG_INFO( "Skipping completed task [", serviceName, "] on ", task->file->mrl() );
m_parserCb->done( std::move( task ), parser::Task::Status::Success );
......
......@@ -70,7 +70,7 @@ protected:
virtual parser::Task::Status run( parser::Task& task ) = 0;
virtual const char* name() const = 0;
virtual uint8_t nbThreads() const = 0;
virtual File::ParserStep step() const = 0;
virtual bool isCompleted( const parser::Task& task ) const = 0;
private:
// Thread(s) entry point
......
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