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
7401be21
Commit
7401be21
authored
Aug 23, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vlc_object_get_name, vlc_object_set_name: accessors
parent
df85fc8b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
14 deletions
+43
-14
src/libvlc.h
src/libvlc.h
+12
-2
src/misc/objects.c
src/misc/objects.c
+31
-12
No files found.
src/libvlc.h
View file @
7401be21
...
...
@@ -140,6 +140,12 @@ __vlc_custom_create (vlc_object_t *p_this, size_t i_size, int i_type,
#define vlc_custom_create(o, s, t, n) \
__vlc_custom_create(VLC_OBJECT(o), s, t, n)
/**
* Assign a name to an object for vlc_object_find_name().
*/
extern
int
vlc_object_set_name
(
vlc_object_t
*
,
const
char
*
);
#define vlc_object_set_name(o, n) vlc_object_set_name(VLC_OBJECT(o), n)
/*
* To be cleaned-up module stuff:
*/
...
...
@@ -158,8 +164,7 @@ module_t *module_find_by_shortcut (const char *psz_shortcut);
typedef
struct
vlc_object_internals_t
{
int
i_object_type
;
/* Object type, deprecated */
char
*
psz_object_name
;
/* module name */
/* ^^ can only used from the thread that called module_(un)need() */
char
*
psz_name
;
/* given name */
/* Object variables */
variable_t
*
p_vars
;
...
...
@@ -193,6 +198,11 @@ typedef struct vlc_object_internals_t
#define vlc_internals( obj ) (((vlc_object_internals_t*)(VLC_OBJECT(obj)))-1)
static
inline
const
char
*
vlc_object_get_name
(
const
vlc_object_t
*
o
)
{
return
vlc_internals
(
o
)
->
psz_name
;
}
typedef
struct
sap_handler_t
sap_handler_t
;
/**
...
...
src/misc/objects.c
View file @
7401be21
...
...
@@ -54,6 +54,7 @@
# include <errno.h>
/* ENOSYS */
#endif
#include <limits.h>
#include <assert.h>
#if defined (HAVE_SYS_EVENTFD_H)
...
...
@@ -122,7 +123,7 @@ void *__vlc_custom_create( vlc_object_t *p_this, size_t i_size,
p_priv
->
i_object_type
=
i_type
;
p_new
->
psz_object_type
=
psz_type
;
p_priv
->
psz_
object_
name
=
NULL
;
p_priv
->
psz_name
=
NULL
;
p_new
->
b_die
=
false
;
p_new
->
b_error
=
false
;
...
...
@@ -241,6 +242,20 @@ void __vlc_object_set_destructor( vlc_object_t *p_this,
vlc_spin_unlock
(
&
p_priv
->
ref_spin
);
}
#undef vlc_object_set_name
int
vlc_object_set_name
(
vlc_object_t
*
obj
,
const
char
*
name
)
{
vlc_object_internals_t
*
priv
=
vlc_internals
(
obj
);
/* Object must be named before it is attached (or never) */
assert
(
obj
->
p_parent
==
NULL
);
assert
(
priv
->
i_children
==
0
);
free
(
priv
->
psz_name
);
priv
->
psz_name
=
name
?
strdup
(
name
)
:
NULL
;
return
(
priv
->
psz_name
||
!
name
)
?
VLC_SUCCESS
:
VLC_ENOMEM
;
}
/**
****************************************************************************
* Destroy a vlc object (Internal)
...
...
@@ -281,7 +296,7 @@ static void vlc_object_destroy( vlc_object_t *p_this )
free
(
p_this
->
psz_header
);
free
(
p_priv
->
psz_
object_
name
);
free
(
p_priv
->
psz_name
);
vlc_spin_destroy
(
&
p_priv
->
ref_spin
);
if
(
p_priv
->
pipes
[
1
]
!=
-
1
&&
p_priv
->
pipes
[
1
]
!=
p_priv
->
pipes
[
0
]
)
...
...
@@ -453,6 +468,14 @@ void * __vlc_object_find( vlc_object_t *p_this, int i_type, int i_mode )
return
p_found
;
}
static
int
objnamecmp
(
const
vlc_object_t
*
obj
,
const
char
*
name
)
{
if
(
!
vlc_object_get_name
(
obj
))
return
INT_MIN
;
return
strcmp
(
vlc_object_get_name
(
obj
),
name
);
}
#undef vlc_object_find_name
/**
* Finds a named object and increment its reference count.
...
...
@@ -479,9 +502,7 @@ vlc_object_t *vlc_object_find_name( vlc_object_t *p_this,
* Use a libvlc address variable instead for that sort of things! */
msg_Warn
(
p_this
,
"%s(%s) is not safe!"
,
__func__
,
psz_name
);
/* If have the requested name ourselves, don't look further */
if
(
!
(
i_mode
&
FIND_STRICT
)
&&
vlc_internals
(
p_this
)
->
psz_object_name
&&
!
strcmp
(
vlc_internals
(
p_this
)
->
psz_object_name
,
psz_name
)
)
if
(
!
(
i_mode
&
FIND_STRICT
)
&&
!
objnamecmp
(
p_this
,
psz_name
)
)
{
vlc_object_hold
(
p_this
);
return
p_this
;
...
...
@@ -581,7 +602,7 @@ void __vlc_object_release( vlc_object_t *p_this )
fprintf
(
stderr
,
"ERROR: leaking object (%p, type:%s, name:%s)
\n
"
,
leaked
,
leaked
->
psz_object_type
,
vlc_
internals
(
leaked
)
->
psz_object_name
);
vlc_
object_get_name
(
leaked
)
);
/* Dump object to ease debugging */
vlc_object_dump
(
leaked
);
fflush
(
stderr
);
...
...
@@ -1014,8 +1035,7 @@ static vlc_object_t * FindObjectName( vlc_object_t *p_this,
p_tmp
=
p_this
->
p_parent
;
if
(
p_tmp
)
{
if
(
vlc_internals
(
p_tmp
)
->
psz_object_name
&&
!
strcmp
(
vlc_internals
(
p_tmp
)
->
psz_object_name
,
psz_name
)
)
if
(
!
objnamecmp
(
p_tmp
,
psz_name
)
)
{
vlc_object_hold
(
p_tmp
);
return
p_tmp
;
...
...
@@ -1031,8 +1051,7 @@ static vlc_object_t * FindObjectName( vlc_object_t *p_this,
for
(
i
=
vlc_internals
(
p_this
)
->
i_children
;
i
--
;
)
{
p_tmp
=
vlc_internals
(
p_this
)
->
pp_children
[
i
];
if
(
vlc_internals
(
p_tmp
)
->
psz_object_name
&&
!
strcmp
(
vlc_internals
(
p_tmp
)
->
psz_object_name
,
psz_name
)
)
if
(
!
objnamecmp
(
p_tmp
,
psz_name
)
)
{
vlc_object_hold
(
p_tmp
);
return
p_tmp
;
...
...
@@ -1064,10 +1083,10 @@ static void PrintObject( vlc_object_t *p_this, const char *psz_prefix )
int
canc
=
vlc_savecancel
();
memset
(
&
psz_name
,
0
,
sizeof
(
psz_name
)
);
if
(
vlc_
internals
(
p_this
)
->
psz_object_name
)
if
(
vlc_
object_get_name
(
p_this
)
)
{
snprintf
(
psz_name
,
49
,
"
\"
%s
\"
"
,
vlc_
internals
(
p_this
)
->
psz_object_name
);
vlc_
object_get_name
(
p_this
)
);
if
(
psz_name
[
48
]
)
psz_name
[
48
]
=
'\"'
;
}
...
...
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