[vlc-devel] [PATCH] stream: expose vlc_stream_Control symbol

Alexandre Janniaux ajanni at videolabs.io
Thu Sep 17 12:58:22 CEST 2020


Hi,

On Thu, Sep 17, 2020 at 09:50:54AM +0200, Thomas Guillem wrote:
>
>
> On Wed, Sep 16, 2020, at 21:33, Romain Vimont wrote:
> > The stream "control" function is exposed in 2 variants:
> >  - vlc_stream_vaControl(), with a va_list parameter;
> >  - vlc_stream_Control(), with a variable number of arguments.
> >
> > From Rust, the va_list version could only be called using the
> > "c_variadic" feature, currently unstable:
> > https://doc.rust-lang.org/std/ffi/struct.VaList.html
>
> Since the Rust integration is still experimental, could we require a Rust unstable ?
> The question is: when this unstable version will be released? After or before 4.0 ?

We could require an unstable version for the sys crate and a stable
version for the public plugin interface. There's no issues mixing
both (except the duplication of stdlib/toolchain/etc which is a
different problem in itself in this context).

Regarding the status in the Rust development workflow, being in
unstable version means that the associated RFC is not validated yet
so it might not even be in the next ten stable release for example.

It can reach stable only after the item has been accepted by the
compiler and lang team I think.

Romain's solution is the less cumbersome and can be removed later,
but we can also just implement it in a separate C file and link it
to vlccore-sys too instead of exposing it directly in libvlccore.

Regards,
--
Alexandre Janniaux
Videolabs

> >
> > However, the variadic version (vlc_stream_Control()) can be called:
> > https://doc.rust-lang.org/nomicon/ffi.html#variadic-functions
> >
> > In practice, it was provided as a static inline helper in the header.
> > Expose it with a symbol so that it can be called from Rust.
> >
> > Note: In the future, we would like to get rid of variadic or va_list
> > functions in API.
> > ---
> >  include/vlc_stream.h | 12 +-----------
> >  src/input/stream.c   | 11 +++++++++++
> >  src/libvlccore.sym   |  1 +
> >  3 files changed, 13 insertions(+), 11 deletions(-)
> >
> > diff --git a/include/vlc_stream.h b/include/vlc_stream.h
> > index bc6c0d30b7..d8ba670a70 100644
> > --- a/include/vlc_stream.h
> > +++ b/include/vlc_stream.h
> > @@ -297,17 +297,7 @@ VLC_API bool vlc_stream_Eof(const stream_t *) VLC_USED;
> >  VLC_API int vlc_stream_Seek(stream_t *, uint64_t offset) VLC_USED;
> >
> >  VLC_API int vlc_stream_vaControl(stream_t *s, int query, va_list args);
> > -
> > -static inline int vlc_stream_Control(stream_t *s, int query, ...)
> > -{
> > -    va_list ap;
> > -    int ret;
> > -
> > -    va_start(ap, query);
> > -    ret = vlc_stream_vaControl(s, query, ap);
> > -    va_end(ap);
> > -    return ret;
> > -}
> > +VLC_API int vlc_stream_Control(stream_t *s, int query, ...);
>
> Otherwise, OK with this patch.
>
> >
> >  VLC_API block_t *vlc_stream_Block(stream_t *s, size_t);
> >  VLC_API char *vlc_stream_ReadLine(stream_t *);
> > diff --git a/src/input/stream.c b/src/input/stream.c
> > index 35c5a04870..606621cf27 100644
> > --- a/src/input/stream.c
> > +++ b/src/input/stream.c
> > @@ -703,6 +703,17 @@ int vlc_stream_vaControl(stream_t *s, int cmd,
> > va_list args)
> >      return s->pf_control(s, cmd, args);
> >  }
> >
> > +int vlc_stream_Control(stream_t *s, int query, ...)
> > +{
> > +    va_list ap;
> > +    int ret;
> > +
> > +    va_start(ap, query);
> > +    ret = vlc_stream_vaControl(s, query, ap);
> > +    va_end(ap);
> > +    return ret;
> > +}
> > +
> >  /**
> >   * Read data into a block.
> >   *
> > diff --git a/src/libvlccore.sym b/src/libvlccore.sym
> > index 31fcd37cba..f78efcc11c 100644
> > --- a/src/libvlccore.sym
> > +++ b/src/libvlccore.sym
> > @@ -372,6 +372,7 @@ vlc_stream_Tell
> >  vlc_stream_NewMRL
> >  vlc_stream_NewURL
> >  vlc_stream_vaControl
> > +vlc_stream_Control
> >  vlc_stream_ReadDir
> >  vlc_stream_fifo_New
> >  vlc_stream_fifo_Queue
> > --
> > 2.28.0
> >
> > _______________________________________________
> > 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