Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
4f57a49b
Commit
4f57a49b
authored
Oct 22, 2015
by
Hugo Beauzée-Luyssen
Browse files
Parser: Require the ML callback to be passed during initialization
parent
08eea9cc
Changes
3
Show whitespace changes
Inline
Side-by-side
src/MediaLibrary.cpp
View file @
4f57a49b
...
...
@@ -114,7 +114,7 @@ bool MediaLibrary::initialize( const std::string& dbPath, const std::string& sna
m_snapshotPath
=
snapshotPath
;
m_callback
=
mlCallback
;
m_dbConnection
.
reset
(
new
SqliteConnection
(
dbPath
)
);
m_parser
.
reset
(
new
Parser
(
m_dbConnection
.
get
()
)
);
m_parser
.
reset
(
new
Parser
(
m_dbConnection
.
get
()
,
m_callback
)
);
if
(
mlCallback
!=
nullptr
)
...
...
@@ -217,7 +217,7 @@ std::shared_ptr<Media> MediaLibrary::addFile( const std::string& path, FolderPtr
}
if
(
m_callback
!=
nullptr
)
m_callback
->
onFileAdded
(
fptr
);
m_parser
->
parse
(
fptr
,
m_callback
);
m_parser
->
parse
(
fptr
);
return
fptr
;
}
...
...
src/Parser.cpp
View file @
4f57a49b
...
...
@@ -26,10 +26,11 @@
#include "IMedia.h"
Parser
::
Parser
(
DBConnection
dbConnection
)
Parser
::
Parser
(
DBConnection
dbConnection
,
IMediaLibraryCb
*
cb
)
:
m_thread
(
&
Parser
::
run
,
this
)
,
m_stopParser
(
false
)
,
m_dbConnection
(
dbConnection
)
,
m_callback
(
cb
)
{
}
...
...
@@ -105,8 +106,7 @@ void Parser::restore()
for
(
auto
&
it
:
media
)
{
auto
m
=
std
::
static_pointer_cast
<
Media
>
(
it
);
//FIXME: No callback here
m_tasks
.
push
(
new
Task
(
m
,
m_services
,
nullptr
)
);
m_tasks
.
push
(
new
Task
(
m
,
m_services
,
m_callback
)
);
}
}
...
...
src/Parser.h
View file @
4f57a49b
...
...
@@ -36,10 +36,10 @@
class
Parser
:
public
IMetadataServiceCb
{
public:
Parser
(
DBConnection
dbConnection
);
Parser
(
DBConnection
dbConnection
,
IMediaLibraryCb
*
cb
);
~
Parser
();
void
addService
(
std
::
unique_ptr
<
IMetadataService
>
service
);
void
parse
(
std
::
shared_ptr
<
Media
>
file
,
IMediaLibraryCb
*
cb
);
void
parse
(
std
::
shared_ptr
<
Media
>
file
);
private:
virtual
void
done
(
std
::
shared_ptr
<
Media
>
file
,
IMetadataService
::
Status
status
,
void
*
data
)
override
;
...
...
@@ -67,6 +67,7 @@ class Parser : public IMetadataServiceCb
std
::
condition_variable
m_cond
;
std
::
atomic_bool
m_stopParser
;
DBConnection
m_dbConnection
;
IMediaLibraryCb
*
m_callback
;
};
#endif // PARSER_H
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment