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
814d5303
Commit
814d5303
authored
Aug 14, 2013
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
picture: convert to standard atomic operations
parent
2c470d8d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
21 deletions
+19
-21
include/vlc_picture.h
include/vlc_picture.h
+1
-1
src/misc/picture.c
src/misc/picture.c
+8
-9
src/misc/picture_pool.c
src/misc/picture_pool.c
+10
-11
No files found.
include/vlc_picture.h
View file @
814d5303
...
@@ -102,7 +102,7 @@ struct picture_t
...
@@ -102,7 +102,7 @@ struct picture_t
/** This way the picture_Release can be overloaded */
/** This way the picture_Release can be overloaded */
struct
struct
{
{
vlc_atomic
_t
refcount
;
atomic_uintptr
_t
refcount
;
void
(
*
pf_destroy
)(
picture_t
*
);
void
(
*
pf_destroy
)(
picture_t
*
);
picture_gc_sys_t
*
p_sys
;
picture_gc_sys_t
*
p_sys
;
}
gc
;
}
gc
;
...
...
src/misc/picture.c
View file @
814d5303
...
@@ -37,7 +37,6 @@
...
@@ -37,7 +37,6 @@
#include <vlc_picture.h>
#include <vlc_picture.h>
#include <vlc_image.h>
#include <vlc_image.h>
#include <vlc_block.h>
#include <vlc_block.h>
#include <vlc_atomic.h>
/**
/**
* Allocate a new picture in the heap.
* Allocate a new picture in the heap.
...
@@ -100,7 +99,7 @@ static void PictureDestroyContext( picture_t *p_picture )
...
@@ -100,7 +99,7 @@ static void PictureDestroyContext( picture_t *p_picture )
static
void
PictureDestroy
(
picture_t
*
p_picture
)
static
void
PictureDestroy
(
picture_t
*
p_picture
)
{
{
assert
(
p_picture
&&
assert
(
p_picture
&&
vlc_atomic_get
(
&
p_picture
->
gc
.
refcount
)
==
0
);
atomic_load
(
&
p_picture
->
gc
.
refcount
)
==
0
);
vlc_free
(
p_picture
->
gc
.
p_sys
);
vlc_free
(
p_picture
->
gc
.
p_sys
);
free
(
p_picture
->
p_sys
);
free
(
p_picture
->
p_sys
);
...
@@ -141,7 +140,7 @@ int picture_Setup( picture_t *p_picture, vlc_fourcc_t i_chroma,
...
@@ -141,7 +140,7 @@ int picture_Setup( picture_t *p_picture, vlc_fourcc_t i_chroma,
p
->
i_pixel_pitch
=
0
;
p
->
i_pixel_pitch
=
0
;
}
}
vlc_atomic_se
t
(
&
p_picture
->
gc
.
refcount
,
0
);
atomic_ini
t
(
&
p_picture
->
gc
.
refcount
,
0
);
p_picture
->
gc
.
pf_destroy
=
NULL
;
p_picture
->
gc
.
pf_destroy
=
NULL
;
p_picture
->
gc
.
p_sys
=
NULL
;
p_picture
->
gc
.
p_sys
=
NULL
;
...
@@ -248,7 +247,7 @@ picture_t *picture_NewFromResource( const video_format_t *p_fmt, const picture_r
...
@@ -248,7 +247,7 @@ picture_t *picture_NewFromResource( const video_format_t *p_fmt, const picture_r
/* */
/* */
p_picture
->
format
=
fmt
;
p_picture
->
format
=
fmt
;
vlc_atomic_se
t
(
&
p_picture
->
gc
.
refcount
,
1
);
atomic_ini
t
(
&
p_picture
->
gc
.
refcount
,
1
);
if
(
p_picture
->
gc
.
pf_destroy
==
NULL
)
if
(
p_picture
->
gc
.
pf_destroy
==
NULL
)
p_picture
->
gc
.
pf_destroy
=
PictureDestroy
;
p_picture
->
gc
.
pf_destroy
=
PictureDestroy
;
...
@@ -277,15 +276,15 @@ picture_t *picture_New( vlc_fourcc_t i_chroma, int i_width, int i_height, int i_
...
@@ -277,15 +276,15 @@ picture_t *picture_New( vlc_fourcc_t i_chroma, int i_width, int i_height, int i_
picture_t
*
picture_Hold
(
picture_t
*
p_picture
)
picture_t
*
picture_Hold
(
picture_t
*
p_picture
)
{
{
vlc_atomic_inc
(
&
p_picture
->
gc
.
refcount
);
atomic_fetch_add
(
&
p_picture
->
gc
.
refcount
,
1
);
return
p_picture
;
return
p_picture
;
}
}
void
picture_Release
(
picture_t
*
p_picture
)
void
picture_Release
(
picture_t
*
p_picture
)
{
{
uintptr_t
refs
=
vlc_atomic_dec
(
&
p_picture
->
gc
.
refcount
);
uintptr_t
refs
=
atomic_fetch_sub
(
&
p_picture
->
gc
.
refcount
,
1
);
assert
(
refs
!=
(
uintptr_t
)
-
1
);
assert
(
refs
!=
0
);
if
(
refs
>
0
)
if
(
refs
>
1
)
return
;
return
;
PictureDestroyContext
(
p_picture
);
PictureDestroyContext
(
p_picture
);
...
@@ -295,7 +294,7 @@ void picture_Release( picture_t *p_picture )
...
@@ -295,7 +294,7 @@ void picture_Release( picture_t *p_picture )
bool
picture_IsReferenced
(
picture_t
*
p_picture
)
bool
picture_IsReferenced
(
picture_t
*
p_picture
)
{
{
return
vlc_atomic_get
(
&
p_picture
->
gc
.
refcount
)
>
1
;
return
atomic_load
(
&
p_picture
->
gc
.
refcount
)
>
1
;
}
}
/*****************************************************************************
/*****************************************************************************
...
...
src/misc/picture_pool.c
View file @
814d5303
...
@@ -33,7 +33,6 @@
...
@@ -33,7 +33,6 @@
#include <vlc_common.h>
#include <vlc_common.h>
#include <vlc_picture_pool.h>
#include <vlc_picture_pool.h>
#include <vlc_atomic.h>
/*****************************************************************************
/*****************************************************************************
*
*
...
@@ -108,7 +107,7 @@ picture_pool_t *picture_pool_NewExtended(const picture_pool_configuration_t *cfg
...
@@ -108,7 +107,7 @@ picture_pool_t *picture_pool_NewExtended(const picture_pool_configuration_t *cfg
gc_sys
->
tick
=
0
;
gc_sys
->
tick
=
0
;
/* */
/* */
vlc_atomic_se
t
(
&
picture
->
gc
.
refcount
,
0
);
atomic_ini
t
(
&
picture
->
gc
.
refcount
,
0
);
picture
->
gc
.
pf_destroy
=
Destroy
;
picture
->
gc
.
pf_destroy
=
Destroy
;
picture
->
gc
.
p_sys
=
gc_sys
;
picture
->
gc
.
p_sys
=
gc_sys
;
...
@@ -166,7 +165,7 @@ picture_pool_t *picture_pool_Reserve(picture_pool_t *master, int count)
...
@@ -166,7 +165,7 @@ picture_pool_t *picture_pool_Reserve(picture_pool_t *master, int count)
if
(
master
->
picture_reserved
[
i
])
if
(
master
->
picture_reserved
[
i
])
continue
;
continue
;
assert
(
vlc_atomic_get
(
&
master
->
picture
[
i
]
->
gc
.
refcount
)
==
0
);
assert
(
atomic_load
(
&
master
->
picture
[
i
]
->
gc
.
refcount
)
==
0
);
master
->
picture_reserved
[
i
]
=
true
;
master
->
picture_reserved
[
i
]
=
true
;
pool
->
picture
[
found
]
=
master
->
picture
[
i
];
pool
->
picture
[
found
]
=
master
->
picture
[
i
];
...
@@ -192,11 +191,11 @@ void picture_pool_Delete(picture_pool_t *pool)
...
@@ -192,11 +191,11 @@ void picture_pool_Delete(picture_pool_t *pool)
}
else
{
}
else
{
picture_gc_sys_t
*
gc_sys
=
picture
->
gc
.
p_sys
;
picture_gc_sys_t
*
gc_sys
=
picture
->
gc
.
p_sys
;
assert
(
vlc_atomic_get
(
&
picture
->
gc
.
refcount
)
==
0
);
assert
(
atomic_load
(
&
picture
->
gc
.
refcount
)
==
0
);
assert
(
!
pool
->
picture_reserved
[
i
]);
assert
(
!
pool
->
picture_reserved
[
i
]);
/* Restore old release callback */
/* Restore old release callback */
vlc_atomic_se
t
(
&
picture
->
gc
.
refcount
,
1
);
atomic_ini
t
(
&
picture
->
gc
.
refcount
,
1
);
picture
->
gc
.
pf_destroy
=
gc_sys
->
destroy
;
picture
->
gc
.
pf_destroy
=
gc_sys
->
destroy
;
picture
->
gc
.
p_sys
=
gc_sys
->
destroy_sys
;
picture
->
gc
.
p_sys
=
gc_sys
->
destroy_sys
;
...
@@ -217,7 +216,7 @@ picture_t *picture_pool_Get(picture_pool_t *pool)
...
@@ -217,7 +216,7 @@ picture_t *picture_pool_Get(picture_pool_t *pool)
continue
;
continue
;
picture_t
*
picture
=
pool
->
picture
[
i
];
picture_t
*
picture
=
pool
->
picture
[
i
];
if
(
vlc_atomic_get
(
&
picture
->
gc
.
refcount
)
>
0
)
if
(
atomic_load
(
&
picture
->
gc
.
refcount
)
>
0
)
continue
;
continue
;
if
(
Lock
(
picture
))
if
(
Lock
(
picture
))
...
@@ -242,19 +241,19 @@ void picture_pool_NonEmpty(picture_pool_t *pool, bool reset)
...
@@ -242,19 +241,19 @@ void picture_pool_NonEmpty(picture_pool_t *pool, bool reset)
picture_t
*
picture
=
pool
->
picture
[
i
];
picture_t
*
picture
=
pool
->
picture
[
i
];
if
(
reset
)
{
if
(
reset
)
{
if
(
vlc_atomic_get
(
&
picture
->
gc
.
refcount
)
>
0
)
if
(
atomic_load
(
&
picture
->
gc
.
refcount
)
>
0
)
Unlock
(
picture
);
Unlock
(
picture
);
vlc_atomic_set
(
&
picture
->
gc
.
refcount
,
0
);
atomic_store
(
&
picture
->
gc
.
refcount
,
0
);
}
else
if
(
vlc_atomic_get
(
&
picture
->
gc
.
refcount
)
==
0
)
{
}
else
if
(
atomic_load
(
&
picture
->
gc
.
refcount
)
==
0
)
{
return
;
return
;
}
else
if
(
!
old
||
picture
->
gc
.
p_sys
->
tick
<
old
->
gc
.
p_sys
->
tick
)
{
}
else
if
(
!
old
||
picture
->
gc
.
p_sys
->
tick
<
old
->
gc
.
p_sys
->
tick
)
{
old
=
picture
;
old
=
picture
;
}
}
}
}
if
(
!
reset
&&
old
)
{
if
(
!
reset
&&
old
)
{
if
(
vlc_atomic_get
(
&
old
->
gc
.
refcount
)
>
0
)
if
(
atomic_load
(
&
old
->
gc
.
refcount
)
>
0
)
Unlock
(
old
);
Unlock
(
old
);
vlc_atomic_set
(
&
old
->
gc
.
refcount
,
0
);
atomic_store
(
&
old
->
gc
.
refcount
,
0
);
}
}
}
}
int
picture_pool_GetSize
(
picture_pool_t
*
pool
)
int
picture_pool_GetSize
(
picture_pool_t
*
pool
)
...
...
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