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

media library: Do not start parsing automatically

parent e6a58b5f
......@@ -26,7 +26,14 @@ class IMediaLibrary
virtual MoviePtr movie( const std::string& title ) = 0;
virtual MoviePtr createMovie( const std::string& title ) = 0;
/**
* @brief addMetadataService Adds a service to parse media
*
* Use is expected to add all services before calling parse for the first time.
* Once parse has been called, adding another service is an undefined behavior
*/
virtual void addMetadataService( IMetadataService* service ) = 0;
virtual void parse( FilePtr file ) = 0;
};
class MediaLibraryFactory
......
......@@ -67,8 +67,6 @@ FilePtr MediaLibrary::addFile( const std::string& path )
auto file = File::create( m_dbConnection, path );
if ( file == nullptr )
return nullptr;
for ( const auto& s : m_mdServices )
s->run( file );
return file;
}
......@@ -145,3 +143,8 @@ void MediaLibrary::addMetadataService(IMetadataService* service)
m_mdServices.push_back( MdsPtr( service ) );
std::push_heap( m_mdServices.begin(), m_mdServices.end(), comp );
}
void MediaLibrary::parse( FilePtr file )
{
assert(false);
}
......@@ -32,6 +32,7 @@ class MediaLibrary : public IMediaLibrary
virtual MoviePtr createMovie( const std::string& title );
virtual void addMetadataService( IMetadataService* service );
virtual void parse( FilePtr file );
private:
std::shared_ptr<sqlite3> m_dbConnection;
std::vector<std::unique_ptr<IMetadataService>> m_mdServices;
......
......@@ -77,6 +77,7 @@ TEST_F( VLCMetadataServices, ParseAudio )
{
std::unique_lock<std::mutex> lock( cb->mutex );
auto file = ml->addFile( "mr-zebra.mp3" );
ml->parse(file);
std::vector<AudioTrackPtr> tracks;
cb->waitCond.wait( lock, [&]{ return file->audioTracks( tracks ) == true && tracks.size() > 0; } );
......@@ -96,6 +97,7 @@ TEST_F( VLCMetadataServices, ParseAlbum )
{
std::unique_lock<std::mutex> lock( cb->mutex );
auto file = ml->addFile( "mr-zebra.mp3" );
ml->parse(file);
bool res = cb->waitCond.wait_for( lock, std::chrono::seconds( 2 ),
[&]{ return file->albumTrack() != nullptr; } );
......
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