Skip to content

Commit

Permalink
thumbnailer: return the number of tasks cancelled
Browse files Browse the repository at this point in the history
  • Loading branch information
tguillem committed Oct 17, 2024
1 parent a9fdd37 commit da2ff17
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion include/vlc_thumbnailer.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ vlc_thumbnailer_RequestByPos( vlc_thumbnailer_t *thumbnailer,
* \param thumbnailer A thumbnailer object
* \param id unique id returned by vlc_thumbnailer_Request*(),
* VLC_THUMBNAILER_REQ_ID_INVALID to cancels all tasks
* \return number of tasks cancelled
*/
VLC_API void
VLC_API size_t
vlc_thumbnailer_Cancel( vlc_thumbnailer_t* thumbnailer, vlc_thumbnailer_req_id id );

/**
Expand Down
6 changes: 5 additions & 1 deletion src/input/thumbnailer.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,17 @@ vlc_thumbnailer_RequestByPos( vlc_thumbnailer_t *thumbnailer,
userdata);
}

void vlc_thumbnailer_Cancel( vlc_thumbnailer_t* thumbnailer, vlc_thumbnailer_req_id id )
size_t vlc_thumbnailer_Cancel( vlc_thumbnailer_t* thumbnailer, vlc_thumbnailer_req_id id )
{
vlc_mutex_lock(&thumbnailer->lock);

task_t *task;
size_t count = 0;
vlc_list_foreach(task, &thumbnailer->submitted_tasks, node)
{
if (id == VLC_THUMBNAILER_REQ_ID_INVALID || task->id == id)
{
count++;
bool canceled =
vlc_executor_Cancel(thumbnailer->executor, &task->runnable);
if (canceled)
Expand All @@ -312,6 +314,8 @@ void vlc_thumbnailer_Cancel( vlc_thumbnailer_t* thumbnailer, vlc_thumbnailer_req
}

vlc_mutex_unlock(&thumbnailer->lock);

return count;
}

vlc_thumbnailer_t *vlc_thumbnailer_Create( vlc_object_t* parent)
Expand Down

0 comments on commit da2ff17

Please sign in to comment.