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
7d62c062
Commit
7d62c062
authored
Oct 06, 2015
by
Hugo Beauzée-Luyssen
Browse files
MediaLibrary: Explicitely stop the discoverer worker
parent
30140738
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/MediaLibrary.cpp
View file @
7d62c062
...
...
@@ -63,6 +63,8 @@ MediaLibrary::~MediaLibrary()
// not be called anymore.
if
(
m_vlcInstance
.
isValid
()
)
m_vlcInstance
.
logUnset
();
// Explicitely stop the discoverer, to avoid it writting while tearing down.
m_discoverer
->
stop
();
File
::
clear
();
Folder
::
clear
();
Label
::
clear
();
...
...
src/discoverer/DiscovererWorker.cpp
View file @
7d62c062
...
...
@@ -9,14 +9,7 @@ DiscovererWorker::DiscovererWorker()
DiscovererWorker
::~
DiscovererWorker
()
{
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_mutex
);
while
(
m_entryPoints
.
empty
()
==
false
)
m_entryPoints
.
pop
();
m_run
=
false
;
}
m_cond
.
notify_all
();
m_thread
.
join
();
stop
();
}
void
DiscovererWorker
::
addDiscoverer
(
std
::
unique_ptr
<
IDiscoverer
>
discoverer
)
...
...
@@ -29,6 +22,21 @@ void DiscovererWorker::setCallback(IMediaLibraryCb* cb)
m_cb
=
cb
;
}
void
DiscovererWorker
::
stop
()
{
bool
running
=
true
;
if
(
m_run
.
compare_exchange_strong
(
running
,
false
)
)
{
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_mutex
);
while
(
m_entryPoints
.
empty
()
==
false
)
m_entryPoints
.
pop
();
}
m_cond
.
notify_all
();
m_thread
.
join
();
}
}
bool
DiscovererWorker
::
discover
(
const
std
::
string
&
entryPoint
)
{
if
(
entryPoint
.
length
()
==
0
)
...
...
src/discoverer/DiscovererWorker.h
View file @
7d62c062
...
...
@@ -18,6 +18,7 @@ public:
virtual
~
DiscovererWorker
();
void
addDiscoverer
(
std
::
unique_ptr
<
IDiscoverer
>
discoverer
);
void
setCallback
(
IMediaLibraryCb
*
cb
);
void
stop
();
virtual
bool
discover
(
const
std
::
string
&
entryPoint
)
override
;
virtual
void
reload
()
override
;
...
...
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