[vlc-devel] [PATCH 01/14] media_tree: allow preparse tasks to be canceled

Pierre Lamot pierre at videolabs.io
Fri Feb 7 13:57:39 CET 2020


On 2020-02-06 16:16, Alexandre Janniaux wrote:
> Hi,
> 
> LGTM for the whole set, except a few nits which are not
> really important.

Hi, I updated the patchset on gitlab with the differents nits.

[1] https://code.videolan.org/chub/vlc/commits/qml/network-fixes

> Regards,
> --
> Alexandre Janniaux
> Videolabs
> 
> On Thu, Feb 06, 2020 at 01:56:38PM +0100, Pierre Lamot wrote:
>>   If we need to release the media tree before the preparse ends
>>   the preparse callback will likely crash.
>> 
>>   This allows to pass an optional task id to vlc_media_tree_Preparse 
>> and to
>>   cancel it afterwards
>> ---
>>  include/vlc_media_source.h                      | 13 ++++++++++++-
>>  .../gui/macosx/media-source/VLCMediaSource.m    |  2 +-
>>  modules/gui/qt/network/networkmediamodel.cpp    |  3 +--
>>  src/libvlccore.sym                              |  1 +
>>  src/media_source/media_tree.c                   | 17 
>> +++++++++++++++--
>>  5 files changed, 30 insertions(+), 6 deletions(-)
>> 
>> diff --git a/include/vlc_media_source.h b/include/vlc_media_source.h
>> index 36e1f9a0b8..9a26ddb39a 100644
>> --- a/include/vlc_media_source.h
>> +++ b/include/vlc_media_source.h
>> @@ -191,10 +191,21 @@ vlc_media_tree_Find(vlc_media_tree_t *tree, 
>> const input_item_t *media,
>>   * \param tree   the media tree (not necessarily locked)
>>   * \param libvlc the libvlc instance
>>   * \param media  the media to preparse
>> + * \param id     a task identifier
>>   */
>>  VLC_API void
>>  vlc_media_tree_Preparse(vlc_media_tree_t *tree, libvlc_int_t *libvlc,
>> -                        input_item_t *media);
>> +                        input_item_t *media, void *id);
>> +
>> +
>> +/**
>> + * Cancel a media tree preparse request
>> + *
>> + * \param libvlc the libvlc instance
>> + * \param id the preparse task id
>> + */
>> +VLC_API void
>> +vlc_media_tree_PreparseCancel(libvlc_int_t *libvlc, void* id);
>> 
>>  /**
>>   * Media source.
>> diff --git a/modules/gui/macosx/media-source/VLCMediaSource.m 
>> b/modules/gui/macosx/media-source/VLCMediaSource.m
>> index eb187fd1ea..4c01af0749 100644
>> --- a/modules/gui/macosx/media-source/VLCMediaSource.m
>> +++ b/modules/gui/macosx/media-source/VLCMediaSource.m
>> @@ -128,7 +128,7 @@ static const struct vlc_media_tree_callbacks 
>> treeCallbacks = {
>>      if (inputItem == nil) {
>>          return;
>>      }
>> -    vlc_media_tree_Preparse(_p_mediaSource->tree, _p_libvlcInstance, 
>> inputItem.vlcInputItem);
>> +    vlc_media_tree_Preparse(_p_mediaSource->tree, _p_libvlcInstance, 
>> inputItem.vlcInputItem, NULL);
>>  }
>> 
>>  - (NSString *)mediaSourceDescription
>> diff --git a/modules/gui/qt/network/networkmediamodel.cpp 
>> b/modules/gui/qt/network/networkmediamodel.cpp
>> index c2561e1620..1a24f3de91 100644
>> --- a/modules/gui/qt/network/networkmediamodel.cpp
>> +++ b/modules/gui/qt/network/networkmediamodel.cpp
>> @@ -255,8 +255,7 @@ bool NetworkMediaModel::initializeMediaSources()
>>          emit isIndexedChanged();
>>      }
>> 
>> -
>> -    vlc_media_tree_Preparse( tree, libvlc, m_treeItem.media.get() );
>> +    vlc_media_tree_Preparse( tree, libvlc, m_treeItem.media.get(), 
>> this );
>>      m_parsingPending = true;
>>      emit parsingPendingChanged(m_parsingPending);
>> 
>> diff --git a/src/libvlccore.sym b/src/libvlccore.sym
>> index cf0f2230a1..befaab5151 100644
>> --- a/src/libvlccore.sym
>> +++ b/src/libvlccore.sym
>> @@ -947,6 +947,7 @@ vlc_media_tree_Lock
>>  vlc_media_tree_Unlock
>>  vlc_media_tree_Find
>>  vlc_media_tree_Preparse
>> +vlc_media_tree_PreparseCancel
>>  vlc_viewpoint_to_4x4
>>  vlc_video_context_Create
>>  vlc_video_context_Release
>> diff --git a/src/media_source/media_tree.c 
>> b/src/media_source/media_tree.c
>> index ed2df3be42..017325719f 100644
>> --- a/src/media_source/media_tree.c
>> +++ b/src/media_source/media_tree.c
>> @@ -342,17 +342,30 @@ static const input_preparser_callbacks_t 
>> input_preparser_callbacks = {
>> 
>>  void
>>  vlc_media_tree_Preparse(vlc_media_tree_t *tree, libvlc_int_t *libvlc,
>> -                        input_item_t *media)
>> +                        input_item_t *media, void* id)
>>  {
>>  #ifdef TEST_MEDIA_SOURCE
>>      VLC_UNUSED(tree);
>>      VLC_UNUSED(libvlc);
>>      VLC_UNUSED(media);
>> +    VLC_UNUSED(id);
>>      VLC_UNUSED(input_preparser_callbacks);
>>  #else
>>      media->i_preparse_depth = 1;
>>      vlc_MetadataRequest(libvlc, media, META_REQUEST_OPTION_SCOPE_ANY 
>> |
>>                          META_REQUEST_OPTION_DO_INTERACT,
>> -                        &input_preparser_callbacks, tree, 0, NULL);
>> +                        &input_preparser_callbacks, tree, 0, id);
>> +#endif
>> +}
>> +
>> +
>> +void
>> +vlc_media_tree_PreparseCancel(libvlc_int_t *libvlc, void* id)
>> +{
>> +#ifdef TEST_MEDIA_SOURCE
>> +    VLC_UNUSED(libvlc);
>> +    VLC_UNUSED(id);
>> +#else
>> +    libvlc_MetadataCancel(libvlc, id);
>>  #endif
>>  }
>> --
>> 2.17.1
>> 
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list