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
62daf8e8
Commit
62daf8e8
authored
Nov 10, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mirror: use atomic variables instead of lock
parent
5ba31909
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
34 deletions
+22
-34
modules/video_filter/mirror.c
modules/video_filter/mirror.c
+22
-34
No files found.
modules/video_filter/mirror.c
View file @
62daf8e8
...
...
@@ -29,10 +29,11 @@
# include "config.h"
#endif
#include <assert.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <assert.h>
#include <vlc_atomic.h>
#include <vlc_filter.h>
#include "filter_picture.h"
...
...
@@ -102,9 +103,8 @@ static int FilterCallback( vlc_object_t *, char const *,
*****************************************************************************/
struct
filter_sys_t
{
int
i_split
;
int
i_direction
;
vlc_mutex_t
lock
;
atomic_int
i_split
;
atomic_int
i_direction
;
};
/*****************************************************************************
...
...
@@ -146,14 +146,14 @@ static int Create( vlc_object_t *p_this )
config_ChainParse
(
p_filter
,
CFG_PREFIX
,
ppsz_filter_options
,
p_filter
->
p_cfg
);
p_sys
->
i_split
=
var_CreateGetIntegerCommand
(
p_filter
,
CFG_PREFIX
"split"
);
p_sys
->
i_direction
=
var_CreateGetIntegerCommand
(
p_filter
,
CFG_PREFIX
"direction"
);
vlc_mutex_init
(
&
p_sys
->
lock
);
atomic_init
(
&
p_sys
->
i_split
,
var_CreateGetIntegerCommand
(
p_filter
,
CFG_PREFIX
"split"
)
);
atomic_init
(
&
p_sys
->
i_direction
,
var_CreateGetIntegerCommand
(
p_filter
,
CFG_PREFIX
"direction"
)
);
var_AddCallback
(
p_filter
,
CFG_PREFIX
"split"
,
FilterCallback
,
NULL
);
var_AddCallback
(
p_filter
,
CFG_PREFIX
"direction"
,
FilterCallback
,
NULL
);
var_AddCallback
(
p_filter
,
CFG_PREFIX
"split"
,
FilterCallback
,
p_sys
);
var_AddCallback
(
p_filter
,
CFG_PREFIX
"direction"
,
FilterCallback
,
p_sys
);
p_filter
->
pf_video_filter
=
Filter
;
...
...
@@ -168,12 +168,11 @@ static int Create( vlc_object_t *p_this )
static
void
Destroy
(
vlc_object_t
*
p_this
)
{
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
var_DelCallback
(
p_filter
,
CFG_PREFIX
"split"
,
FilterCallback
,
NULL
);
var_DelCallback
(
p_filter
,
CFG_PREFIX
"direction"
,
FilterCallback
,
NULL
);
vlc_mutex_destroy
(
&
p_filter
->
p_sys
->
lock
);
free
(
p_filter
->
p_sys
);
var_DelCallback
(
p_filter
,
CFG_PREFIX
"split"
,
FilterCallback
,
p_sys
);
var_DelCallback
(
p_filter
,
CFG_PREFIX
"direction"
,
FilterCallback
,
p_sys
);
free
(
p_sys
);
}
/*****************************************************************************
...
...
@@ -192,10 +191,8 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
if
(
!
p_pic
)
return
NULL
;
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
vlc_mutex_lock
(
&
p_sys
->
lock
);
b_vertical_split
=
p_sys
->
i_split
==
0
?
true
:
false
;
b_left_to_right
=
p_sys
->
i_direction
==
0
?
true
:
false
;
vlc_mutex_unlock
(
&
p_sys
->
lock
);
b_vertical_split
=
!
atomic_load
(
&
p_sys
->
i_split
);
b_left_to_right
=
!
atomic_load
(
&
p_sys
->
i_direction
);
p_outpic
=
filter_NewPicture
(
p_filter
);
if
(
!
p_outpic
)
...
...
@@ -592,22 +589,13 @@ static void HorizontalMirror( picture_t *p_pic, picture_t *p_outpic, int i_plane
static
int
FilterCallback
(
vlc_object_t
*
p_this
,
char
const
*
psz_var
,
vlc_value_t
oldval
,
vlc_value_t
newval
,
void
*
p_data
)
{
(
void
)
oldval
;
(
void
)
p_data
;
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
(
void
)
p_this
;
(
void
)
oldval
;
filter_sys_t
*
p_sys
=
p_data
;
if
(
!
strcmp
(
psz_var
,
CFG_PREFIX
"split"
)
)
{
vlc_mutex_lock
(
&
p_sys
->
lock
);
p_sys
->
i_split
=
newval
.
i_int
;
vlc_mutex_unlock
(
&
p_sys
->
lock
);
}
atomic_store
(
&
p_sys
->
i_split
,
newval
.
i_int
);
else
/* CFG_PREFIX "direction" */
{
vlc_mutex_lock
(
&
p_sys
->
lock
);
p_sys
->
i_direction
=
newval
.
i_int
;
vlc_mutex_unlock
(
&
p_sys
->
lock
);
}
atomic_store
(
&
p_sys
->
i_direction
,
newval
.
i_int
);
return
VLC_SUCCESS
;
}
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