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
c4cd36ee
Commit
c4cd36ee
authored
Aug 04, 2014
by
Felix Abecassis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
variables: add internal type callback_table_t for storing a list of callbacks
parent
f8187680
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
22 deletions
+29
-22
src/misc/objects.c
src/misc/objects.c
+2
-2
src/misc/variables.c
src/misc/variables.c
+19
-16
src/misc/variables.h
src/misc/variables.h
+8
-4
No files found.
src/misc/objects.c
View file @
c4cd36ee
...
@@ -603,8 +603,8 @@ static void DumpVariable (const void *data, const VISIT which, const int depth)
...
@@ -603,8 +603,8 @@ static void DumpVariable (const void *data, const VISIT which, const int depth)
fputs
(
", has choices"
,
stdout
);
fputs
(
", has choices"
,
stdout
);
if
(
p_var
->
i_type
&
VLC_VAR_ISCOMMAND
)
if
(
p_var
->
i_type
&
VLC_VAR_ISCOMMAND
)
fputs
(
", command"
,
stdout
);
fputs
(
", command"
,
stdout
);
if
(
p_var
->
i_entries
)
if
(
p_var
->
value_callbacks
.
i_entries
)
printf
(
", %d callbacks"
,
p_var
->
i_entries
);
printf
(
", %d callbacks"
,
p_var
->
value_callbacks
.
i_entries
);
switch
(
p_var
->
i_type
&
VLC_VAR_CLASS
)
switch
(
p_var
->
i_type
&
VLC_VAR_CLASS
)
{
{
case
VLC_VAR_VOID
:
case
VLC_VAR_VOID
:
...
...
src/misc/variables.c
View file @
c4cd36ee
...
@@ -169,10 +169,11 @@ static void Destroy( variable_t *p_var )
...
@@ -169,10 +169,11 @@ static void Destroy( variable_t *p_var )
free
(
p_var
->
choices_text
.
p_values
);
free
(
p_var
->
choices_text
.
p_values
);
}
}
#if 0 // ndef NDEBUG
#if 0 // ndef NDEBUG
for (int i = 0; i < p_var->i_entries; i++)
callback_table_t *p_table = &p_var->value_callbacks;
for (int i = 0; i < p_table->i_entries; i++)
{
{
const char *file = "?", *symbol = "?";
const char *file = "?", *symbol = "?";
const void *addr = p_
var
->p_entries[i].pf_callback;
const void *addr = p_
table
->p_entries[i].pf_callback;
# ifdef __GLIBC__
# ifdef __GLIBC__
Dl_info info;
Dl_info info;
...
@@ -189,7 +190,7 @@ static void Destroy( variable_t *p_var )
...
@@ -189,7 +190,7 @@ static void Destroy( variable_t *p_var )
free
(
p_var
->
psz_name
);
free
(
p_var
->
psz_name
);
free
(
p_var
->
psz_text
);
free
(
p_var
->
psz_text
);
free
(
p_var
->
p_entries
);
free
(
p_var
->
value_callbacks
.
p_entries
);
free
(
p_var
);
free
(
p_var
);
}
}
...
@@ -228,8 +229,7 @@ int var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )
...
@@ -228,8 +229,7 @@ int var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )
p_var
->
choices_text
.
p_values
=
NULL
;
p_var
->
choices_text
.
p_values
=
NULL
;
p_var
->
b_incallback
=
false
;
p_var
->
b_incallback
=
false
;
p_var
->
i_entries
=
0
;
p_var
->
value_callbacks
=
(
callback_table_t
){
0
};
p_var
->
p_entries
=
NULL
;
/* Always initialize the variable, even if it is a list variable; this
/* Always initialize the variable, even if it is a list variable; this
* will lead to errors if the variable is not initialized, but it will
* will lead to errors if the variable is not initialized, but it will
...
@@ -825,10 +825,11 @@ static int AddCallback( vlc_object_t *p_this, const char *psz_name,
...
@@ -825,10 +825,11 @@ static int AddCallback( vlc_object_t *p_this, const char *psz_name,
}
}
WaitUnused
(
p_this
,
p_var
);
WaitUnused
(
p_this
,
p_var
);
INSERT_ELEM
(
p_var
->
p_entries
,
callback_table_t
*
p_table
=
&
p_var
->
value_callbacks
;
p_var
->
i_entries
,
INSERT_ELEM
(
p_table
->
p_entries
,
p_var
->
i_entries
,
p_table
->
i_entries
,
entry
);
p_table
->
i_entries
,
entry
);
vlc_mutex_unlock
(
&
p_priv
->
var_lock
);
vlc_mutex_unlock
(
&
p_priv
->
var_lock
);
...
@@ -886,15 +887,16 @@ static int DelCallback( vlc_object_t *p_this, const char *psz_name,
...
@@ -886,15 +887,16 @@ static int DelCallback( vlc_object_t *p_this, const char *psz_name,
WaitUnused
(
p_this
,
p_var
);
WaitUnused
(
p_this
,
p_var
);
for
(
i_entry
=
p_var
->
i_entries
;
i_entry
--
;
)
callback_table_t
*
p_table
=
&
p_var
->
value_callbacks
;
for
(
i_entry
=
p_table
->
i_entries
;
i_entry
--
;
)
{
{
if
(
p_
var
->
p_entries
[
i_entry
].
pf_callback
==
entry
.
pf_callback
if
(
p_
table
->
p_entries
[
i_entry
].
pf_callback
==
entry
.
pf_callback
&&
p_
var
->
p_entries
[
i_entry
].
p_data
==
entry
.
p_data
)
&&
p_
table
->
p_entries
[
i_entry
].
p_data
==
entry
.
p_data
)
{
{
break
;
break
;
}
}
#ifndef NDEBUG
#ifndef NDEBUG
else
if
(
p_
var
->
p_entries
[
i_entry
].
pf_callback
==
entry
.
pf_callback
)
else
if
(
p_
table
->
p_entries
[
i_entry
].
pf_callback
==
entry
.
pf_callback
)
b_found_similar
=
true
;
b_found_similar
=
true
;
#endif
#endif
}
}
...
@@ -911,7 +913,7 @@ static int DelCallback( vlc_object_t *p_this, const char *psz_name,
...
@@ -911,7 +913,7 @@ static int DelCallback( vlc_object_t *p_this, const char *psz_name,
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
REMOVE_ELEM
(
p_
var
->
p_entries
,
p_var
->
i_entries
,
i_entry
);
REMOVE_ELEM
(
p_
table
->
p_entries
,
p_table
->
i_entries
,
i_entry
);
vlc_mutex_unlock
(
&
p_priv
->
var_lock
);
vlc_mutex_unlock
(
&
p_priv
->
var_lock
);
...
@@ -1317,11 +1319,12 @@ static int TriggerCallback( vlc_object_t *p_this, variable_t *p_var,
...
@@ -1317,11 +1319,12 @@ static int TriggerCallback( vlc_object_t *p_this, variable_t *p_var,
{
{
assert
(
p_this
);
assert
(
p_this
);
int
i_entries
=
p_var
->
i_entries
;
callback_table_t
*
p_table
=
&
p_var
->
value_callbacks
;
int
i_entries
=
p_table
->
i_entries
;
if
(
i_entries
==
0
)
if
(
i_entries
==
0
)
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
callback_entry_t
*
p_entries
=
p_
var
->
p_entries
;
callback_entry_t
*
p_entries
=
p_
table
->
p_entries
;
vlc_object_internals_t
*
p_priv
=
vlc_internals
(
p_this
);
vlc_object_internals_t
*
p_priv
=
vlc_internals
(
p_this
);
assert
(
!
p_var
->
b_incallback
);
assert
(
!
p_var
->
b_incallback
);
...
...
src/misc/variables.h
View file @
c4cd36ee
...
@@ -66,6 +66,12 @@ typedef struct variable_ops_t
...
@@ -66,6 +66,12 @@ typedef struct variable_ops_t
void
(
*
pf_free
)
(
vlc_value_t
*
);
void
(
*
pf_free
)
(
vlc_value_t
*
);
}
variable_ops_t
;
}
variable_ops_t
;
typedef
struct
callback_table_t
{
int
i_entries
;
callback_entry_t
*
p_entries
;
}
callback_table_t
;
/**
/**
* The structure describing a variable.
* The structure describing a variable.
* \note vlc_value_t is the common union for variable values
* \note vlc_value_t is the common union for variable values
...
@@ -99,10 +105,8 @@ struct variable_t
...
@@ -99,10 +105,8 @@ struct variable_t
/** Set to TRUE if the variable is in a callback */
/** Set to TRUE if the variable is in a callback */
bool
b_incallback
;
bool
b_incallback
;
/** Number of registered callbacks */
/** Registered value callbacks */
int
i_entries
;
callback_table_t
value_callbacks
;
/** Array of registered callbacks */
callback_entry_t
*
p_entries
;
};
};
extern
void
var_DestroyAll
(
vlc_object_t
*
);
extern
void
var_DestroyAll
(
vlc_object_t
*
);
...
...
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