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
6a80bb9a
Commit
6a80bb9a
authored
Jul 10, 2011
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove debug-only dependency of vlc_events on vlc_object
parent
dca6b1f8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
102 deletions
+18
-102
include/vlc_events.h
include/vlc_events.h
+6
-17
src/input/item.c
src/input/item.c
+1
-1
src/misc/events.c
src/misc/events.c
+10
-83
src/playlist/services_discovery.c
src/playlist/services_discovery.c
+1
-1
No files found.
include/vlc_events.h
View file @
6a80bb9a
...
@@ -105,12 +105,10 @@ typedef struct vlc_event_manager_t
...
@@ -105,12 +105,10 @@ typedef struct vlc_event_manager_t
void
*
p_obj
;
void
*
p_obj
;
vlc_mutex_t
object_lock
;
vlc_mutex_t
object_lock
;
vlc_mutex_t
event_sending_lock
;
vlc_mutex_t
event_sending_lock
;
vlc_object_t
*
p_parent_object
;
DECL_ARRAY
(
struct
vlc_event_listeners_group_t
*
)
listeners_groups
;
DECL_ARRAY
(
struct
vlc_event_listeners_group_t
*
)
listeners_groups
;
}
vlc_event_manager_t
;
}
vlc_event_manager_t
;
/* List of event */
/* List of event */
/* Be sure to keep sync-ed with misc/events.c debug name table */
typedef
enum
vlc_event_type_t
{
typedef
enum
vlc_event_type_t
{
/* Input (thread) events */
/* Input (thread) events */
vlc_InputStateChanged
,
vlc_InputStateChanged
,
...
@@ -216,15 +214,8 @@ typedef void ( *vlc_event_callback_t )( const vlc_event_t *, void * );
...
@@ -216,15 +214,8 @@ typedef void ( *vlc_event_callback_t )( const vlc_event_t *, void * );
/*
/*
* p_obj points to the object that owns the event manager, and from
* p_obj points to the object that owns the event manager, and from
* which events are sent
* which events are sent
* p_obj is here to give us a libvlc instance
*/
*/
#define vlc_event_manager_init_with_vlc_object(a,b) \
VLC_API
int
vlc_event_manager_init
(
vlc_event_manager_t
*
p_em
,
void
*
p_obj
);
vlc_event_manager_init( a, b, b )
VLC_API
int
vlc_event_manager_init
(
vlc_event_manager_t
*
p_em
,
void
*
p_obj
,
vlc_object_t
*
);
#define vlc_event_manager_init(a,b,c) \
vlc_event_manager_init(a, b, VLC_OBJECT(c))
/*
/*
* Destroy
* Destroy
...
@@ -248,16 +239,14 @@ VLC_API void vlc_event_send( vlc_event_manager_t * p_em, vlc_event_t * );
...
@@ -248,16 +239,14 @@ VLC_API void vlc_event_send( vlc_event_manager_t * p_em, vlc_event_t * );
VLC_API
int
vlc_event_attach
(
vlc_event_manager_t
*
p_event_manager
,
VLC_API
int
vlc_event_attach
(
vlc_event_manager_t
*
p_event_manager
,
vlc_event_type_t
event_type
,
vlc_event_type_t
event_type
,
vlc_event_callback_t
pf_callback
,
vlc_event_callback_t
pf_callback
,
void
*
p_user_data
,
void
*
p_user_data
);
const
char
*
psz_debug_name
);
#define vlc_event_attach(a, b, c, d) vlc_event_attach(a, b, c, d, #c)
/*
/*
* Remove a callback for an event.
* Remove a callback for an event.
*/
*/
VLC_API
int
vlc_event_detach
(
vlc_event_manager_t
*
p_event_manager
,
VLC_API
void
vlc_event_detach
(
vlc_event_manager_t
*
p_event_manager
,
vlc_event_type_t
event_type
,
vlc_event_type_t
event_type
,
vlc_event_callback_t
pf_callback
,
vlc_event_callback_t
pf_callback
,
void
*
p_user_data
);
void
*
p_user_data
);
#endif
/* VLC_EVENTS_H */
#endif
/* VLC_EVENTS_H */
src/input/item.c
View file @
6a80bb9a
...
@@ -60,7 +60,7 @@ static inline void input_item_Init( vlc_object_t *p_o, input_item_t *p_i )
...
@@ -60,7 +60,7 @@ static inline void input_item_Init( vlc_object_t *p_o, input_item_t *p_i )
vlc_mutex_init
(
&
p_i
->
lock
);
vlc_mutex_init
(
&
p_i
->
lock
);
vlc_event_manager_t
*
p_em
=
&
p_i
->
event_manager
;
vlc_event_manager_t
*
p_em
=
&
p_i
->
event_manager
;
vlc_event_manager_init
(
p_em
,
p_i
,
p_o
);
vlc_event_manager_init
(
p_em
,
p_i
);
vlc_event_manager_register_event_type
(
p_em
,
vlc_InputItemMetaChanged
);
vlc_event_manager_register_event_type
(
p_em
,
vlc_InputItemMetaChanged
);
vlc_event_manager_register_event_type
(
p_em
,
vlc_InputItemSubItemAdded
);
vlc_event_manager_register_event_type
(
p_em
,
vlc_InputItemSubItemAdded
);
vlc_event_manager_register_event_type
(
p_em
,
vlc_InputItemSubItemTreeAdded
);
vlc_event_manager_register_event_type
(
p_em
,
vlc_InputItemSubItemTreeAdded
);
...
...
src/misc/events.c
View file @
6a80bb9a
...
@@ -42,8 +42,6 @@
...
@@ -42,8 +42,6 @@
* Documentation : Read vlc_events.h
* Documentation : Read vlc_events.h
*****************************************************************************/
*****************************************************************************/
//#define DEBUG_EVENT
/*****************************************************************************
/*****************************************************************************
* Private types.
* Private types.
*****************************************************************************/
*****************************************************************************/
...
@@ -52,9 +50,6 @@ typedef struct vlc_event_listener_t
...
@@ -52,9 +50,6 @@ typedef struct vlc_event_listener_t
{
{
void
*
p_user_data
;
void
*
p_user_data
;
vlc_event_callback_t
pf_callback
;
vlc_event_callback_t
pf_callback
;
#ifdef DEBUG_EVENT
char
*
psz_debug_name
;
#endif
}
vlc_event_listener_t
;
}
vlc_event_listener_t
;
typedef
struct
vlc_event_listeners_group_t
typedef
struct
vlc_event_listeners_group_t
...
@@ -69,27 +64,6 @@ typedef struct vlc_event_listeners_group_t
...
@@ -69,27 +64,6 @@ typedef struct vlc_event_listeners_group_t
}
vlc_event_listeners_group_t
;
}
vlc_event_listeners_group_t
;
#ifdef DEBUG_EVENT
static
const
char
ppsz_event_type_to_name
[][
40
]
=
{
[
vlc_InputStateChanged
]
=
"vlc_InputStateChanged"
,
[
vlc_InputSelectedStreamChanged
]
=
"vlc_InputSelectedStreamChanged"
,
[
vlc_InputItemMetaChanged
]
=
"vlc_InputItemMetaChanged"
,
[
vlc_InputItemSubItemAdded
]
=
"vlc_InputItemSubItemAdded"
,
[
vlc_InputItemDurationChanged
]
=
"vlc_InputItemDurationChanged"
,
[
vlc_InputItemPreparsedChanged
]
=
"vlc_InputItemPreparsedChanged"
,
[
vlc_InputItemNameChanged
]
=
"vlc_InputItemNameChanged"
,
[
vlc_InputItemInfoChanged
]
=
"vlc_InputItemInfoChanged"
,
[
vlc_InputItemErrorWhenReadingChanged
]
=
"vlc_InputItemErrorWhenReadingChanged"
,
[
vlc_ServicesDiscoveryItemAdded
]
=
"vlc_ServicesDiscoveryItemAdded"
,
[
vlc_ServicesDiscoveryItemRemoved
]
=
"vlc_ServicesDiscoveryItemRemoved"
,
[
vlc_ServicesDiscoveryStarted
]
=
"vlc_ServicesDiscoveryStarted"
,
[
vlc_ServicesDiscoveryEnded
]
=
"vlc_ServicesDiscoveryEnded"
};
#endif
static
bool
static
bool
listeners_are_equal
(
vlc_event_listener_t
*
listener1
,
listeners_are_equal
(
vlc_event_listener_t
*
listener1
,
vlc_event_listener_t
*
listener2
)
vlc_event_listener_t
*
listener2
)
...
@@ -120,13 +94,10 @@ group_contains_listener( vlc_event_listeners_group_t * group,
...
@@ -120,13 +94,10 @@ group_contains_listener( vlc_event_listeners_group_t * group,
* p_obj 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
* necessarily a vlc_object_t (an input_item_t is not a vlc_object_t
* for instance).
* 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
;
p_em
->
p_obj
=
p_obj
;
p_em
->
p_parent_object
=
p_parent_obj
;
vlc_mutex_init
(
&
p_em
->
object_lock
);
vlc_mutex_init
(
&
p_em
->
object_lock
);
/* We need a recursive lock here, because we need to be able
/* We need a recursive lock here, because we need to be able
...
@@ -219,9 +190,6 @@ void vlc_event_send( vlc_event_manager_t * p_em,
...
@@ -219,9 +190,6 @@ void vlc_event_send( vlc_event_manager_t * p_em,
cached_listener
=
array_of_cached_listeners
;
cached_listener
=
array_of_cached_listeners
;
FOREACH_ARRAY
(
listener
,
listeners_group
->
listeners
)
FOREACH_ARRAY
(
listener
,
listeners_group
->
listeners
)
memcpy
(
cached_listener
,
listener
,
sizeof
(
vlc_event_listener_t
));
memcpy
(
cached_listener
,
listener
,
sizeof
(
vlc_event_listener_t
));
#ifdef DEBUG_EVENT
cached_listener
->
psz_debug_name
=
strdup
(
cached_listener
->
psz_debug_name
);
#endif
cached_listener
++
;
cached_listener
++
;
FOREACH_END
()
FOREACH_END
()
...
@@ -246,14 +214,6 @@ void vlc_event_send( vlc_event_manager_t * p_em,
...
@@ -246,14 +214,6 @@ void vlc_event_send( vlc_event_manager_t * p_em,
for
(
i
=
0
;
i
<
i_cached_listeners
;
i
++
)
for
(
i
=
0
;
i
<
i_cached_listeners
;
i
++
)
{
{
#ifdef DEBUG_EVENT
msg_Dbg
(
p_em
->
p_parent_object
,
"Calling '%s' with a '%s' event (data %p)"
,
cached_listener
->
psz_debug_name
,
ppsz_event_type_to_name
[
p_event
->
type
],
cached_listener
->
p_user_data
);
free
(
cached_listener
->
psz_debug_name
);
#endif
/* No need to lock on listeners_group, a listener group can't be removed */
/* No need to lock on listeners_group, a listener group can't be removed */
if
(
listeners_group
->
b_sublistener_removed
)
if
(
listeners_group
->
b_sublistener_removed
)
{
{
...
@@ -264,9 +224,6 @@ void vlc_event_send( vlc_event_manager_t * p_em,
...
@@ -264,9 +224,6 @@ void vlc_event_send( vlc_event_manager_t * p_em,
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
if
(
!
valid_listener
)
if
(
!
valid_listener
)
{
{
#ifdef DEBUG_EVENT
msg_Dbg
(
p_em
->
p_parent_object
,
"Callback was removed during execution"
);
#endif
cached_listener
++
;
cached_listener
++
;
continue
;
continue
;
}
}
...
@@ -286,8 +243,7 @@ void vlc_event_send( vlc_event_manager_t * p_em,
...
@@ -286,8 +243,7 @@ void vlc_event_send( vlc_event_manager_t * p_em,
int
vlc_event_attach
(
vlc_event_manager_t
*
p_em
,
int
vlc_event_attach
(
vlc_event_manager_t
*
p_em
,
vlc_event_type_t
event_type
,
vlc_event_type_t
event_type
,
vlc_event_callback_t
pf_callback
,
vlc_event_callback_t
pf_callback
,
void
*
p_user_data
,
void
*
p_user_data
)
const
char
*
psz_debug_name
)
{
{
vlc_event_listeners_group_t
*
listeners_group
;
vlc_event_listeners_group_t
*
listeners_group
;
vlc_event_listener_t
*
listener
;
vlc_event_listener_t
*
listener
;
...
@@ -297,43 +253,28 @@ int vlc_event_attach( vlc_event_manager_t * p_em,
...
@@ -297,43 +253,28 @@ int vlc_event_attach( vlc_event_manager_t * p_em,
listener
->
p_user_data
=
p_user_data
;
listener
->
p_user_data
=
p_user_data
;
listener
->
pf_callback
=
pf_callback
;
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
);
vlc_mutex_lock
(
&
p_em
->
object_lock
);
FOREACH_ARRAY
(
listeners_group
,
p_em
->
listeners_groups
)
FOREACH_ARRAY
(
listeners_group
,
p_em
->
listeners_groups
)
if
(
listeners_group
->
event_type
==
event_type
)
if
(
listeners_group
->
event_type
==
event_type
)
{
{
ARRAY_APPEND
(
listeners_group
->
listeners
,
listener
);
ARRAY_APPEND
(
listeners_group
->
listeners
,
listener
);
#ifdef DEBUG_EVENT
msg_Dbg
(
p_em
->
p_parent_object
,
"Listening to '%s' event with '%s' (data %p)"
,
ppsz_event_type_to_name
[
event_type
],
listener
->
psz_debug_name
,
listener
->
p_user_data
);
#endif
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
FOREACH_END
()
FOREACH_END
()
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
/* Unknown event = BUG */
assert
(
0
);
msg_Err
(
p_em
->
p_parent_object
,
"cannot attach to an object event"
);
free
(
listener
);
return
VLC_EGENERIC
;
}
}
/**
/**
* Remove a callback for an event.
* Remove a callback for an event.
*/
*/
int
vlc_event_detach
(
vlc_event_manager_t
*
p_em
,
void
vlc_event_detach
(
vlc_event_manager_t
*
p_em
,
vlc_event_type_t
event_type
,
vlc_event_type_t
event_type
,
vlc_event_callback_t
pf_callback
,
vlc_event_callback_t
pf_callback
,
void
*
p_user_data
)
void
*
p_user_data
)
{
{
vlc_event_listeners_group_t
*
listeners_group
;
vlc_event_listeners_group_t
*
listeners_group
;
struct
vlc_event_listener_t
*
listener
;
struct
vlc_event_listener_t
*
listener
;
...
@@ -355,28 +296,14 @@ int vlc_event_detach( vlc_event_manager_t *p_em,
...
@@ -355,28 +296,14 @@ int vlc_event_detach( vlc_event_manager_t *p_em,
ARRAY_REMOVE
(
listeners_group
->
listeners
,
ARRAY_REMOVE
(
listeners_group
->
listeners
,
fe_idx
/* This comes from the macro (and that's why
fe_idx
/* This comes from the macro (and that's why
I hate macro) */
);
I hate macro) */
);
#ifdef DEBUG_EVENT
msg_Dbg
(
p_em
->
p_parent_object
,
"Detaching '%s' from '%s' event (data %p)"
,
listener
->
psz_debug_name
,
ppsz_event_type_to_name
[
event_type
],
listener
->
p_user_data
);
free
(
listener
->
psz_debug_name
);
#endif
free
(
listener
);
free
(
listener
);
vlc_mutex_unlock
(
&
p_em
->
event_sending_lock
);
vlc_mutex_unlock
(
&
p_em
->
event_sending_lock
);
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
return
VLC_SUCCESS
;
return
;
}
}
FOREACH_END
()
FOREACH_END
()
}
}
FOREACH_END
()
FOREACH_END
()
vlc_mutex_unlock
(
&
p_em
->
event_sending_lock
);
vlc_mutex_unlock
(
&
p_em
->
object_lock
);
msg_Warn
(
p_em
->
p_parent_object
,
"cannot detach from an object event"
);
assert
(
0
);
return
VLC_EGENERIC
;
}
}
src/playlist/services_discovery.c
View file @
6a80bb9a
...
@@ -118,7 +118,7 @@ services_discovery_t *vlc_sd_Create( vlc_object_t *p_super,
...
@@ -118,7 +118,7 @@ services_discovery_t *vlc_sd_Create( vlc_object_t *p_super,
free
(
config_ChainCreate
(
&
p_sd
->
psz_name
,
&
p_sd
->
p_cfg
,
cfg
));
free
(
config_ChainCreate
(
&
p_sd
->
psz_name
,
&
p_sd
->
p_cfg
,
cfg
));
vlc_event_manager_t
*
em
=
&
p_sd
->
event_manager
;
vlc_event_manager_t
*
em
=
&
p_sd
->
event_manager
;
vlc_event_manager_init
(
em
,
p_sd
,
(
vlc_object_t
*
)
p_sd
);
vlc_event_manager_init
(
em
,
p_sd
);
vlc_event_manager_register_event_type
(
em
,
vlc_ServicesDiscoveryItemAdded
);
vlc_event_manager_register_event_type
(
em
,
vlc_ServicesDiscoveryItemAdded
);
vlc_event_manager_register_event_type
(
em
,
vlc_ServicesDiscoveryItemRemoved
);
vlc_event_manager_register_event_type
(
em
,
vlc_ServicesDiscoveryItemRemoved
);
vlc_event_manager_register_event_type
(
em
,
vlc_ServicesDiscoveryStarted
);
vlc_event_manager_register_event_type
(
em
,
vlc_ServicesDiscoveryStarted
);
...
...
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