Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
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-1.1
Commits
5f9f9ea4
Commit
5f9f9ea4
authored
Aug 17, 2007
by
Pierre d'Herbemont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
misc/events.c: Avoid a couple of warning and move the calling back out of the lock.
parent
6e3263c3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
11 deletions
+32
-11
src/misc/events.c
src/misc/events.c
+32
-11
No files found.
src/misc/events.c
View file @
5f9f9ea4
...
...
@@ -64,13 +64,16 @@ typedef struct vlc_event_listeners_group_t
/**
* Initialize event manager object
* p_
this
is the object that contains the event manager. But not
* p_
obj
is the object that contains the event manager. But not
* necessarily a vlc_object_t (an input_item_t is not a vlc_object_t
* for instance).
* p_parent_obj gives a libvlc instance
*/
int
vlc_event_manager_init
(
vlc_event_manager_t
*
p_em
,
void
*
p_obj
)
int
vlc_event_manager_init
(
vlc_event_manager_t
*
p_em
,
void
*
p_obj
,
vlc_object_t
*
p_parent_obj
)
{
p_em
->
p_obj
=
p_obj
;
vlc_mutex_init
(
p_parent_obj
,
&
p_em
->
object_lock
);
ARRAY_INIT
(
p_em
->
listeners_groups
);
return
VLC_SUCCESS
;
}
...
...
@@ -83,6 +86,8 @@ void vlc_event_manager_fini( vlc_event_manager_t * p_em )
struct
vlc_event_listeners_group_t
*
listeners_group
;
struct
vlc_event_listener_t
*
listener
;
vlc_mutex_destroy
(
&
p_em
->
object_lock
);
FOREACH_ARRAY
(
listeners_group
,
p_em
->
listeners_groups
)
FOREACH_ARRAY
(
listener
,
listeners_group
->
listeners
)
free
(
listener
);
...
...
@@ -106,8 +111,10 @@ int vlc_event_manager_register_event_type(
listeners_group
->
event_type
=
event_type
;
ARRAY_INIT
(
listeners_group
->
listeners
);
vlc_mutex_lock
(
&
p_em
->
object_lock
);
ARRAY_APPEND
(
p_em
->
listeners_groups
,
listeners_group
);
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
return
VLC_SUCCESS
;
}
...
...
@@ -120,26 +127,33 @@ void vlc_event_send( vlc_event_manager_t * p_em,
{
vlc_event_listeners_group_t
*
listeners_group
;
vlc_event_listener_t
*
listener
;
vlc_event_callback_t
func
;
void
*
user_data
;
/* Fill event with the sending object now */
p_event
->
p_obj
=
p_em
->
p_obj
;
vlc_mutex_lock
(
&
p_em
->
object_lock
);
FOREACH_ARRAY
(
listeners_group
,
p_em
->
listeners_groups
)
if
(
listeners_group
->
event_type
==
p_event
->
type
)
{
/* We found the group, now send every one the event */
FOREACH_ARRAY
(
listener
,
listeners_group
->
listeners
)
listener
->
pf_callback
(
p_event
,
listener
->
p_user_data
);
func
=
listener
->
pf_callback
;
user_data
=
listener
->
p_user_data
;
FOREACH_END
()
break
;
}
FOREACH_END
()
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
func
(
p_event
,
user_data
);
}
/**
* Add a callback for an event.
*/
int
vlc_event_attach
(
vlc_event_manager_t
*
p_e
vent_manager
,
int
vlc_event_attach
(
vlc_event_manager_t
*
p_e
m
,
vlc_event_type_t
event_type
,
vlc_event_callback_t
pf_callback
,
void
*
p_user_data
)
...
...
@@ -152,15 +166,18 @@ int vlc_event_attach( vlc_event_manager_t * p_event_manager,
listener
->
p_user_data
=
p_user_data
;
listener
->
pf_callback
=
pf_callback
;
FOREACH_ARRAY
(
listeners_group
,
p_event_manager
->
listeners_groups
)
vlc_mutex_lock
(
&
p_em
->
object_lock
);
FOREACH_ARRAY
(
listeners_group
,
p_em
->
listeners_groups
)
if
(
listeners_group
->
event_type
==
event_type
)
{
ARRAY_APPEND
(
listeners_group
->
listeners
,
listener
);
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
return
VLC_SUCCESS
;
}
FOREACH_END
()
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
free
(
listener
);
return
VLC_EGENERIC
;
}
...
...
@@ -168,14 +185,16 @@ int vlc_event_attach( vlc_event_manager_t * p_event_manager,
/**
* Remove a callback for an event.
*/
int
vlc_event_detach
(
vlc_event_manager_t
*
p_e
vent_manager
,
int
vlc_event_detach
(
vlc_event_manager_t
*
p_e
m
,
vlc_event_type_t
event_type
,
vlc_event_callback_t
pf_callback
,
void
*
p_user_data
)
{
vlc_event_listeners_group_t
*
listeners_group
;
struct
vlc_event_listener_t
*
listener
;
FOREACH_ARRAY
(
listeners_group
,
p_event_manager
->
listeners_groups
)
vlc_mutex_lock
(
&
p_em
->
object_lock
);
FOREACH_ARRAY
(
listeners_group
,
p_em
->
listeners_groups
)
if
(
listeners_group
->
event_type
==
event_type
)
{
FOREACH_ARRAY
(
listener
,
listeners_group
->
listeners
)
...
...
@@ -183,15 +202,17 @@ int vlc_event_detach( vlc_event_manager_t *p_event_manager,
listener
->
p_user_data
==
p_user_data
)
{
/* that's our listener */
free
(
listener
);
ARRAY_REMOVE
(
listeners_group
->
listeners
,
fe_idx
/* This comes from the macro (and that's why
I hate macro) */
);
free
(
listener
);
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
return
VLC_SUCCESS
;
}
FOREACH_END
()
}
FOREACH_END
()
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
return
VLC_EGENERIC
;
}
...
...
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