Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
13b7d257
Commit
13b7d257
authored
May 12, 2009
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libvlc_event_*: fix locking
parent
15463713
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
9 deletions
+28
-9
src/control/event.c
src/control/event.c
+28
-9
No files found.
src/control/event.c
View file @
13b7d257
...
...
@@ -93,8 +93,8 @@ void libvlc_event_manager_release( libvlc_event_manager_t * p_em )
libvlc_event_listeners_group_t
*
p_lg
;
int
i
,
j
;
vlc_mutex_
destroy
(
&
p_em
->
event_sending_lock
);
vlc_mutex_
destroy
(
&
p_em
->
object_lock
);
vlc_mutex_
lock
(
&
p_em
->
event_sending_lock
);
vlc_mutex_
lock
(
&
p_em
->
object_lock
);
for
(
i
=
0
;
i
<
vlc_array_count
(
&
p_em
->
listeners_groups
);
i
++
)
{
...
...
@@ -107,7 +107,15 @@ void libvlc_event_manager_release( libvlc_event_manager_t * p_em )
free
(
p_lg
);
}
vlc_array_clear
(
&
p_em
->
listeners_groups
);
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
vlc_mutex_unlock
(
&
p_em
->
event_sending_lock
);
libvlc_release
(
p_em
->
p_libvlc_instance
);
vlc_mutex_destroy
(
&
p_em
->
event_sending_lock
);
vlc_mutex_destroy
(
&
p_em
->
object_lock
);
free
(
p_em
);
}
...
...
@@ -122,9 +130,14 @@ void libvlc_event_manager_register_event_type(
libvlc_exception_t
*
p_e
)
{
libvlc_event_listeners_group_t
*
listeners_group
;
vlc_mutex_lock
(
&
p_em
->
object_lock
);
listeners_group
=
malloc
(
sizeof
(
libvlc_event_listeners_group_t
));
if
(
!
listeners_group
)
{
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
libvlc_exception_raise
(
p_e
,
"No Memory left"
);
return
;
}
...
...
@@ -132,7 +145,6 @@ void libvlc_event_manager_register_event_type(
listeners_group
->
event_type
=
event_type
;
vlc_array_init
(
&
listeners_group
->
listeners
);
vlc_mutex_lock
(
&
p_em
->
object_lock
);
vlc_array_append
(
&
p_em
->
listeners_groups
,
listeners_group
);
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
}
...
...
@@ -171,6 +183,7 @@ void libvlc_event_send( libvlc_event_manager_t * p_em,
if
(
!
array_listeners_cached
)
{
fprintf
(
stderr
,
"Can't alloc memory in libvlc_event_send"
);
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
return
;
}
...
...
@@ -187,6 +200,7 @@ void libvlc_event_send( libvlc_event_manager_t * p_em,
if
(
!
listeners_group
)
{
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
free
(
array_listeners_cached
);
return
;
}
...
...
@@ -215,9 +229,10 @@ void libvlc_event_send( libvlc_event_manager_t * p_em,
listener_cached
->
pf_callback
(
p_event
,
listener_cached
->
p_user_data
);
listener_cached
++
;
}
vlc_mutex_unlock
(
&
p_em
->
event_sending_lock
);
free
(
array_listeners_cached
);
vlc_mutex_unlock
(
&
p_em
->
event_sending_lock
);
}
/*
...
...
@@ -299,9 +314,13 @@ void libvlc_event_attach( libvlc_event_manager_t * p_event_manager,
libvlc_event_listener_t
*
listener
;
int
i
;
vlc_mutex_lock
(
&
p_event_manager
->
object_lock
);
listener
=
malloc
(
sizeof
(
libvlc_event_listener_t
));
if
(
!
listener
)
{
vlc_mutex_unlock
(
&
p_event_manager
->
object_lock
);
libvlc_exception_raise
(
p_e
,
"No Memory left"
);
return
;
}
...
...
@@ -310,7 +329,6 @@ void libvlc_event_attach( libvlc_event_manager_t * p_event_manager,
listener
->
p_user_data
=
p_user_data
;
listener
->
pf_callback
=
pf_callback
;
vlc_mutex_lock
(
&
p_event_manager
->
object_lock
);
for
(
i
=
0
;
i
<
vlc_array_count
(
&
p_event_manager
->
listeners_groups
);
i
++
)
{
listeners_group
=
vlc_array_item_at_index
(
&
p_event_manager
->
listeners_groups
,
i
);
...
...
@@ -321,9 +339,11 @@ void libvlc_event_attach( libvlc_event_manager_t * p_event_manager,
return
;
}
}
vlc_mutex_unlock
(
&
p_event_manager
->
object_lock
);
free
(
listener
);
vlc_mutex_unlock
(
&
p_event_manager
->
object_lock
);
libvlc_exception_raise
(
p_e
,
"This object event manager doesn't know about '%s' events"
,
libvlc_event_type_name
(
event_type
));
...
...
@@ -344,8 +364,8 @@ void libvlc_event_detach( libvlc_event_manager_t *p_event_manager,
libvlc_event_listener_t
*
listener
;
int
i
,
j
;
vlc_mutex_lock
(
&
p_event_manager
->
event_sending_lock
);
vlc_mutex_lock
(
&
p_event_manager
->
object_lock
);
for
(
i
=
0
;
i
<
vlc_array_count
(
&
p_event_manager
->
listeners_groups
);
i
++
)
{
listeners_group
=
vlc_array_item_at_index
(
&
p_event_manager
->
listeners_groups
,
i
);
...
...
@@ -367,14 +387,13 @@ void libvlc_event_detach( libvlc_event_manager_t *p_event_manager,
free
(
listener
);
vlc_array_remove
(
&
listeners_group
->
listeners
,
j
);
vlc_mutex_unlock
(
&
p_event_manager
->
object_lock
);
vlc_mutex_unlock
(
&
p_event_manager
->
event_sending_lock
);
return
;
}
}
}
}
vlc_mutex_unlock
(
&
p_event_manager
->
object_lock
);
vlc_mutex_unlock
(
&
p_event_manager
->
event_sending_lock
);
libvlc_exception_raise
(
p_e
,
"This object event manager doesn't know about '%s,%p,%p' event observer"
,
...
...
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