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

Romain Vimont rom1v at videolabs.io
Wed Sep 16 21:33:33 CEST 2020


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

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, ...);
 
 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



More information about the vlc-devel mailing list