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
8cc3dca1
Commit
8cc3dca1
authored
Aug 25, 2007
by
Pierre d'Herbemont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
misc/events.c: Add some debug code. (turnable on and off via #ifdef)
parent
3fdc5f7c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
10 deletions
+57
-10
include/vlc_events.h
include/vlc_events.h
+8
-4
src/misc/events.c
src/misc/events.c
+49
-6
No files found.
include/vlc_events.h
View file @
8cc3dca1
...
...
@@ -104,10 +104,12 @@ typedef struct vlc_event_manager_t
{
void
*
p_obj
;
vlc_mutex_t
object_lock
;
vlc_object_t
*
p_parent_object
;
DECL_ARRAY
(
struct
vlc_event_listeners_group_t
*
)
listeners_groups
;
}
vlc_event_manager_t
;
/* List of event */
/* Be sure to keep sync-ed with misc/events.c debug name table */
typedef
enum
vlc_event_type_t
{
/* Input item events */
vlc_InputItemMetaChanged
,
...
...
@@ -184,10 +186,12 @@ VLC_EXPORT(void, vlc_event_send, ( vlc_event_manager_t * p_em,
/*
* Add a callback for an event.
*/
VLC_EXPORT
(
int
,
vlc_event_attach
,
(
vlc_event_manager_t
*
p_event_manager
,
vlc_event_type_t
event_type
,
vlc_event_callback_t
pf_callback
,
void
*
p_user_data
));
#define vlc_event_attach(a, b, c, d) __vlc_event_attach(a, b, c, d, #c)
VLC_EXPORT
(
int
,
__vlc_event_attach
,
(
vlc_event_manager_t
*
p_event_manager
,
vlc_event_type_t
event_type
,
vlc_event_callback_t
pf_callback
,
void
*
p_user_data
,
const
char
*
psz_debug_name
));
/*
* Remove a callback for an event.
...
...
src/misc/events.c
View file @
8cc3dca1
...
...
@@ -39,6 +39,8 @@
* Documentation : Read vlc_events.h
*****************************************************************************/
//#define DEBUG_EVENT
/*****************************************************************************
* Private types.
*****************************************************************************/
...
...
@@ -47,6 +49,9 @@ typedef struct vlc_event_listener_t
{
void
*
p_user_data
;
vlc_event_callback_t
pf_callback
;
#ifdef DEBUG_EVENT
char
*
psz_debug_name
;
#endif
}
vlc_event_listener_t
;
typedef
struct
vlc_event_listeners_group_t
...
...
@@ -55,6 +60,16 @@ typedef struct vlc_event_listeners_group_t
DECL_ARRAY
(
struct
vlc_event_listener_t
*
)
listeners
;
}
vlc_event_listeners_group_t
;
#ifdef DEBUG_EVENT
static
const
char
*
ppsz_event_type_to_name
[]
=
{
[
vlc_InputItemMetaChanged
]
=
"vlc_InputItemMetaChanged"
,
[
vlc_InputItemSubItemAdded
]
=
"vlc_InputItemSubItemAdded"
,
[
vlc_ServicesDiscoveryItemAdded
]
=
"vlc_ServicesDiscoveryItemAdded"
,
[
vlc_ServicesDiscoveryItemRemoved
]
=
"vlc_ServicesDiscoveryItemRemoved"
}
#endif
/*****************************************************************************
*
*****************************************************************************/
...
...
@@ -70,6 +85,7 @@ 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
;
p_em
->
p_parent_object
=
p_parent_obj
;
vlc_mutex_init
(
p_parent_obj
,
&
p_em
->
object_lock
);
ARRAY_INIT
(
p_em
->
listeners_groups
);
return
VLC_SUCCESS
;
...
...
@@ -138,6 +154,12 @@ void vlc_event_send( vlc_event_manager_t * p_em,
FOREACH_ARRAY
(
listener
,
listeners_group
->
listeners
)
func
=
listener
->
pf_callback
;
user_data
=
listener
->
p_user_data
;
#ifdef DEBUG_EVENT
msg_Dbg
(
"Calling '%s' with a '%s' event (data %p)
\n
"
,
listener
->
psz_debug_name
,
ppsz_event_type_to_name
[
event_type
],
listener
->
p_user_data
);
#endif
/* This is safe to do that because we are sure
* that there will be no object owned references
* used after the lock. */
...
...
@@ -154,10 +176,11 @@ void vlc_event_send( vlc_event_manager_t * p_em,
/**
* Add a callback for an event.
*/
int
vlc_event_attach
(
vlc_event_manager_t
*
p_em
,
vlc_event_type_t
event_type
,
vlc_event_callback_t
pf_callback
,
void
*
p_user_data
)
int
__vlc_event_attach
(
vlc_event_manager_t
*
p_em
,
vlc_event_type_t
event_type
,
vlc_event_callback_t
pf_callback
,
void
*
p_user_data
,
const
char
*
psz_debug_name
)
{
vlc_event_listeners_group_t
*
listeners_group
;
vlc_event_listener_t
*
listener
;
...
...
@@ -167,18 +190,30 @@ int vlc_event_attach( vlc_event_manager_t * p_em,
listener
->
p_user_data
=
p_user_data
;
listener
->
pf_callback
=
pf_callback
;
#ifdef DEBUG_EVENT
listener
->
psz_debug_name
=
strdup
(
psz_debug_name
);
#else
(
void
)
psz_debug_name
;
#endif
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
);
#ifdef DEBUG_EVENT
msg_Dbg
(
"Listening to '%s' event with '%s' (data %p)
\n
"
,
ppsz_event_type_to_name
[
event_type
],
listener
->
psz_debug_name
,
listener
->
p_user_data
);
#endif
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
return
VLC_SUCCESS
;
}
FOREACH_END
()
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
msg_Err
(
p_em
->
p_parent_object
,
"Can't attach to an object event manager event"
);
free
(
listener
);
return
VLC_EGENERIC
;
}
...
...
@@ -206,6 +241,14 @@ int vlc_event_detach( vlc_event_manager_t *p_em,
ARRAY_REMOVE
(
listeners_group
->
listeners
,
fe_idx
/* This comes from the macro (and that's why
I hate macro) */
);
#ifdef DEBUG_EVENT
msg_Dbg
(
"Detaching '%s' from '%s' event (data %p)
\n
"
,
listener
->
psz_debug_name
,
ppsz_event_type_to_name
[
event_type
],
listener
->
p_user_data
);
free
(
listener
->
psz_debug_name
);
#endif
free
(
listener
);
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
return
VLC_SUCCESS
;
...
...
@@ -215,7 +258,7 @@ int vlc_event_detach( vlc_event_manager_t *p_em,
FOREACH_END
()
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
msg_Warn
(
p_em
->
p_parent_object
,
"Can't detach to an object event manager event"
);
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