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
e4752428
Commit
e4752428
authored
Nov 18, 2015
by
Thomas Guillem
Committed by
Rémi Denis-Courmont
Nov 30, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
picture_pool: add picture_pool_Cancel
Signed-off-by:
Rémi Denis-Courmont
<
remi@remlab.net
>
parent
c41a4a3e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
1 deletion
+35
-1
include/vlc_picture_pool.h
include/vlc_picture_pool.h
+9
-0
src/misc/picture_pool.c
src/misc/picture_pool.c
+26
-1
No files found.
include/vlc_picture_pool.h
View file @
e4752428
...
...
@@ -157,6 +157,15 @@ VLC_API void picture_pool_Enum( picture_pool_t *,
*/
unsigned
picture_pool_Reset
(
picture_pool_t
*
);
/**
* Cancel the picture pool.
*
* It won't return any pictures via picture_pool_Get or picture_pool_Wait after
* this call. This function will also unblock picture_pool_Wait. Call
* picture_pool_Reset to reset the cancel state.
*/
void
picture_pool_Cancel
(
picture_pool_t
*
);
/**
* Reserves pictures from a pool and creates a new pool with those.
*
...
...
src/misc/picture_pool.c
View file @
e4752428
...
...
@@ -42,6 +42,7 @@ struct picture_pool_t {
vlc_mutex_t
lock
;
vlc_cond_t
wait
;
bool
canceled
;
unsigned
long
long
available
;
atomic_ushort
refs
;
unsigned
short
picture_count
;
...
...
@@ -131,6 +132,7 @@ picture_pool_t *picture_pool_NewExtended(const picture_pool_configuration_t *cfg
pool
->
picture_count
=
cfg
->
picture_count
;
memcpy
(
pool
->
picture
,
cfg
->
picture
,
cfg
->
picture_count
*
sizeof
(
picture_t
*
));
pool
->
canceled
=
false
;
return
pool
;
}
...
...
@@ -204,6 +206,12 @@ picture_t *picture_pool_Get(picture_pool_t *pool)
vlc_mutex_lock
(
&
pool
->
lock
);
assert
(
pool
->
refs
>
0
);
if
(
pool
->
canceled
)
{
vlc_mutex_unlock
(
&
pool
->
lock
);
return
NULL
;
}
for
(
unsigned
i
=
ffsll
(
pool
->
available
);
i
;
i
=
fnsll
(
pool
->
available
,
i
))
{
pool
->
available
&=
~
(
1ULL
<<
(
i
-
1
));
...
...
@@ -236,9 +244,15 @@ picture_t *picture_pool_Wait(picture_pool_t *pool)
vlc_mutex_lock
(
&
pool
->
lock
);
assert
(
pool
->
refs
>
0
);
while
(
pool
->
available
==
0
)
while
(
pool
->
available
==
0
&&
!
pool
->
canceled
)
vlc_cond_wait
(
&
pool
->
wait
,
&
pool
->
lock
);
if
(
pool
->
canceled
)
{
vlc_mutex_unlock
(
&
pool
->
lock
);
return
NULL
;
}
i
=
ffsll
(
pool
->
available
);
assert
(
i
>
0
);
pool
->
available
&=
~
(
1ULL
<<
(
i
-
1
));
...
...
@@ -262,6 +276,16 @@ picture_t *picture_pool_Wait(picture_pool_t *pool)
return
clone
;
}
void
picture_pool_Cancel
(
picture_pool_t
*
pool
)
{
vlc_mutex_lock
(
&
pool
->
lock
);
assert
(
pool
->
refs
>
0
);
pool
->
canceled
=
true
;
vlc_cond_signal
(
&
pool
->
wait
);
vlc_mutex_unlock
(
&
pool
->
lock
);
}
unsigned
picture_pool_Reset
(
picture_pool_t
*
pool
)
{
unsigned
ret
;
...
...
@@ -270,6 +294,7 @@ unsigned picture_pool_Reset(picture_pool_t *pool)
assert
(
pool
->
refs
>
0
);
ret
=
pool
->
picture_count
-
popcountll
(
pool
->
available
);
pool
->
available
=
(
1ULL
<<
pool
->
picture_count
)
-
1
;
pool
->
canceled
=
false
;
vlc_mutex_unlock
(
&
pool
->
lock
);
return
ret
;
...
...
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