Commit 349b20ca authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

MediaLibrary: Store the VLC instance as a member variable

parent 362e90b8
......@@ -83,8 +83,8 @@ bool MediaLibrary::initialize( const std::string& dbPath, const std::string& sna
"-vv",
"--vout=dummy",
};
VLC::Instance vlcInstance( sizeof(args) / sizeof(args[0]), args );
vlcInstance.logSet([](int lvl, const libvlc_log_t*, std::string msg) {
m_vlcInstance = VLC::Instance( sizeof(args) / sizeof(args[0]), args );
m_vlcInstance.logSet([](int lvl, const libvlc_log_t*, std::string msg) {
if ( lvl == LIBVLC_ERROR )
Log::Error( msg );
else if ( lvl == LIBVLC_WARNING )
......@@ -93,8 +93,8 @@ bool MediaLibrary::initialize( const std::string& dbPath, const std::string& sna
Log::Info( msg );
});
auto vlcService = std::unique_ptr<VLCMetadataService>( new VLCMetadataService( vlcInstance ) );
auto thumbnailerService = std::unique_ptr<VLCThumbnailer>( new VLCThumbnailer( vlcInstance ) );
auto vlcService = std::unique_ptr<VLCMetadataService>( new VLCMetadataService( m_vlcInstance ) );
auto thumbnailerService = std::unique_ptr<VLCThumbnailer>( new VLCThumbnailer( m_vlcInstance ) );
addMetadataService( std::move( vlcService ) );
addMetadataService( std::move( thumbnailerService ) );
}
......
......@@ -8,6 +8,7 @@ class Parser;
#include "IMediaLibrary.h"
#include "IDiscoverer.h"
#include "logging/Logger.h"
#include "vlcpp/vlc.hpp"
class MediaLibrary : public IMediaLibrary, public IDiscovererCb
{
......@@ -67,6 +68,10 @@ class MediaLibrary : public IMediaLibrary, public IDiscovererCb
std::string m_snapshotPath;
IMediaLibraryCb* m_callback;
// This probably qualifies as a work around, but we need to keep the VLC::Instance
// alive to be able to use the logging wrapper lambda
VLC::Instance m_vlcInstance;
// Keep the parser as last field.
// The parser holds a (raw) pointer to the media library. When MediaLibrary's destructor gets called
// it might still finish a few operations before exiting the parser thread. Those operations are
......
Supports Markdown
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