[vlc-devel] [PATCH 1/2] lib: media_player: keep player libvlc instance

Thomas Guillem thomas at gllm.fr
Thu Jul 16 11:00:25 CEST 2020



On Thu, Jul 16, 2020, at 10:52, Alexandre Janniaux wrote:
> Hi,
> 
> On Wed, Jul 15, 2020 at 10:55:46PM +0300, Rémi Denis-Courmont wrote:
> > Le keskiviikkona 15. heinäkuuta 2020, 21.24.12 EEST Thomas Guillem a écrit :
> > > On Wed, Jul 15, 2020, at 18:26, Rémi Denis-Courmont wrote:
> > > > Le torstaina 9. heinäkuuta 2020, 18.21.50 EEST Alexandre Janniaux a écrit
> > :
> > > > > The media_player instance retains and releases the libvlc instance it's
> > > > > created from. When using a different libvlc instance for media_player
> > > > > and media,
> > > >
> > > > Frankly, it makes zero sense for a media to be tied to an instance in the
> > > > first place. input_item_t is not tied to an instance. I think you're
> > > > looking at it from the wrong angle.
> > > >
> > > > Of course, an instance is necessary for certain operation on the media:
> > > > playing, parsing, etc. In all those case, we should do one of the
> > > > following: 1) implicitly use the instance from the actor object (as media
> > > > player does)
> > > I vote for 1/, we should create a libvlc_parser API. That way we can remove
> > > the instance from the media.
> > > > 2) create an instance automatically,
> > > > 3) take an explicit instance pointer as parameter.
> >
> > I tend to agree that (1) is better than either (2) or (3). There should be
> > separate player, meta reader, thumbnailer and meta writer objects. Only the
> > first one exists as yet.
> >
> > But I don't know if the new functions should create their own private VLC
> > instance, require a supplied VLC instance, or leave the choice of either (i.e.
> > create an instance if the instance parameter is NULL).
> 
> I tend to think that default in C is not really that idiomatic
> nor easy to use/understand for the actual libvlc users.
> 
> libvlc_new() is easy to call and refcounting makes it easy to
> just allocate the instance, allocate the actor object, and
> release the instance, while providing a good habit of how the
> libvlc API are working for the user.

Users can setup logs and dialogs callbacks on the libvlc instance. That's another reason to keep only one libvlc instance.

Regarding dialogs callbacks, I did a bad design. The dialog callbacks should be set up on the media_player, the parser, the thumbnailer directly. Indeed, some applications are changing the dialog callbacks depending on some app context without respecting a rule I forget to add in comment: dialog callbacks should be setup before creating any objects (again, bad design...). 

> 
> Regards,
> --
> Alexandre Janniaux
> Videolabs
> _______________________________________________
> 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