[vlc-commits] [Git][videolan/vlc][master] 4 commits: preparser: remove from the executor list the earliest possible
Steve Lhomme (@robUx4)
gitlab at videolan.org
Wed Apr 5 09:56:32 UTC 2023
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
3459103b by Thomas Guillem at 2023-04-05T09:28:42+00:00
preparser: remove from the executor list the earliest possible
Remove from the list immediately after we are done with the executor.
This will be needed by the next commit.
- - - - -
f4f2ef45 by Thomas Guillem at 2023-04-05T09:28:42+00:00
preparser: don't wait for the fetcher
Let the preparser thread parse the next item, while the current one is
being art fetched, ie. don't block the preparser thread while fetching
arts.
- - - - -
ec26295b by Thomas Guillem at 2023-04-05T09:28:42+00:00
preparser: remove task->art_fetched
It can now be used directly.
- - - - -
0c5eb699 by Thomas Guillem at 2023-04-05T09:28:42+00:00
input: remove always true arg in input_item_SetPreparsed()
- - - - -
4 changed files:
- src/input/es_out.c
- src/input/input_interface.h
- src/input/item.c
- src/preparser/preparser.c
Changes:
=====================================
src/input/es_out.c
=====================================
@@ -1929,7 +1929,7 @@ static void EsOutMeta( es_out_t *p_out, const vlc_meta_t *p_meta, const vlc_meta
}
free( psz_alloc );
- input_item_SetPreparsed( p_item, true );
+ input_item_SetPreparsed( p_item );
input_SendEventMeta( p_input );
/* TODO handle sout meta ? */
=====================================
src/input/input_interface.h
=====================================
@@ -29,7 +29,7 @@
/**********************************************************************
* Item metadata
**********************************************************************/
-void input_item_SetPreparsed( input_item_t *p_i, bool b_preparsed );
+void input_item_SetPreparsed( input_item_t *p_i );
void input_item_SetArtNotFound( input_item_t *p_i, bool b_not_found );
void input_item_SetArtFetched( input_item_t *p_i, bool b_art_fetched );
void input_item_SetEpg( input_item_t *p_item, const vlc_epg_t *p_epg, bool );
=====================================
src/input/item.c
=====================================
@@ -65,18 +65,14 @@ void input_item_SetErrorWhenReading( input_item_t *p_i, bool b_error )
.u.input_item_error_when_reading_changed.new_value = b_error } );
}
}
-void input_item_SetPreparsed( input_item_t *p_i, bool b_preparsed )
+void input_item_SetPreparsed( input_item_t *p_i )
{
bool b_send_event = false;
vlc_mutex_lock( &p_i->lock );
int status = vlc_meta_GetStatus(p_i->p_meta);
- int new_status;
- if( b_preparsed )
- new_status = status | ITEM_PREPARSED;
- else
- new_status = status & ~ITEM_PREPARSED;
+ int new_status = status | ITEM_PREPARSED;
if( status != new_status )
{
vlc_meta_SetStatus(p_i->p_meta, new_status);
=====================================
src/preparser/preparser.c
=====================================
@@ -56,10 +56,8 @@ struct task
input_item_parser_id_t *parser;
vlc_sem_t preparse_ended;
- vlc_sem_t fetch_ended;
atomic_int preparse_status;
atomic_bool interrupted;
- bool art_fetched;
struct vlc_runnable runnable; /**< to be passed to the executor */
@@ -87,13 +85,11 @@ TaskNew(vlc_preparser_t *preparser, input_item_t *item,
task->userdata = userdata;
task->id = id;
task->timeout = timeout;
- task->art_fetched = false;
input_item_Hold(item);
task->parser = NULL;
vlc_sem_init(&task->preparse_ended, 0);
- vlc_sem_init(&task->fetch_ended, 0);
atomic_init(&task->preparse_status, ITEM_PREPARSE_SKIPPED);
atomic_init(&task->interrupted, false);
@@ -127,14 +123,14 @@ PreparserRemoveTask(vlc_preparser_t *preparser, struct task *task)
}
static void
-NotifyPreparseEnded(struct task *task)
+NotifyPreparseEnded(struct task *task, bool art_fetched)
{
if (task->cbs == NULL)
return;
if (task->options & META_REQUEST_OPTION_FETCH_ANY
&& task->cbs->on_art_fetch_ended)
- task->cbs->on_art_fetch_ended(task->item, task->art_fetched,
+ task->cbs->on_art_fetch_ended(task->item, art_fetched,
task->userdata);
if (task->cbs->on_preparse_ended) {
@@ -182,9 +178,12 @@ OnArtFetchEnded(input_item_t *item, bool fetched, void *userdata)
VLC_UNUSED(fetched);
struct task *task = userdata;
- task->art_fetched = fetched;
- vlc_sem_post(&task->fetch_ended);
+ if (!atomic_load(&task->interrupted))
+ input_item_SetPreparsed(task->item);
+
+ NotifyPreparseEnded(task, fetched);
+ TaskDelete(task);
}
static const input_fetcher_callbacks_t input_fetcher_callbacks = {
@@ -223,22 +222,16 @@ Parse(struct task *task, vlc_tick_t deadline)
input_item_parser_id_Release(task->parser);
}
-static void
+static int
Fetch(struct task *task)
{
input_fetcher_t *fetcher = task->preparser->fetcher;
if (!fetcher || !(task->options & META_REQUEST_OPTION_FETCH_ANY))
- return;
+ return VLC_ENOENT;
- int ret =
- input_fetcher_Push(fetcher, task->item,
- task->options & META_REQUEST_OPTION_FETCH_ANY,
- &input_fetcher_callbacks, task);
- if (ret != VLC_SUCCESS)
- return;
-
- /* Wait until the end of fetching (fetching is not interruptible) */
- vlc_sem_wait(&task->fetch_ended);
+ return input_fetcher_Push(fetcher, task->item,
+ task->options & META_REQUEST_OPTION_FETCH_ANY,
+ &input_fetcher_callbacks, task);
}
static void
@@ -247,6 +240,7 @@ RunnableRun(void *userdata)
vlc_thread_set_name("vlc-run-prepars");
struct task *task = userdata;
+ vlc_preparser_t *preparser = task->preparser;
vlc_tick_t deadline = task->timeout ? vlc_tick_now() + task->timeout
: VLC_TICK_INVALID;
@@ -255,25 +249,29 @@ RunnableRun(void *userdata)
META_REQUEST_OPTION_SCOPE_FORCED))
{
if (atomic_load(&task->interrupted))
+ {
+ PreparserRemoveTask(preparser, task);
goto end;
+ }
Parse(task, deadline);
}
+ PreparserRemoveTask(preparser, task);
+
if (atomic_load(&task->interrupted))
goto end;
- Fetch(task);
+ int ret = Fetch(task);
- if (atomic_load(&task->interrupted))
- goto end;
+ if (ret == VLC_SUCCESS)
+ return; /* Remove the task and notify from the fetcher callback */
- input_item_SetPreparsed(task->item, true);
+ if (!atomic_load(&task->interrupted))
+ input_item_SetPreparsed(task->item);
end:
- NotifyPreparseEnded(task);
- vlc_preparser_t *preparser = task->preparser;
- PreparserRemoveTask(preparser, task);
+ NotifyPreparseEnded(task, false);
TaskDelete(task);
}
@@ -389,7 +387,7 @@ void vlc_preparser_Cancel( vlc_preparser_t *preparser, void *id )
vlc_executor_Cancel(preparser->executor, &task->runnable);
if (canceled)
{
- NotifyPreparseEnded(task);
+ NotifyPreparseEnded(task, false);
vlc_list_remove(&task->node);
TaskDelete(task);
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fef5c66edb73dc71a97aeae59daffd1e4585c5b4...0c5eb69958622bbcbad01a853d23c0d21da135b2
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fef5c66edb73dc71a97aeae59daffd1e4585c5b4...0c5eb69958622bbcbad01a853d23c0d21da135b2
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list