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
d2e0d7fe
Commit
d2e0d7fe
authored
Aug 02, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Preparser: detach thread and race to idle
parent
96f64209
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
34 deletions
+19
-34
src/playlist/preparser.c
src/playlist/preparser.c
+19
-34
No files found.
src/playlist/preparser.c
View file @
d2e0d7fe
...
@@ -42,9 +42,9 @@ struct playlist_preparser_t
...
@@ -42,9 +42,9 @@ struct playlist_preparser_t
playlist_t
*
p_playlist
;
playlist_t
*
p_playlist
;
playlist_fetcher_t
*
p_fetcher
;
playlist_fetcher_t
*
p_fetcher
;
vlc_thread_t
thread
;
vlc_mutex_t
lock
;
vlc_mutex_t
lock
;
bool
b_live
,
b_zombie
;
vlc_cond_t
wait
;
bool
b_live
;
input_item_t
**
pp_waiting
;
input_item_t
**
pp_waiting
;
int
i_waiting
;
int
i_waiting
;
...
@@ -65,7 +65,8 @@ playlist_preparser_t *playlist_preparser_New( playlist_t *p_playlist, playlist_f
...
@@ -65,7 +65,8 @@ playlist_preparser_t *playlist_preparser_New( playlist_t *p_playlist, playlist_f
p_preparser
->
p_playlist
=
p_playlist
;
p_preparser
->
p_playlist
=
p_playlist
;
p_preparser
->
p_fetcher
=
p_fetcher
;
p_preparser
->
p_fetcher
=
p_fetcher
;
vlc_mutex_init
(
&
p_preparser
->
lock
);
vlc_mutex_init
(
&
p_preparser
->
lock
);
p_preparser
->
b_zombie
=
p_preparser
->
b_live
=
false
;
vlc_cond_init
(
&
p_preparser
->
wait
);
p_preparser
->
b_live
=
false
;
p_preparser
->
i_art_policy
=
var_GetInteger
(
p_playlist
,
"album-art"
);
p_preparser
->
i_art_policy
=
var_GetInteger
(
p_playlist
,
"album-art"
);
p_preparser
->
i_waiting
=
0
;
p_preparser
->
i_waiting
=
0
;
p_preparser
->
pp_waiting
=
NULL
;
p_preparser
->
pp_waiting
=
NULL
;
...
@@ -78,43 +79,40 @@ void playlist_preparser_Push( playlist_preparser_t *p_preparser, input_item_t *p
...
@@ -78,43 +79,40 @@ void playlist_preparser_Push( playlist_preparser_t *p_preparser, input_item_t *p
vlc_gc_incref
(
p_item
);
vlc_gc_incref
(
p_item
);
vlc_mutex_lock
(
&
p_preparser
->
lock
);
vlc_mutex_lock
(
&
p_preparser
->
lock
);
if
(
p_preparser
->
b_zombie
)
{
vlc_join
(
p_preparser
->
thread
,
NULL
);
p_preparser
->
b_zombie
=
false
;
}
INSERT_ELEM
(
p_preparser
->
pp_waiting
,
p_preparser
->
i_waiting
,
INSERT_ELEM
(
p_preparser
->
pp_waiting
,
p_preparser
->
i_waiting
,
p_preparser
->
i_waiting
,
p_item
);
p_preparser
->
i_waiting
,
p_item
);
if
(
!
p_preparser
->
b_live
)
if
(
!
p_preparser
->
b_live
)
{
{
if
(
vlc_clone
(
&
p_preparser
->
thread
,
Thread
,
p_preparser
,
vlc_thread_t
th
;
VLC_THREAD_PRIORITY_LOW
)
)
if
(
vlc_clone
(
&
th
,
Thread
,
p_preparser
,
VLC_THREAD_PRIORITY_LOW
)
)
msg_Warn
(
p_preparser
->
p_playlist
,
msg_Warn
(
p_preparser
->
p_playlist
,
"cannot spawn pre-parser thread"
);
"cannot spawn pre-parser thread"
);
else
else
{
vlc_detach
(
th
);
p_preparser
->
b_live
=
true
;
p_preparser
->
b_live
=
true
;
}
}
}
vlc_mutex_unlock
(
&
p_preparser
->
lock
);
vlc_mutex_unlock
(
&
p_preparser
->
lock
);
}
}
void
playlist_preparser_Delete
(
playlist_preparser_t
*
p_preparser
)
void
playlist_preparser_Delete
(
playlist_preparser_t
*
p_preparser
)
{
{
bool
b_join
;
/* Destroy the item preparser */
vlc_mutex_lock
(
&
p_preparser
->
lock
);
vlc_mutex_lock
(
&
p_preparser
->
lock
);
if
(
p_preparser
->
b_live
)
/* Remove pending item to speed up preparser thread exit */
vlc_cancel
(
p_preparser
->
thread
);
b_join
=
p_preparser
->
b_live
||
p_preparser
->
b_zombie
;
vlc_mutex_unlock
(
&
p_preparser
->
lock
);
if
(
b_join
)
vlc_join
(
p_preparser
->
thread
,
NULL
);
while
(
p_preparser
->
i_waiting
>
0
)
while
(
p_preparser
->
i_waiting
>
0
)
{
/* Any left-over unparsed item? */
{
vlc_gc_decref
(
p_preparser
->
pp_waiting
[
0
]
);
vlc_gc_decref
(
p_preparser
->
pp_waiting
[
0
]
);
REMOVE_ELEM
(
p_preparser
->
pp_waiting
,
p_preparser
->
i_waiting
,
0
);
REMOVE_ELEM
(
p_preparser
->
pp_waiting
,
p_preparser
->
i_waiting
,
0
);
}
}
while
(
p_preparser
->
b_live
)
vlc_cond_wait
(
&
p_preparser
->
wait
,
&
p_preparser
->
lock
);
vlc_mutex_unlock
(
&
p_preparser
->
lock
);
/* Destroy the item preparser */
vlc_cond_destroy
(
&
p_preparser
->
wait
);
vlc_mutex_destroy
(
&
p_preparser
->
lock
);
vlc_mutex_destroy
(
&
p_preparser
->
lock
);
free
(
p_preparser
);
free
(
p_preparser
);
}
}
...
@@ -210,28 +208,15 @@ static void *Thread( void *data )
...
@@ -210,28 +208,15 @@ static void *Thread( void *data )
{
{
p_current
=
NULL
;
p_current
=
NULL
;
p_preparser
->
b_live
=
false
;
p_preparser
->
b_live
=
false
;
p_preparser
->
b_zombie
=
true
;
}
}
vlc_mutex_unlock
(
&
p_preparser
->
lock
);
vlc_mutex_unlock
(
&
p_preparser
->
lock
);
if
(
!
p_current
)
if
(
!
p_current
)
break
;
break
;
int
canc
=
vlc_savecancel
();
Preparse
(
p_playlist
,
p_current
);
Preparse
(
p_playlist
,
p_current
);
Art
(
p_preparser
,
p_current
);
Art
(
p_preparser
,
p_current
);
vlc_restorecancel
(
canc
);
/* */
int
i_activity
=
var_GetInteger
(
p_playlist
,
"activity"
);
if
(
i_activity
<
0
)
i_activity
=
0
;
/* Sleep at least 1ms and cancel thread if needed */
msleep
(
(
i_activity
+
1
)
*
1000
);
}
}
return
NULL
;
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