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

ParserService: Allow ParserService to know the name/type of the underlying service

parent 0f9b4324
......@@ -86,6 +86,11 @@ parser::Task::Status VLCMetadataService::run( parser::Task& task )
return status;
}
const char* VLCMetadataService::name() const
{
return "VLC";
}
parser::Task::Status VLCMetadataService::handleMediaMeta( std::shared_ptr<Media> media, std::shared_ptr<File> file, VLC::Media& vlcMedia ) const
{
const auto tracks = vlcMedia.tracks();
......
......@@ -49,6 +49,7 @@ class VLCMetadataService : public ParserService
virtual bool initialize() override;
virtual parser::Task::Status run( parser::Task& task ) override;
virtual const char* name() const override;
private:
parser::Task::Status handleMediaMeta(std::shared_ptr<Media> media , std::shared_ptr<File> file, VLC::Media &vlcMedia ) const;
......
......@@ -359,3 +359,8 @@ parser::Task::Status VLCThumbnailer::compress( std::shared_ptr<Media> media, std
return parser::Task::Status::Error;
return parser::Task::Status::Success;
}
const char*VLCThumbnailer::name() const
{
return "Thumbnailer";
}
......@@ -57,6 +57,8 @@ private:
parser::Task::Status takeThumbnail( std::shared_ptr<Media> media, std::shared_ptr<File> file, VLC::MediaPlayer &mp );
parser::Task::Status compress( std::shared_ptr<Media> media, std::shared_ptr<File> file );
virtual const char* name() const;
private:
// Force a base width, let height be computed depending on A/R
static const uint32_t DesiredWidth = 320;
......
......@@ -90,7 +90,11 @@ bool ParserService::initialize()
void ParserService::mainloop()
{
LOG_INFO("Entering ParserService thread");
// It would be unsafe to call name() at the end of this function, since
// we might stop the thread during ParserService destruction. This implies
// that the underlying service has been deleted already.
std::string serviceName = name();
LOG_INFO("Entering ParserService [", serviceName, "] thread");
while ( m_stopParser == false )
{
......@@ -122,6 +126,6 @@ void ParserService::mainloop()
m_parserCb->done( std::move( task ), parser::Task::Status::Fatal );
}
}
LOG_INFO("Exiting Parser thread");
LOG_INFO("Exiting ParserService [", serviceName, "] thread");
}
......@@ -50,6 +50,7 @@ protected:
/// Can be overriden to run service dependent initializations
virtual bool initialize();
virtual parser::Task::Status run( parser::Task& task ) = 0;
virtual const char* name() 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