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
1c0e65e3
Commit
1c0e65e3
authored
Jun 03, 2009
by
Pierre d'Herbemont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libvlc: Get rid of the recursive lock.
parent
4dafeacf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
12 deletions
+26
-12
src/control/event_async.c
src/control/event_async.c
+26
-12
No files found.
src/control/event_async.c
View file @
1c0e65e3
...
...
@@ -90,6 +90,16 @@ static void push(libvlc_event_manager_t * p_em, libvlc_event_listener_t * listen
iter
->
next
=
elmt
;
}
static
inline
void
queue_lock
(
libvlc_event_manager_t
*
p_em
)
{
vlc_mutex_lock
(
&
queue
(
p_em
)
->
lock
);
}
static
inline
void
queue_unlock
(
libvlc_event_manager_t
*
p_em
)
{
vlc_mutex_unlock
(
&
queue
(
p_em
)
->
lock
);
}
/* Lock must be held */
static
bool
pop
(
libvlc_event_manager_t
*
p_em
,
libvlc_event_listener_t
*
listener
,
libvlc_event_t
*
event
)
{
...
...
@@ -172,7 +182,7 @@ libvlc_event_async_init(libvlc_event_manager_t * p_em)
return
;
}
vlc_mutex_init
_recursive
(
&
queue
(
p_em
)
->
lock
);
// Beware, this is re-entrant
vlc_mutex_init
(
&
queue
(
p_em
)
->
lock
);
vlc_cond_init
(
&
queue
(
p_em
)
->
signal
);
}
...
...
@@ -186,9 +196,9 @@ libvlc_event_async_ensure_listener_removal(libvlc_event_manager_t * p_em, libvlc
{
if
(
!
is_queue_initialized
(
p_em
))
return
;
vlc_mutex_lock
(
&
queue
(
p_em
)
->
lock
);
queue_lock
(
p_em
);
pop_listener
(
p_em
,
listener
);
vlc_mutex_unlock
(
&
queue
(
p_em
)
->
lock
);
queue_unlock
(
p_em
);
}
/**************************************************************************
...
...
@@ -205,10 +215,10 @@ libvlc_event_async_dispatch(libvlc_event_manager_t * p_em, libvlc_event_listener
libvlc_event_async_init
(
p_em
);
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
vlc_mutex_lock
(
&
queue
(
p_em
)
->
lock
);
queue_lock
(
p_em
);
push
(
p_em
,
listener
,
event
);
vlc_cond_signal
(
&
queue
(
p_em
)
->
signal
);
vlc_mutex_unlock
(
&
queue
(
p_em
)
->
lock
);
queue_unlock
(
p_em
);
}
/**************************************************************************
...
...
@@ -222,19 +232,23 @@ static void * event_async_loop(void * arg)
libvlc_event_listener_t
listener
;
libvlc_event_t
event
;
vlc_mutex_lock
(
&
queue
(
p_em
)
->
lock
);
queue_lock
(
p_em
);
while
(
true
)
{
int
has_listener
=
pop
(
p_em
,
&
listener
,
&
event
);
mutex_cleanup_push
(
&
queue
(
p_em
)
->
lock
);
if
(
has_listener
)
listener
.
pf_callback
(
&
event
,
listener
.
p_user_data
);
// This might edit the queue, ->lock is recursive
{
queue_unlock
(
p_em
);
listener
.
pf_callback
(
&
event
,
listener
.
p_user_data
);
// This might edit the queue
queue_lock
(
p_em
);
}
else
{
mutex_cleanup_push
(
&
queue
(
p_em
)
->
lock
);
vlc_cond_wait
(
&
queue
(
p_em
)
->
signal
,
&
queue
(
p_em
)
->
lock
);
vlc_cleanup_pop
();
vlc_cleanup_pop
();
}
}
vlc_mutex_unlock
(
&
queue
(
p_em
)
->
lock
);
queue_unlock
(
p_em
);
return
NULL
;
}
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