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

IMediaLibraryCb: Expose discover/restore related callback methods

parent 9ba0ea93
......@@ -17,6 +17,15 @@ public:
* @param file The updated file.
*/
virtual void onMetadataUpdated( FilePtr file ) = 0;
virtual void onDiscoveryStarted( const std::string& entryPoint ) = 0;
/**
* @brief onFileAdded This will be called for each new file discovered
* or restored when reloading the media library.
* @param file
*/
virtual void onFileAdded( FilePtr file ) = 0;
virtual void onDiscoveryCompleted( const std::string& entryPoint ) = 0;
};
class IMediaLibrary
......
......@@ -220,10 +220,15 @@ void MediaLibrary::discover( const std::string &entryPoint )
std::thread t([this, entryPoint] {
//FIXME: This will crash if the media library gets deleted while we
//are discovering.
if ( m_callback != nullptr )
m_callback->onDiscoveryStarted( entryPoint );
for ( auto& d : m_discoverers )
d->discover( entryPoint );
}
);
if ( m_callback != nullptr )
m_callback->onDiscoveryCompleted( entryPoint );
});
t.detach();
}
......@@ -361,6 +366,10 @@ FilePtr MediaLibrary::addFile( const fs::IFile* file, unsigned int folderId )
std::cerr << "Failed to add file " << file->fullPath() << " to the media library" << std::endl;
return nullptr;
}
// Keep in mind that this is queued by the parser thread, there is no waranty about
// when the metadata will be available
if ( m_callback != nullptr )
m_callback->onFileAdded( fptr );
m_parser->parse( fptr, m_callback );
return fptr;
}
......
......@@ -20,6 +20,11 @@ class ServiceCb : public IMediaLibraryCb
{
waitCond.notify_all();
}
// IMediaLibraryCb interface
virtual void onDiscoveryStarted( const std::string& ) override {}
virtual void onFileAdded( FilePtr ) override {}
virtual void onDiscoveryCompleted( const std::string& ) override {}
};
class VLCMetadataServices : public Tests
......
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