Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
7e6c2325
Commit
7e6c2325
authored
Feb 09, 2010
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
var_GetAndSet: implement OR and NAND, return new value
parent
94b463ab
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
22 deletions
+50
-22
include/vlc_variables.h
include/vlc_variables.h
+36
-18
src/misc/variables.c
src/misc/variables.c
+14
-4
No files found.
include/vlc_variables.h
View file @
7e6c2325
...
...
@@ -117,16 +117,12 @@
* These are the different actions that can be used with var_GetAndSet()
* @{
*/
/**
* Toggle the value of this boolean
* \param val Unused
*/
#define VLC_VAR_TOGGLE_BOOL 0x0010
/**
* Increment or decrement an integer of a given value
* \param val the value
*/
#define VLC_VAR_INTEGER_INCDEC 0x0020
enum
{
VLC_VAR_BOOL_TOGGLE
,
/**< Invert a boolean value (param ignored) */
VLC_VAR_INTEGER_ADD
,
/**< Add parameter to an integer value */
VLC_VAR_INTEGER_OR
,
/**< Binary OR over an integer bits field */
VLC_VAR_INTEGER_NAND
,
/**< Binary NAND over an integer bits field */
};
/**@}*/
/*****************************************************************************
...
...
@@ -152,8 +148,7 @@ VLC_EXPORT( int, var_Get, ( vlc_object_t *, const char *, vlc_value_t * ) );
VLC_EXPORT
(
int
,
var_SetChecked
,
(
vlc_object_t
*
,
const
char
*
,
int
,
vlc_value_t
)
);
VLC_EXPORT
(
int
,
var_GetChecked
,
(
vlc_object_t
*
,
const
char
*
,
int
,
vlc_value_t
*
)
);
VLC_EXPORT
(
int
,
var_GetAndSet
,
(
vlc_object_t
*
,
const
char
*
,
int
,
vlc_value_t
)
);
#define var_GetAndSet(a,b,c,d) var_GetAndSet(VLC_OBJECT(a), b, c, d)
VLC_EXPORT
(
int
,
var_GetAndSet
,
(
vlc_object_t
*
,
const
char
*
,
int
,
vlc_value_t
*
)
);
VLC_EXPORT
(
int
,
var_Inherit
,
(
vlc_object_t
*
,
const
char
*
,
int
,
vlc_value_t
*
)
);
...
...
@@ -385,11 +380,12 @@ static inline void *var_GetAddress( vlc_object_t *p_obj, const char *psz_name )
* \param p_obj the object that holds the variable
* \param psz_name the name of the variable
*/
static
inline
void
var_IncInteger
(
vlc_object_t
*
p_obj
,
const
char
*
psz_name
)
static
inline
int
var_IncInteger
(
vlc_object_t
*
p_obj
,
const
char
*
psz_name
)
{
vlc_value_t
val
;
val
.
i_int
=
1
;
var_GetAndSet
(
p_obj
,
psz_name
,
VLC_VAR_INTEGER_INCDEC
,
val
);
var_GetAndSet
(
p_obj
,
psz_name
,
VLC_VAR_INTEGER_ADD
,
&
val
);
return
val
.
i_int
;
}
#define var_IncInteger(a,b) var_IncInteger( VLC_OBJECT(a), b )
...
...
@@ -398,14 +394,35 @@ static inline void var_IncInteger( vlc_object_t *p_obj, const char *psz_name )
* \param p_obj the object that holds the variable
* \param psz_name the name of the variable
*/
static
inline
void
var_DecInteger
(
vlc_object_t
*
p_obj
,
const
char
*
psz_name
)
static
inline
int
var_DecInteger
(
vlc_object_t
*
p_obj
,
const
char
*
psz_name
)
{
vlc_value_t
val
;
val
.
i_int
=
-
1
;
var_GetAndSet
(
p_obj
,
psz_name
,
VLC_VAR_INTEGER_INCDEC
,
val
);
var_GetAndSet
(
p_obj
,
psz_name
,
VLC_VAR_INTEGER_ADD
,
&
val
);
return
val
.
i_int
;
}
#define var_DecInteger(a,b) var_DecInteger( VLC_OBJECT(a), b )
static
inline
unsigned
var_OrInteger
(
vlc_object_t
*
obj
,
const
char
*
name
,
unsigned
v
)
{
vlc_value_t
val
;
val
.
i_int
=
v
;
var_GetAndSet
(
obj
,
name
,
VLC_VAR_INTEGER_OR
,
&
val
);
return
val
.
i_int
;
}
#define var_OrInteger(a,b,c) var_OrInteger(VLC_OBJECT(a),b,c)
static
inline
unsigned
var_NAndInteger
(
vlc_object_t
*
obj
,
const
char
*
name
,
unsigned
v
)
{
vlc_value_t
val
;
val
.
i_int
=
v
;
var_GetAndSet
(
obj
,
name
,
VLC_VAR_INTEGER_NAND
,
&
val
);
return
val
.
i_int
;
}
#define var_NAndInteger(a,b,c) var_NAndInteger(VLC_OBJECT(a),b,c)
/**
* Create a integer variable with inherit and get its value.
*
...
...
@@ -600,10 +617,11 @@ static inline int var_CountChoices( vlc_object_t *p_obj, const char *psz_name )
#define var_CountChoices(a,b) var_CountChoices( VLC_OBJECT(a),b)
static
inline
int
var_ToggleBool
(
vlc_object_t
*
p_obj
,
const
char
*
psz_name
)
static
inline
bool
var_ToggleBool
(
vlc_object_t
*
p_obj
,
const
char
*
psz_name
)
{
vlc_value_t
val
;
return
var_GetAndSet
(
p_obj
,
psz_name
,
VLC_VAR_TOGGLE_BOOL
,
val
);
var_GetAndSet
(
p_obj
,
psz_name
,
VLC_VAR_BOOL_TOGGLE
,
&
val
);
return
val
.
b_bool
;
}
#define var_ToggleBool(a,b) var_ToggleBool( VLC_OBJECT(a),b )
...
...
src/misc/variables.c
View file @
7e6c2325
...
...
@@ -634,13 +634,14 @@ int var_Change( vlc_object_t *p_this, const char *psz_name,
* \return vlc error codes
*/
int
var_GetAndSet
(
vlc_object_t
*
p_this
,
const
char
*
psz_name
,
int
i_action
,
vlc_value_t
val
)
vlc_value_t
*
p_
val
)
{
int
i_ret
;
variable_t
*
p_var
;
vlc_value_t
oldval
;
assert
(
p_this
);
assert
(
p_val
);
vlc_object_internals_t
*
p_priv
=
vlc_internals
(
p_this
);
...
...
@@ -663,13 +664,21 @@ int var_GetAndSet( vlc_object_t *p_this, const char *psz_name, int i_action,
/* depending of the action requiered */
switch
(
i_action
)
{
case
VLC_VAR_
TOGGLE_BOOL
:
case
VLC_VAR_
BOOL_TOGGLE
:
assert
(
(
p_var
->
i_type
&
VLC_VAR_BOOL
)
==
VLC_VAR_BOOL
);
p_var
->
val
.
b_bool
=
!
p_var
->
val
.
b_bool
;
break
;
case
VLC_VAR_INTEGER_
INCDEC
:
case
VLC_VAR_INTEGER_
ADD
:
assert
(
(
p_var
->
i_type
&
VLC_VAR_INTEGER
)
==
VLC_VAR_INTEGER
);
p_var
->
val
.
i_int
+=
val
.
i_int
;
p_var
->
val
.
i_int
+=
p_val
->
i_int
;
break
;
case
VLC_VAR_INTEGER_OR
:
assert
(
(
p_var
->
i_type
&
VLC_VAR_INTEGER
)
==
VLC_VAR_INTEGER
);
p_var
->
val
.
i_int
|=
p_val
->
i_int
;
break
;
case
VLC_VAR_INTEGER_NAND
:
assert
(
(
p_var
->
i_type
&
VLC_VAR_INTEGER
)
==
VLC_VAR_INTEGER
);
p_var
->
val
.
i_int
&=
~
p_val
->
i_int
;
break
;
default:
vlc_mutex_unlock
(
&
p_priv
->
var_lock
);
...
...
@@ -678,6 +687,7 @@ int var_GetAndSet( vlc_object_t *p_this, const char *psz_name, int i_action,
/* Check boundaries */
CheckValue
(
p_var
,
&
p_var
->
val
);
*
p_val
=
p_var
->
val
;
/* Deal with callbacks.*/
i_ret
=
TriggerCallback
(
p_this
,
p_var
,
psz_name
,
oldval
);
...
...
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