Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
96f64209
Commit
96f64209
authored
Aug 02, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fetcher: detach thread and race to idle
parent
6cecd8ec
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
33 deletions
+19
-33
src/playlist/fetcher.c
src/playlist/fetcher.c
+19
-33
No files found.
src/playlist/fetcher.c
View file @
96f64209
...
...
@@ -44,9 +44,9 @@ struct playlist_fetcher_t
playlist_t
*
p_playlist
;
vlc_thread_t
thread
;
vlc_mutex_t
lock
;
bool
b_live
,
b_zombie
;
vlc_cond_t
wait
;
bool
b_live
;
int
i_art_policy
;
int
i_waiting
;
input_item_t
**
pp_waiting
;
...
...
@@ -72,8 +72,8 @@ playlist_fetcher_t *playlist_fetcher_New( playlist_t *p_playlist )
vlc_object_attach
(
p_fetcher
,
p_playlist
);
p_fetcher
->
p_playlist
=
p_playlist
;
vlc_mutex_init
(
&
p_fetcher
->
lock
);
vlc_cond_init
(
&
p_fetcher
->
wait
);
p_fetcher
->
b_live
=
false
;
p_fetcher
->
b_zombie
=
false
;
p_fetcher
->
i_waiting
=
0
;
p_fetcher
->
pp_waiting
=
NULL
;
p_fetcher
->
i_art_policy
=
var_GetInteger
(
p_playlist
,
"album-art"
);
...
...
@@ -87,45 +87,39 @@ void playlist_fetcher_Push( playlist_fetcher_t *p_fetcher, input_item_t *p_item
vlc_gc_incref
(
p_item
);
vlc_mutex_lock
(
&
p_fetcher
->
lock
);
if
(
p_fetcher
->
b_zombie
)
/* FIXME: detach the thread */
{
vlc_join
(
p_fetcher
->
thread
,
NULL
);
p_fetcher
->
b_zombie
=
false
;
}
INSERT_ELEM
(
p_fetcher
->
pp_waiting
,
p_fetcher
->
i_waiting
,
p_fetcher
->
i_waiting
,
p_item
);
if
(
!
p_fetcher
->
b_live
)
{
if
(
vlc_clone
(
&
p_fetcher
->
thread
,
Thread
,
p_fetcher
,
VLC_THREAD_PRIORITY_LOW
)
)
vlc_thread_t
th
;
if
(
vlc_clone
(
&
th
,
Thread
,
p_fetcher
,
VLC_THREAD_PRIORITY_LOW
)
)
msg_Err
(
p_fetcher
,
"cannot spawn secondary preparse thread"
);
else
{
vlc_detach
(
th
);
p_fetcher
->
b_live
=
true
;
}
}
vlc_mutex_unlock
(
&
p_fetcher
->
lock
);
}
void
playlist_fetcher_Delete
(
playlist_fetcher_t
*
p_fetcher
)
{
bool
b_join
;
/* Destroy the item meta-infos fetcher */
vlc_mutex_lock
(
&
p_fetcher
->
lock
);
if
(
p_fetcher
->
b_live
)
{
vlc_object_kill
(
p_fetcher
);
vlc_cancel
(
p_fetcher
->
thread
);
}
b_join
=
p_fetcher
->
b_live
||
p_fetcher
->
b_zombie
;
vlc_mutex_unlock
(
&
p_fetcher
->
lock
);
if
(
b_join
)
vlc_join
(
p_fetcher
->
thread
,
NULL
);
/* Remove any left-over item, the fetcher will exit */
while
(
p_fetcher
->
i_waiting
>
0
)
{
/* Any left-over unparsed item? */
{
vlc_gc_decref
(
p_fetcher
->
pp_waiting
[
0
]
);
REMOVE_ELEM
(
p_fetcher
->
pp_waiting
,
p_fetcher
->
i_waiting
,
0
);
}
vlc_object_kill
(
p_fetcher
);
while
(
p_fetcher
->
b_live
)
vlc_cond_wait
(
&
p_fetcher
->
wait
,
&
p_fetcher
->
lock
);
vlc_mutex_unlock
(
&
p_fetcher
->
lock
);
vlc_cond_destroy
(
&
p_fetcher
->
wait
);
vlc_mutex_destroy
(
&
p_fetcher
->
lock
);
vlc_object_release
(
p_fetcher
);
}
...
...
@@ -400,7 +394,7 @@ static void *Thread( void *p_data )
else
{
p_fetcher
->
b_live
=
false
;
p_fetcher
->
b_zombie
=
true
;
vlc_cond_signal
(
&
p_fetcher
->
wait
)
;
}
vlc_mutex_unlock
(
&
p_fetcher
->
lock
);
...
...
@@ -408,7 +402,6 @@ static void *Thread( void *p_data )
break
;
/* */
int
canc
=
vlc_savecancel
();
/* Wait that the input item is preparsed if it is being played */
WaitPreparsed
(
p_fetcher
,
p_item
);
...
...
@@ -444,13 +437,6 @@ static void *Thread( void *p_data )
end:
vlc_gc_decref
(
p_item
);
vlc_restorecancel
(
canc
);
int
i_activity
=
var_GetInteger
(
p_playlist
,
"activity"
);
if
(
i_activity
<
0
)
i_activity
=
0
;
/* Sleep at least 1ms and handle potential thread cancellation */
msleep
(
(
i_activity
+
1
)
*
1000
);
}
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