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
689613d3
Commit
689613d3
authored
Nov 10, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
puzzle: use atomic variables and flag instead of lock
parent
2db07444
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
36 deletions
+21
-36
modules/video_filter/puzzle.c
modules/video_filter/puzzle.c
+21
-36
No files found.
modules/video_filter/puzzle.c
View file @
689613d3
...
...
@@ -96,13 +96,12 @@ struct filter_sys_t
bool
b_finished
;
/* */
vlc_mutex_t
lock
;
bool
b_change
;
struct
{
int
i_cols
;
int
i_rows
;
bool
b_blackslot
;
atomic_flag
b_uptodate
;
atomic_bool
b_blackslot
;
atomic_uint
i_cols
;
atomic_uint
i_rows
;
}
change
;
};
...
...
@@ -151,14 +150,13 @@ static int Open( vlc_object_t *p_this )
p_sys
->
pi_order
=
NULL
;
vlc_mutex_init
(
&
p_sys
->
lock
);
p_sys
->
change
.
i_rows
=
var_CreateGetIntegerCommand
(
p_filter
,
CFG_PREFIX
"rows"
);
p_sys
->
change
.
i_cols
=
var_CreateGetIntegerCommand
(
p_filter
,
CFG_PREFIX
"cols"
);
p_sys
->
change
.
b_blackslot
=
var_CreateGetBoolCommand
(
p_filter
,
CFG_PREFIX
"black-slot"
);
p_sys
->
b_change
=
true
;
atomic_init
(
&
p_sys
->
change
.
i_rows
,
var_CreateGetIntegerCommand
(
p_filter
,
CFG_PREFIX
"rows"
)
);
atomic_init
(
&
p_sys
->
change
.
i_cols
,
var_CreateGetIntegerCommand
(
p_filter
,
CFG_PREFIX
"cols"
)
);
atomic_init
(
&
p_sys
->
change
.
b_blackslot
,
var_CreateGetBoolCommand
(
p_filter
,
CFG_PREFIX
"black-slot"
)
);
p_sys
->
change
.
b_uptodate
=
ATOMIC_FLAG_INIT
;
var_AddCallback
(
p_filter
,
CFG_PREFIX
"rows"
,
PuzzleCallback
,
p_sys
);
var_AddCallback
(
p_filter
,
CFG_PREFIX
"cols"
,
PuzzleCallback
,
p_sys
);
...
...
@@ -182,7 +180,6 @@ static void Close( vlc_object_t *p_this )
var_DelCallback
(
p_filter
,
CFG_PREFIX
"cols"
,
PuzzleCallback
,
p_sys
);
var_DelCallback
(
p_filter
,
CFG_PREFIX
"black-slot"
,
PuzzleCallback
,
p_sys
);
vlc_mutex_destroy
(
&
p_sys
->
lock
);
free
(
p_sys
->
pi_order
);
free
(
p_sys
);
...
...
@@ -203,17 +200,13 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
}
/* */
vlc_mutex_lock
(
&
p_sys
->
lock
);
if
(
p_sys
->
b_change
)
if
(
!
atomic_flag_test_and_set
(
&
p_sys
->
change
.
b_uptodate
)
)
{
p_sys
->
i_rows
=
p_sys
->
change
.
i_rows
;
p_sys
->
i_cols
=
p_sys
->
change
.
i_cols
;
p_sys
->
b_blackslot
=
p_sys
->
change
.
b_blackslot
;
p_sys
->
b_change
=
false
;
p_sys
->
i_rows
=
atomic_load
(
&
p_sys
->
change
.
i_rows
);
p_sys
->
i_cols
=
atomic_load
(
&
p_sys
->
change
.
i_cols
);
p_sys
->
b_blackslot
=
atomic_load
(
&
p_sys
->
change
.
b_blackslot
);
Shuffle
(
p_sys
);
}
vlc_mutex_unlock
(
&
p_sys
->
lock
);
/* */
const
int
i_rows
=
p_sys
->
i_rows
;
...
...
@@ -309,7 +302,7 @@ static int Mouse( filter_t *p_filter, vlc_mouse_t *p_mouse,
if
(
b_clicked
&&
p_new
->
i_x
<
SHUFFLE_WIDTH
&&
p_new
->
i_y
<
SHUFFLE_HEIGHT
)
{
p_sys
->
b_change
=
true
;
atomic_flag_clear
(
&
p_sys
->
change
.
b_uptodate
)
;
return
VLC_EGENERIC
;
}
else
...
...
@@ -359,23 +352,15 @@ static int PuzzleCallback( vlc_object_t *p_this, char const *psz_var,
void
*
p_data
)
{
VLC_UNUSED
(
p_this
);
VLC_UNUSED
(
oldval
);
filter_sys_t
*
p_sys
=
(
filter_sys_t
*
)
p_data
;
filter_sys_t
*
p_sys
=
p_data
;
vlc_mutex_lock
(
&
p_sys
->
lock
);
if
(
!
strcmp
(
psz_var
,
CFG_PREFIX
"rows"
)
)
{
p_sys
->
change
.
i_rows
=
__MAX
(
1
,
newval
.
i_int
);
}
atomic_store
(
&
p_sys
->
change
.
i_rows
,
__MAX
(
1
,
newval
.
i_int
)
);
else
if
(
!
strcmp
(
psz_var
,
CFG_PREFIX
"cols"
)
)
{
p_sys
->
change
.
i_cols
=
__MAX
(
1
,
newval
.
i_int
);
}
atomic_store
(
&
p_sys
->
change
.
i_cols
,
__MAX
(
1
,
newval
.
i_int
)
);
else
if
(
!
strcmp
(
psz_var
,
CFG_PREFIX
"black-slot"
)
)
{
p_sys
->
change
.
b_blackslot
=
newval
.
b_bool
;
}
p_sys
->
b_change
=
true
;
vlc_mutex_unlock
(
&
p_sys
->
lock
);
atomic_store
(
&
p_sys
->
change
.
b_blackslot
,
newval
.
b_bool
);
atomic_flag_clear
(
&
p_sys
->
change
.
b_uptodate
);
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