Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
ace8caef
Commit
ace8caef
authored
Jun 22, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LibVLC: wait until all threads are terminated
parent
6c790747
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
0 deletions
+42
-0
src/libvlc.c
src/libvlc.c
+17
-0
src/libvlc.h
src/libvlc.h
+6
-0
src/misc/threads.c
src/misc/threads.c
+19
-0
No files found.
src/libvlc.c
View file @
ace8caef
...
...
@@ -197,6 +197,10 @@ libvlc_int_t * libvlc_InternalCreate( void )
vlc_mutex_init
(
&
priv
->
timer_lock
);
vlc_mutex_init
(
&
priv
->
config_lock
);
priv
->
threads_count
=
0
;
vlc_mutex_init
(
&
priv
->
threads_lock
);
vlc_cond_init
(
NULL
,
&
priv
->
threads_wait
);
/* Store data for the non-reentrant API */
p_static_vlc
=
p_libvlc
;
...
...
@@ -986,6 +990,17 @@ int libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
}
#endif
/* Make sure all threads are completed before we start looking for
* reference leaks and deinitializing core LibVLC subsytems. */
vlc_mutex_lock
(
&
priv
->
threads_lock
);
while
(
priv
->
threads_count
)
{
msg_Dbg
(
p_libvlc
,
"waiting for %u remaining threads"
,
priv
->
threads_count
);
vlc_cond_wait
(
&
priv
->
threads_wait
,
&
priv
->
threads_lock
);
}
vlc_mutex_unlock
(
&
priv
->
threads_lock
);
bool
b_clean
=
true
;
FOREACH_ARRAY
(
input_item_t
*
p_del
,
priv
->
input_items
)
msg_Err
(
p_libvlc
,
"input item %p has not been deleted properly: refcount %d, name %s"
,
...
...
@@ -1066,6 +1081,8 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, bool b_release )
/* Destroy mutexes */
vlc_mutex_destroy
(
&
priv
->
config_lock
);
vlc_mutex_destroy
(
&
priv
->
timer_lock
);
vlc_cond_destroy
(
&
priv
->
threads_wait
);
vlc_mutex_destroy
(
&
priv
->
threads_lock
);
if
(
b_release
)
vlc_object_release
(
p_libvlc
);
vlc_object_release
(
p_libvlc
);
...
...
src/libvlc.h
View file @
ace8caef
...
...
@@ -244,6 +244,7 @@ typedef struct libvlc_priv_t
void
*
p_stats_computer
;
///< Input thread computing stats
/// (needs cleanup)
/* Singleton objects */
module_t
*
p_memcpy_module
;
///< Fast memcpy plugin used
playlist_t
*
p_playlist
;
//< the playlist singleton
vlm_t
*
p_vlm
;
///< the VLM singleton (or NULL)
...
...
@@ -252,6 +253,11 @@ typedef struct libvlc_priv_t
/* Private playlist data (FIXME - playlist_t is too public...) */
sout_instance_t
*
p_sout
;
///< kept sout instance (for playlist)
/* Thread support */
unsigned
threads_count
;
vlc_mutex_t
threads_lock
;
vlc_cond_t
threads_wait
;
}
libvlc_priv_t
;
static
inline
libvlc_priv_t
*
libvlc_priv
(
libvlc_int_t
*
libvlc
)
...
...
src/misc/threads.c
View file @
ace8caef
...
...
@@ -467,6 +467,12 @@ static THREAD_RTYPE thread_entry (void *data)
msg_Dbg
(
obj
,
"thread started"
);
func
(
obj
);
msg_Dbg
(
obj
,
"thread ended"
);
libvlc_priv_t
*
libpriv
=
libvlc_priv
(
obj
->
p_libvlc
);
vlc_mutex_lock
(
&
libpriv
->
threads_lock
);
if
(
--
libpriv
->
threads_count
==
0
)
vlc_cond_signal
(
&
libpriv
->
threads_wait
);
vlc_mutex_unlock
(
&
libpriv
->
threads_lock
);
return
THREAD_RVAL
;
}
...
...
@@ -482,6 +488,7 @@ int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line
{
int
i_ret
;
vlc_object_internals_t
*
p_priv
=
vlc_internals
(
p_this
);
libvlc_priv_t
*
libpriv
=
libvlc_priv
(
p_this
->
p_libvlc
);
struct
vlc_thread_boot
*
boot
=
malloc
(
sizeof
(
*
boot
));
if
(
boot
==
NULL
)
...
...
@@ -489,6 +496,10 @@ int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line
boot
->
entry
=
func
;
boot
->
object
=
p_this
;
vlc_mutex_lock
(
&
libpriv
->
threads_lock
);
libpriv
->
threads_count
++
;
vlc_mutex_unlock
(
&
libpriv
->
threads_lock
);
vlc_object_lock
(
p_this
);
#if defined( LIBVLC_USE_PTHREAD )
...
...
@@ -596,6 +607,14 @@ int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line
}
vlc_object_unlock
(
p_this
);
if
(
i_ret
)
{
vlc_mutex_lock
(
&
libpriv
->
threads_lock
);
if
(
--
libpriv
->
threads_count
==
0
)
vlc_cond_signal
(
&
libpriv
->
threads_wait
);
vlc_mutex_unlock
(
&
libpriv
->
threads_lock
);
}
return
i_ret
;
}
...
...
Write
Preview
Markdown
is supported
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