Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
GSoC
GSoC2018
macOS
vlc
Commits
c240692f
Commit
c240692f
authored
Jun 18, 2016
by
Rémi Denis-Courmont
Browse files
Common structure for VLC common object members, document
parent
70a05fb5
Changes
130
Hide whitespace changes
Inline
Side-by-side
include/vlc_common.h
View file @
c240692f
...
...
@@ -411,47 +411,86 @@ typedef int ( * vlc_list_callback_t ) ( vlc_object_t *, /* variable's objec
#include "vlc_mtime.h"
#include "vlc_threads.h"
/**
***************************************************************************
/**
* Common structure members
*****************************************************************************/
/* VLC_COMMON_MEMBERS : members common to all basic vlc objects */
#define VLC_COMMON_MEMBERS \
/** \name VLC_COMMON_MEMBERS \
* these members are common for all vlc objects \
*/
\
/**@{*/
\
const char *psz_object_type; \
\
/* Messages header */
\
char *psz_header; \
int i_flags; \
\
/* Object properties */
\
bool b_force;
/**< set by the outside (eg. module_need()) */
\
\
/* Stuff related to the libvlc structure */
\
libvlc_int_t *p_libvlc;
/**< (root of all evil) - 1 */
\
\
vlc_object_t * p_parent;
/**< our parent */
\
\
/**@}*/
\
/* VLC_OBJECT: attempt at doing a clever cast */
#if VLC_GCC_VERSION(4,0)
/**
* VLC object common members
*
* Common public properties for all VLC objects.
* Object also have private properties maintained by the core, see
* \ref vlc_object_internals_t
*/
struct
vlc_common_members
{
/** Object type name
*
* A constant string identifying the type of the object (for logging)
*/
const
char
*
object_type
;
/** Log messages header
*
* Human-readable header for log messages. This is not thread-safe and
* only used by VLM and Lua interfaces.
*/
char
*
header
;
int
flags
;
/** Module probe flag
*
* A boolean during module probing when the probe is "forced".
* See \ref module_need().
*/
bool
force
;
/** LibVLC instance
*
* Root VLC object of the objects tree that this object belongs in.
*/
libvlc_int_t
*
libvlc
;
/** Parent object
*
* The parent VLC object in the objects tree. For the root (the LibVLC
* instance) object, this is NULL.
*/
vlc_object_t
*
parent
;
};
/**
* Backward compatibility macro
*/
#define VLC_COMMON_MEMBERS struct vlc_common_members obj;
/**
* Type-safe vlc_object_t cast
*
* This macro attempts to cast a pointer to a compound type to a
* \ref vlc_object_t pointer in a type-safe manner.
* It checks if the compound type actually starts with an embedded
* \ref vlc_object_t structure.
*/
#if !defined(__cplusplus) && (__STDC_VERSION__ >= 201112L)
# define VLC_OBJECT(x) \
_Generic((x)->obj, \
struct vlc_common_members: (vlc_object_t *)(&(x)->obj) \
)
#elif VLC_GCC_VERSION(4,0)
# ifndef __cplusplus
# define VLC_OBJECT( x ) \
__builtin_choose_expr( \
__builtin_offsetof(__typeof__(*(x)), psz_object_type), \
(void)0
/* screw you */
, \
(vlc_object_t *)(x))
__builtin_types_compatible_p(__typeof__((x)->obj), struct vlc_common_members), \
(vlc_object_t *)(x), (void)0)
# else
# define VLC_OBJECT( x ) \
((vlc_object_t *)(
x
) \
+ 0 * __builtin_offsetof(__typeof__(*(x)),
psz_
object_type))
((vlc_object_t *)(
&((x)->obj)
) \
+ 0 * __builtin_offsetof(__typeof__(*(x)),
obj.
object_type))
# endif
#else
# define VLC_OBJECT( x ) ((vlc_object_t *)(x))
# define VLC_OBJECT( x ) ((vlc_object_t *)
&
(x)
->obj
)
#endif
/*****************************************************************************
...
...
include/vlc_interface.h
View file @
c240692f
...
...
@@ -92,7 +92,7 @@ VLC_API void libvlc_Quit( libvlc_int_t * );
static
inline
playlist_t
*
pl_Get
(
struct
intf_thread_t
*
intf
)
{
return
(
playlist_t
*
)(
intf
->
p_
parent
);
return
(
playlist_t
*
)(
intf
->
obj
.
parent
);
}
/**
...
...
lib/media_player.c
View file @
c240692f
...
...
@@ -739,7 +739,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
* FIXME: It's unclear why we want to put this in public API, and why we
* want to expose it in such a limiting and ugly way.
*/
var_AddCallback
(
mp
->
p_
libvlc
,
"snapshot-file"
,
snapshot_was_taken
,
mp
);
var_AddCallback
(
mp
->
obj
.
libvlc
,
"snapshot-file"
,
snapshot_was_taken
,
mp
);
libvlc_retain
(
instance
);
return
mp
;
...
...
@@ -773,7 +773,7 @@ static void libvlc_media_player_destroy( libvlc_media_player_t *p_mi )
assert
(
p_mi
);
/* Detach Callback from the main libvlc object */
var_DelCallback
(
p_mi
->
p_
libvlc
,
var_DelCallback
(
p_mi
->
obj
.
libvlc
,
"snapshot-file"
,
snapshot_was_taken
,
p_mi
);
/* Detach callback from the media player / input manager object */
...
...
modules/access/archive/access.c
View file @
c240692f
...
...
@@ -118,10 +118,10 @@ static int FindVolumes(access_t *p_access, struct archive *p_archive, const char
break
;
/* Probe URI */
int
i_savedflags
=
p_access
->
i_
flags
;
p_access
->
i_
flags
|=
OBJECT_FLAGS_NOINTERACT
;
int
i_savedflags
=
p_access
->
obj
.
flags
;
p_access
->
obj
.
flags
|=
OBJECT_FLAGS_NOINTERACT
;
stream_t
*
p_stream
=
stream_UrlNew
(
p_access
,
psz_newuri
);
p_access
->
i_
flags
=
i_savedflags
;
p_access
->
obj
.
flags
=
i_savedflags
;
if
(
p_stream
)
{
ppsz_files
[
*
pi_files
]
=
psz_newuri
;
...
...
modules/access/http/transport.c
View file @
c240692f
...
...
@@ -127,7 +127,7 @@ vlc_tls_t *vlc_https_connect(vlc_tls_creds_t *creds, const char *name,
if
(
port
==
0
)
port
=
443
;
int
fd
=
vlc_tcp_connect
(
creds
->
p_
parent
,
name
,
port
);
int
fd
=
vlc_tcp_connect
(
creds
->
obj
.
parent
,
name
,
port
);
if
(
fd
==
-
1
)
return
NULL
;
...
...
modules/access/http/tunnel.c
View file @
c240692f
...
...
@@ -151,7 +151,7 @@ vlc_tls_t *vlc_https_connect_proxy(vlc_tls_creds_t *creds,
sock
=
vlc_https_connect
(
creds
,
url
.
psz_host
,
url
.
i_port
,
&
ptwo
);
else
if
(
!
strcasecmp
(
url
.
psz_protocol
,
"http"
))
sock
=
vlc_http_connect
(
creds
?
creds
->
p_
parent
:
NULL
,
sock
=
vlc_http_connect
(
creds
?
creds
->
obj
.
parent
:
NULL
,
url
.
psz_host
,
url
.
i_port
);
else
sock
=
NULL
;
...
...
modules/access/idummy.c
View file @
c240692f
...
...
@@ -162,7 +162,7 @@ nop:
msg_Info
(
p_demux
,
"command `quit'"
);
p_demux
->
pf_demux
=
DemuxNoOp
;
p_demux
->
pf_control
=
DemuxControl
;
libvlc_Quit
(
p_demux
->
p_
libvlc
);
libvlc_Quit
(
p_demux
->
obj
.
libvlc
);
return
VLC_SUCCESS
;
}
...
...
modules/access/rar/rar.c
View file @
c240692f
...
...
@@ -394,10 +394,10 @@ int RarParse(stream_t *s, int *count, rar_file_t ***file, unsigned int *pi_nbvol
if
(
!
volume_mrl
)
return
VLC_SUCCESS
;
const
int
s_flags
=
s
->
i_
flags
;
s
->
i_
flags
|=
OBJECT_FLAGS_NOINTERACT
;
const
int
s_flags
=
s
->
obj
.
flags
;
s
->
obj
.
flags
|=
OBJECT_FLAGS_NOINTERACT
;
vol
=
stream_UrlNew
(
s
,
volume_mrl
);
s
->
i_
flags
=
s_flags
;
s
->
obj
.
flags
=
s_flags
;
if
(
!
vol
)
{
free
(
volume_mrl
);
...
...
modules/audio_filter/audiobargraph_a.c
View file @
c240692f
...
...
@@ -139,8 +139,8 @@ static int Open( vlc_object_t *p_this )
p_filter
->
fmt_out
.
audio
=
p_filter
->
fmt_in
.
audio
;
p_filter
->
pf_audio_filter
=
DoWork
;
var_Create
(
p_filter
->
p_
libvlc
,
"audiobargraph_v-alarm"
,
VLC_VAR_BOOL
);
var_Create
(
p_filter
->
p_
libvlc
,
"audiobargraph_v-i_values"
,
VLC_VAR_STRING
);
var_Create
(
p_filter
->
obj
.
libvlc
,
"audiobargraph_v-alarm"
,
VLC_VAR_BOOL
);
var_Create
(
p_filter
->
obj
.
libvlc
,
"audiobargraph_v-i_values"
,
VLC_VAR_STRING
);
return
VLC_SUCCESS
;
}
...
...
@@ -157,7 +157,7 @@ static void SendValues(filter_t *p_filter, float *value, int nbChannels)
}
//msg_Dbg(p_filter, "values: %s", message);
var_SetString
(
p_filter
->
p_
libvlc
,
"audiobargraph_v-i_values"
,
msg
);
var_SetString
(
p_filter
->
obj
.
libvlc
,
"audiobargraph_v-i_values"
,
msg
);
}
/*****************************************************************************
...
...
@@ -223,7 +223,7 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
sum
=
sqrtf
(
sum
);
/* 5 - compare it to the threshold */
var_SetBool
(
p_filter
->
p_
libvlc
,
"audiobargraph_v-alarm"
,
var_SetBool
(
p_filter
->
obj
.
libvlc
,
"audiobargraph_v-alarm"
,
sum
<
p_sys
->
alarm_threshold
);
p_sys
->
lastAlarm
=
p_in_buf
->
i_pts
;
...
...
@@ -246,8 +246,8 @@ static void Close( vlc_object_t *p_this )
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
var_Destroy
(
p_filter
->
p_
libvlc
,
"audiobargraph_v-i_values"
);
var_Destroy
(
p_filter
->
p_
libvlc
,
"audiobargraph_v-alarm"
);
var_Destroy
(
p_filter
->
obj
.
libvlc
,
"audiobargraph_v-i_values"
);
var_Destroy
(
p_filter
->
obj
.
libvlc
,
"audiobargraph_v-alarm"
);
while
(
p_sys
->
first
!=
NULL
)
{
ValueDate_t
*
current
=
p_sys
->
first
;
...
...
modules/audio_filter/compressor.c
View file @
c240692f
...
...
@@ -205,7 +205,7 @@ vlc_module_end ()
static
int
Open
(
vlc_object_t
*
p_this
)
{
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
vlc_object_t
*
p_aout
=
p_filter
->
p_
parent
;
vlc_object_t
*
p_aout
=
p_filter
->
obj
.
parent
;
float
f_sample_rate
=
p_filter
->
fmt_in
.
audio
.
i_rate
;
float
f_num
;
...
...
@@ -270,7 +270,7 @@ static int Open( vlc_object_t *p_this )
static
void
Close
(
vlc_object_t
*
p_this
)
{
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
vlc_object_t
*
p_aout
=
p_filter
->
p_
parent
;
vlc_object_t
*
p_aout
=
p_filter
->
obj
.
parent
;
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
/* Remove our callbacks */
...
...
modules/audio_filter/equalizer.c
View file @
c240692f
...
...
@@ -282,7 +282,7 @@ static int EqzInit( filter_t *p_filter, int i_rate )
eqz_config_t
cfg
;
int
i
,
ch
;
vlc_value_t
val1
,
val2
,
val3
;
vlc_object_t
*
p_aout
=
p_filter
->
p_
parent
;
vlc_object_t
*
p_aout
=
p_filter
->
obj
.
parent
;
int
i_ret
=
VLC_ENOMEM
;
bool
b_vlcFreqs
=
var_InheritBool
(
p_aout
,
"equalizer-vlcfreqs"
);
...
...
@@ -451,7 +451,7 @@ static void EqzFilter( filter_t *p_filter, float *out, float *in,
static
void
EqzClean
(
filter_t
*
p_filter
)
{
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
vlc_object_t
*
p_aout
=
p_filter
->
p_
parent
;
vlc_object_t
*
p_aout
=
p_filter
->
obj
.
parent
;
var_DelCallback
(
p_aout
,
"equalizer-bands"
,
BandsCallback
,
p_sys
);
var_DelCallback
(
p_aout
,
"equalizer-preset"
,
PresetCallback
,
p_sys
);
...
...
modules/audio_filter/gain.c
View file @
c240692f
...
...
@@ -93,7 +93,7 @@ static int Open( vlc_object_t *p_this )
return
VLC_EGENERIC
;
}
p_sys
->
f_gain
=
var_InheritFloat
(
p_filter
->
p_
parent
,
"gain-value"
);
p_sys
->
f_gain
=
var_InheritFloat
(
p_filter
->
obj
.
parent
,
"gain-value"
);
msg_Dbg
(
p_filter
,
"gain multiplier sets to %.2fx"
,
p_sys
->
f_gain
);
p_filter
->
fmt_out
.
audio
=
p_filter
->
fmt_in
.
audio
;
...
...
modules/audio_filter/normvol.c
View file @
c240692f
...
...
@@ -102,8 +102,10 @@ static int Open( vlc_object_t *p_this )
p_sys
=
p_filter
->
p_sys
=
malloc
(
sizeof
(
*
p_sys
)
);
if
(
!
p_sys
)
return
VLC_ENOMEM
;
p_sys
->
i_nb
=
var_CreateGetInteger
(
p_filter
->
p_parent
,
"norm-buff-size"
);
p_sys
->
f_max
=
var_CreateGetFloat
(
p_filter
->
p_parent
,
"norm-max-level"
);
p_sys
->
i_nb
=
var_CreateGetInteger
(
p_filter
->
obj
.
parent
,
"norm-buff-size"
);
p_sys
->
f_max
=
var_CreateGetFloat
(
p_filter
->
obj
.
parent
,
"norm-max-level"
);
if
(
p_sys
->
f_max
<=
0
)
p_sys
->
f_max
=
0
.
01
;
...
...
@@ -184,7 +186,8 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
f_average
=
f_average
/
p_sys
->
i_nb
;
/* Seuil arbitraire */
p_sys
->
f_max
=
var_GetFloat
(
p_filter
->
p_parent
,
"norm-max-level"
);
p_sys
->
f_max
=
var_GetFloat
(
p_filter
->
obj
.
parent
,
"norm-max-level"
);
//fprintf(stderr,"Average %f, max %f\n", f_average, p_sys->f_max );
if
(
f_average
>
p_sys
->
f_max
)
...
...
modules/audio_filter/spatializer/spatializer.cpp
View file @
c240692f
...
...
@@ -132,7 +132,7 @@ static int Open( vlc_object_t *p_this )
{
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
filter_sys_t
*
p_sys
;
vlc_object_t
*
p_aout
=
p_filter
->
p_
parent
;
vlc_object_t
*
p_aout
=
p_filter
->
obj
.
parent
;
/* Allocate structure */
p_sys
=
p_filter
->
p_sys
=
(
filter_sys_t
*
)
malloc
(
sizeof
(
*
p_sys
)
);
...
...
@@ -172,7 +172,7 @@ static void Close( vlc_object_t *p_this )
{
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
vlc_object_t
*
p_aout
=
p_filter
->
p_
parent
;
vlc_object_t
*
p_aout
=
p_filter
->
obj
.
parent
;
/* Delete the callbacks */
for
(
unsigned
i
=
0
;
i
<
num_callbacks
;
++
i
)
...
...
modules/codec/daala.c
View file @
c240692f
...
...
@@ -581,7 +581,7 @@ static int OpenEncoder( vlc_object_t *p_this )
int
status
;
if
(
p_enc
->
fmt_out
.
i_codec
!=
VLC_CODEC_DAALA
&&
!
p_enc
->
b_
force
)
!
p_enc
->
obj
.
force
)
{
return
VLC_EGENERIC
;
}
...
...
modules/codec/dvbsub.c
View file @
c240692f
...
...
@@ -1719,7 +1719,7 @@ static int OpenEncoder( vlc_object_t *p_this )
encoder_sys_t
*
p_sys
;
if
(
(
p_enc
->
fmt_out
.
i_codec
!=
VLC_CODEC_DVBS
)
&&
!
p_enc
->
b_
force
)
!
p_enc
->
obj
.
force
)
{
return
VLC_EGENERIC
;
}
...
...
modules/codec/flac.c
View file @
c240692f
...
...
@@ -669,7 +669,7 @@ static int OpenEncoder( vlc_object_t *p_this )
encoder_sys_t
*
p_sys
;
if
(
p_enc
->
fmt_out
.
i_codec
!=
VLC_CODEC_FLAC
&&
!
p_enc
->
b_
force
)
!
p_enc
->
obj
.
force
)
{
return
VLC_EGENERIC
;
}
...
...
modules/codec/rtpvideo.c
View file @
c240692f
...
...
@@ -53,7 +53,7 @@ vlc_module_end ()
static
int
OpenEncoder
(
vlc_object_t
*
p_this
)
{
encoder_t
*
p_enc
=
(
encoder_t
*
)
p_this
;
if
(
p_enc
->
fmt_out
.
i_codec
!=
VLC_CODEC_R420
&&
!
p_enc
->
b_
force
)
if
(
p_enc
->
fmt_out
.
i_codec
!=
VLC_CODEC_R420
&&
!
p_enc
->
obj
.
force
)
return
VLC_EGENERIC
;
p_enc
->
pf_encode_video
=
Encode
;
...
...
modules/codec/schroedinger.c
View file @
c240692f
...
...
@@ -1078,7 +1078,7 @@ static int OpenEncoder( vlc_object_t *p_this )
char
*
psz_tmp
;
if
(
p_enc
->
fmt_out
.
i_codec
!=
VLC_CODEC_DIRAC
&&
!
p_enc
->
b_
force
)
!
p_enc
->
obj
.
force
)
{
return
VLC_EGENERIC
;
}
...
...
modules/codec/speex.c
View file @
c240692f
...
...
@@ -957,7 +957,7 @@ static int OpenEncoder( vlc_object_t *p_this )
uint8_t
*
p_extra
;
if
(
p_enc
->
fmt_out
.
i_codec
!=
VLC_CODEC_SPEEX
&&
!
p_enc
->
b_
force
)
!
p_enc
->
obj
.
force
)
{
return
VLC_EGENERIC
;
}
...
...
Prev
1
2
3
4
5
…
7
Next
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