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
a1adede1
Commit
a1adede1
authored
Jun 28, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
picture_pool: make the reference count atomic
parent
4a474456
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
14 deletions
+9
-14
src/misc/picture_pool.c
src/misc/picture_pool.c
+9
-14
No files found.
src/misc/picture_pool.c
View file @
a1adede1
...
...
@@ -31,6 +31,7 @@
#include <vlc_common.h>
#include <vlc_picture_pool.h>
#include <vlc_atomic.h>
#include "picture.h"
static
const
uintptr_t
pool_max
=
CHAR_BIT
*
sizeof
(
unsigned
long
long
);
...
...
@@ -41,21 +42,14 @@ struct picture_pool_t {
vlc_mutex_t
lock
;
unsigned
long
long
available
;
unsigned
refs
;
unsigned
picture_count
;
atomic_ushort
refs
;
unsigned
short
picture_count
;
picture_t
*
picture
[];
};
static
void
picture_pool_Destroy
(
picture_pool_t
*
pool
)
{
bool
destroy
;
vlc_mutex_lock
(
&
pool
->
lock
);
assert
(
pool
->
refs
>
0
);
destroy
=
--
pool
->
refs
==
0
;
vlc_mutex_unlock
(
&
pool
->
lock
);
if
(
likely
(
!
destroy
))
if
(
atomic_fetch_sub
(
&
pool
->
refs
,
1
)
!=
1
)
return
;
vlc_mutex_destroy
(
&
pool
->
lock
);
...
...
@@ -129,7 +123,7 @@ picture_pool_t *picture_pool_NewExtended(const picture_pool_configuration_t *cfg
pool
->
pic_unlock
=
cfg
->
unlock
;
vlc_mutex_init
(
&
pool
->
lock
);
pool
->
available
=
(
1ULL
<<
cfg
->
picture_count
)
-
1
;
pool
->
refs
=
1
;
atomic_init
(
&
pool
->
refs
,
1
)
;
pool
->
picture_count
=
cfg
->
picture_count
;
memcpy
(
pool
->
picture
,
cfg
->
picture
,
cfg
->
picture_count
*
sizeof
(
picture_t
*
));
...
...
@@ -203,7 +197,6 @@ picture_t *picture_pool_Get(picture_pool_t *pool)
continue
;
pool
->
available
&=
~
(
1ULL
<<
i
);
pool
->
refs
++
;
vlc_mutex_unlock
(
&
pool
->
lock
);
picture_t
*
picture
=
pool
->
picture
[
i
];
...
...
@@ -211,12 +204,14 @@ picture_t *picture_pool_Get(picture_pool_t *pool)
if
(
pool
->
pic_lock
!=
NULL
&&
pool
->
pic_lock
(
picture
)
!=
0
)
{
vlc_mutex_lock
(
&
pool
->
lock
);
pool
->
available
|=
1ULL
<<
i
;
pool
->
refs
--
;
continue
;
}
picture_t
*
clone
=
picture_pool_ClonePicture
(
pool
,
i
);
assert
(
unlikely
(
clone
==
NULL
)
||
clone
->
p_next
==
NULL
);
if
(
clone
!=
NULL
)
{
assert
(
clone
->
p_next
==
NULL
);
atomic_fetch_add
(
&
pool
->
refs
,
1
);
}
return
clone
;
}
...
...
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