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
823b0568
Commit
823b0568
authored
Jun 04, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
preparser: shut threat down when not needed
parent
032f1e34
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
26 deletions
+39
-26
src/playlist/preparser.c
src/playlist/preparser.c
+39
-26
No files found.
src/playlist/preparser.c
View file @
823b0568
...
...
@@ -44,7 +44,7 @@ struct playlist_preparser_t
vlc_thread_t
thread
;
vlc_mutex_t
lock
;
vlc_cond_t
wait
;
bool
b_live
,
b_zombie
;
input_item_t
**
pp_waiting
;
int
i_waiting
;
...
...
@@ -65,18 +65,11 @@ playlist_preparser_t *playlist_preparser_New( playlist_t *p_playlist, playlist_f
p_preparser
->
p_playlist
=
p_playlist
;
p_preparser
->
p_fetcher
=
p_fetcher
;
vlc_mutex_init
(
&
p_preparser
->
lock
);
vlc_cond_init
(
&
p_preparser
->
wait
)
;
p_preparser
->
b_zombie
=
p_preparser
->
b_live
=
false
;
p_preparser
->
i_art_policy
=
var_GetInteger
(
p_playlist
,
"album-art"
);
p_preparser
->
i_waiting
=
0
;
p_preparser
->
pp_waiting
=
NULL
;
if
(
vlc_clone
(
&
p_preparser
->
thread
,
Thread
,
p_preparser
,
VLC_THREAD_PRIORITY_LOW
)
)
{
msg_Err
(
p_playlist
,
"cannot spawn preparse thread"
);
free
(
p_preparser
);
return
NULL
;
}
return
p_preparser
;
}
...
...
@@ -85,24 +78,43 @@ void playlist_preparser_Push( playlist_preparser_t *p_preparser, input_item_t *p
vlc_gc_incref
(
p_item
);
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
,
p_preparser
->
i_waiting
,
p_item
);
vlc_cond_signal
(
&
p_preparser
->
wait
);
if
(
!
p_preparser
->
b_live
)
{
if
(
vlc_clone
(
&
p_preparser
->
thread
,
Thread
,
p_preparser
,
VLC_THREAD_PRIORITY_LOW
)
)
msg_Warn
(
p_preparser
->
p_playlist
,
"cannot spawn pre-parser thread"
);
else
p_preparser
->
b_live
=
true
;
}
vlc_mutex_unlock
(
&
p_preparser
->
lock
);
}
void
playlist_preparser_Delete
(
playlist_preparser_t
*
p_preparser
)
{
bool
b_join
;
/* Destroy the item preparser */
vlc_cancel
(
p_preparser
->
thread
);
vlc_join
(
p_preparser
->
thread
,
NULL
);
vlc_mutex_lock
(
&
p_preparser
->
lock
);
if
(
p_preparser
->
b_live
)
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
)
{
/* Any left-over unparsed item? */
vlc_gc_decref
(
p_preparser
->
pp_waiting
[
0
]
);
REMOVE_ELEM
(
p_preparser
->
pp_waiting
,
p_preparser
->
i_waiting
,
0
);
}
vlc_cond_destroy
(
&
p_preparser
->
wait
);
vlc_mutex_destroy
(
&
p_preparser
->
lock
);
free
(
p_preparser
);
}
...
...
@@ -187,22 +199,23 @@ static void *Thread( void *data )
{
input_item_t
*
p_current
;
/* Be sure to be cancellable before our queue is empty */
vlc_testcancel
();
/* */
vlc_mutex_lock
(
&
p_preparser
->
lock
);
mutex_cleanup_push
(
&
p_preparser
->
lock
);
while
(
p_preparser
->
i_waiting
==
0
)
vlc_cond_wait
(
&
p_preparser
->
wait
,
&
p_preparser
->
lock
);
p_current
=
p_preparser
->
pp_waiting
[
0
];
REMOVE_ELEM
(
p_preparser
->
pp_waiting
,
p_preparser
->
i_waiting
,
0
);
vlc_cleanup_run
(
);
if
(
p_preparser
->
i_waiting
>
0
)
{
p_current
=
p_preparser
->
pp_waiting
[
0
];
REMOVE_ELEM
(
p_preparser
->
pp_waiting
,
p_preparser
->
i_waiting
,
0
);
}
else
{
p_current
=
NULL
;
p_preparser
->
b_live
=
false
;
p_preparser
->
b_zombie
=
true
;
}
vlc_mutex_unlock
(
&
p_preparser
->
lock
);
if
(
!
p_current
)
continue
;
break
;
int
canc
=
vlc_savecancel
();
...
...
@@ -217,7 +230,7 @@ static void *Thread( void *data )
if
(
i_activity
<
0
)
i_activity
=
0
;
/* Sleep at least 1ms */
/* Sleep at least 1ms
and cancel thread if needed
*/
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