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
85e5f7ca
Commit
85e5f7ca
authored
Nov 01, 2014
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
picture_pool: simplify and clean-up pool deletion
parent
995535ec
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
29 deletions
+19
-29
src/misc/picture_pool.c
src/misc/picture_pool.c
+19
-29
No files found.
src/misc/picture_pool.c
View file @
85e5f7ca
...
...
@@ -40,7 +40,6 @@
struct
picture_gc_sys_t
{
picture_pool_t
*
pool
;
picture_t
*
picture
;
atomic_bool
zombie
;
int64_t
tick
;
};
...
...
@@ -56,18 +55,27 @@ struct picture_pool_t {
vlc_mutex_t
lock
;
};
static
void
Release
(
picture_pool_t
*
pool
)
static
void
picture_pool_
Release
(
picture_pool_t
*
pool
)
{
bool
destroy
;
vlc_mutex_lock
(
&
pool
->
lock
);
assert
(
pool
->
refs
>
0
);
destroy
=
!--
pool
->
refs
;
destroy
=
--
pool
->
refs
==
0
;
vlc_mutex_unlock
(
&
pool
->
lock
);
if
(
!
destroy
)
if
(
likely
(
!
destroy
)
)
return
;
for
(
unsigned
i
=
0
;
i
<
pool
->
picture_count
;
i
++
)
{
picture_t
*
picture
=
pool
->
picture
[
i
];
picture_gc_sys_t
*
sys
=
picture
->
gc
.
p_sys
;
picture_Release
(
sys
->
picture
);
free
(
sys
);
free
(
picture
);
}
vlc_mutex_destroy
(
&
pool
->
lock
);
free
(
pool
->
picture
);
free
(
pool
);
...
...
@@ -81,15 +89,7 @@ static void picture_pool_ReleasePicture(picture_t *picture)
if
(
pool
->
pic_unlock
!=
NULL
)
pool
->
pic_unlock
(
picture
);
if
(
!
atomic_load
(
&
sys
->
zombie
))
return
;
/* Picture from an already destroyed pool */
picture_Release
(
sys
->
picture
);
free
(
sys
);
free
(
picture
);
Release
(
pool
);
picture_pool_Release
(
pool
);
}
static
picture_t
*
picture_pool_ClonePicture
(
picture_pool_t
*
pool
,
...
...
@@ -101,7 +101,6 @@ static picture_t *picture_pool_ClonePicture(picture_pool_t *pool,
sys
->
pool
=
pool
;
sys
->
picture
=
picture
;
atomic_init
(
&
sys
->
zombie
,
false
);
sys
->
tick
=
0
;
picture_resource_t
res
=
{
...
...
@@ -160,7 +159,6 @@ picture_pool_t *picture_pool_NewExtended(const picture_pool_configuration_t *cfg
atomic_init
(
&
picture
->
gc
.
refcount
,
0
);
pool
->
picture
[
i
]
=
picture
;
pool
->
refs
++
;
}
return
pool
;
...
...
@@ -228,18 +226,7 @@ error:
void
picture_pool_Delete
(
picture_pool_t
*
pool
)
{
for
(
unsigned
i
=
0
;
i
<
pool
->
picture_count
;
i
++
)
{
picture_t
*
picture
=
pool
->
picture
[
i
];
/* Restore the initial reference that was cloberred in
* picture_pool_NewExtended(). */
atomic_fetch_add
(
&
picture
->
gc
.
refcount
,
1
);
/* The picture might still locked and then the G.C. state cannot be
* modified (w/o memory synchronization). */
atomic_store
(
&
picture
->
gc
.
p_sys
->
zombie
,
true
);
picture_Release
(
picture
);
}
Release
(
pool
);
picture_pool_Release
(
pool
);
}
picture_t
*
picture_pool_Get
(
picture_pool_t
*
pool
)
...
...
@@ -256,9 +243,12 @@ picture_t *picture_pool_Get(picture_pool_t *pool)
continue
;
}
/* */
p
icture
->
p_next
=
NULL
;
vlc_mutex_lock
(
&
pool
->
lock
);
p
ool
->
refs
++
;
picture
->
gc
.
p_sys
->
tick
=
pool
->
tick
++
;
vlc_mutex_unlock
(
&
pool
->
lock
);
picture
->
p_next
=
NULL
;
return
picture
;
}
return
NULL
;
...
...
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