[vlc-devel] [PATCH] lua: player: remove incorrect const
thomas at gllm.fr
Thu May 2 13:22:52 CEST 2019
On Thu, May 2, 2019, at 12:26, Steve Lhomme wrote:
> On 5/2/2019 12:12 PM, Romain Vimont wrote:
> > A title list can be held, so vlc_player_GetTitleList() returns a pointer
> > to a non-const title list.
> I haven't followed the whole player API changes, but if it can be held,
> shouldn't it return a held pointer in the first place ? How long does
> this pointer stay valid ?
Every structs returned by the player are valid until the player is unlocked or until you leave the callback.
Some struct can be duplicated or and some can be held/release (if you want to pass these struct to an other thread).
I forgot to put a warning like this for vlc_player_GetTitleList()
" * @warning The returned pointer becomes invalid when the player is unlocked.
* The referenced structure can be safely copied."
But it is explained in on_titles_changed callback documentation:
* @note Users should hold this list with vlc_player_title_list_Hold() if
* they want to use it from an other context.
> > ---
> > modules/lua/libs/input.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> > diff --git a/modules/lua/libs/input.c b/modules/lua/libs/input.c
> > index c011f1d95f..ac69f1f7b7 100644
> > --- a/modules/lua/libs/input.c
> > +++ b/modules/lua/libs/input.c
> > @@ -117,8 +117,7 @@ static int vlclua_player_get_titles_count(lua_State *L)
> > vlc_player_t *player = vlclua_get_player_internal(L);
> > vlc_player_Lock(player);
> > - const struct vlc_player_title_list *titles =
> > - vlc_player_GetTitleList(player);
> > + struct vlc_player_title_list *titles = vlc_player_GetTitleList(player);
> > size_t count = titles ? vlc_player_title_list_GetCount(titles) : 0;
> > vlc_player_Unlock(player);
> > --
> > 2.20.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:
More information about the vlc-devel