[vlc-commits] [Git][videolan/vlc] Pushed new branch 25796-sndio-fix-crash-when-volume-is-adjusted-while-playback-is-stopped

2021-06-02 Thread Rémi Denis-Courmont


Rémi Denis-Courmont pushed new branch 
25796-sndio-fix-crash-when-volume-is-adjusted-while-playback-is-stopped at 
VideoLAN / VLC

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/tree/25796-sndio-fix-crash-when-volume-is-adjusted-while-playback-is-stopped
You're receiving this email because of your account on code.videolan.org.


___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

[vlc-commits] gnutls: fix priority descriptions (fixes #22775)

2021-04-04 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Apr  4 
11:57:28 2021 +0300| [15fcb6592e6ee966f369b96d4a8152e752d2f659] | committer: 
Rémi Denis-Courmont

gnutls: fix priority descriptions (fixes #22775)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=15fcb6592e6ee966f369b96d4a8152e752d2f659
---

 modules/misc/gnutls.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/misc/gnutls.c b/modules/misc/gnutls.c
index 49079d43d0..6975076494 100644
--- a/modules/misc/gnutls.c
+++ b/modules/misc/gnutls.c
@@ -745,8 +745,8 @@ static const char *const priorities_values[] = {
 static const char *const priorities_text[] = {
 N_("Performance (prioritize faster ciphers)"),
 N_("Normal"),
-N_("Secure 128-bits (exclude 256-bits ciphers)"),
-N_("Secure 256-bits (prioritize 256-bits ciphers)"),
+N_("Secure 128-bit (or higher)"),
+N_("Secure 256-bit (exclude 128-bit ciphers)"),
 };
 
 vlc_module_begin ()

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] xdg-shell: acknowledge size change timely (fixes #25112)

2021-03-15 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Feb  9 
19:03:59 2021 +0200| [4c46e884eeb68022fec7c0c77e7f708761e561be] | committer: 
Rémi Denis-Courmont

xdg-shell: acknowledge size change timely (fixes #25112)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4c46e884eeb68022fec7c0c77e7f708761e561be
---

 modules/video_output/wayland/xdg-shell.c | 32 ++--
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/modules/video_output/wayland/xdg-shell.c 
b/modules/video_output/wayland/xdg-shell.c
index 0b0eba0be0..3a91114caf 100644
--- a/modules/video_output/wayland/xdg-shell.c
+++ b/modules/video_output/wayland/xdg-shell.c
@@ -157,7 +157,20 @@ static void *Thread(void *data)
 //return NULL;
 }
 
-static void ReportSize(vout_window_t *wnd)
+static void ResizeAck(vout_window_t *wnd, void *data)
+{
+#ifdef XDG_SHELL
+vout_window_sys_t *sys = wnd->sys;
+uint32_t *serial = data;
+
+if (serial != NULL)
+xdg_surface_ack_configure(sys->surface, *serial);
+#else
+(void) wnd; (void) data;
+#endif
+}
+
+static void ReportSize(vout_window_t *wnd, void *data)
 {
 vout_window_sys_t *sys = wnd->sys;
 /* Zero wm.width or zero wm.height means the client should choose.
@@ -165,7 +178,7 @@ static void ReportSize(vout_window_t *wnd)
 unsigned width = sys->wm.width ? sys->wm.width : sys->set.width;
 unsigned height = sys->wm.height ? sys->wm.height : sys->set.height;
 
-vout_window_ReportSize(wnd, width, height);
+wnd->owner.cbs->resized(wnd, width, height, ResizeAck, data);
 xdg_surface_set_window_geometry(sys->surface, 0, 0, width, height);
 }
 
@@ -184,7 +197,7 @@ static void Resize(vout_window_t *wnd, unsigned width, 
unsigned height)
 vlc_mutex_lock(>lock);
 sys->set.width = width;
 sys->set.height = height;
-ReportSize(wnd);
+ReportSize(wnd, NULL);
 vlc_mutex_unlock(>lock);
 wl_display_flush(wnd->display.wl);
 }
@@ -330,23 +343,22 @@ static void xdg_surface_configure_cb(void *data, struct 
xdg_surface *surface,
 vout_window_t *wnd = data;
 vout_window_sys_t *sys = wnd->sys;
 
-vlc_mutex_lock(>lock);
-sys->wm.width = sys->wm.latch.width;
-sys->wm.height = sys->wm.latch.height;
-ReportSize(wnd);
-vlc_mutex_unlock(>lock);
-
 if (sys->wm.latch.fullscreen)
 vout_window_ReportFullscreen(wnd, NULL);
 else
 vout_window_ReportWindowed(wnd);
 
-xdg_surface_ack_configure(surface, serial);
+vlc_mutex_lock(>lock);
+sys->wm.width = sys->wm.latch.width;
+sys->wm.height = sys->wm.latch.height;
+ReportSize(wnd, );
+vlc_mutex_unlock(>lock);
 
 vlc_mutex_lock(>lock);
 sys->wm.configured = true;
 vlc_cond_signal(>cond_configured);
 vlc_mutex_unlock(>lock);
+(void) surface;
 }
 
 static const struct xdg_surface_listener xdg_surface_cbs =

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] v4l2: limit PTS delay

2021-03-15 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Mon Mar 15 
18:59:25 2021 +0200| [9e15fb2864a5f74062b793a2718d194df96d3a43] | committer: 
Rémi Denis-Courmont

v4l2: limit PTS delay

There really is no point having the PTS delay over the frame interval;
it just adds unnecessary latency. This should probably be even lower to
improve streaming responsiveness.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9e15fb2864a5f74062b793a2718d194df96d3a43
---

 modules/access/v4l2/demux.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/modules/access/v4l2/demux.c b/modules/access/v4l2/demux.c
index 00f02ee76e..5ae1989f5a 100644
--- a/modules/access/v4l2/demux.c
+++ b/modules/access/v4l2/demux.c
@@ -58,6 +58,7 @@ typedef struct
 es_out_id_t *es;
 vlc_v4l2_ctrl_t *controls;
 vlc_tick_t start;
+vlc_tick_t interval;
 
 #ifdef ZVBI_COMPILED
 vlc_v4l2_vbi_t *vbi;
@@ -406,6 +407,10 @@ static int InitVideo (demux_t *demux, int fd, uint32_t 
caps)
 es_fmt.video.i_frame_rate_base = parm.parm.capture.timeperframe.numerator;
 GetAR (fd, _fmt.video.i_sar_num, _fmt.video.i_sar_den);
 
+sys->interval = vlc_tick_from_samples(
+parm.parm.capture.timeperframe.numerator,
+parm.parm.capture.timeperframe.denominator);
+
 msg_Dbg (demux, "color primaries: %u", fmt.fmt.pix.colorspace);
 switch (fmt.fmt.pix.colorspace)
 {
@@ -848,9 +853,14 @@ static int DemuxControl( demux_t *demux, int query, 
va_list args )
 return VLC_SUCCESS;
 
 case DEMUX_GET_PTS_DELAY:
-*va_arg(args,vlc_tick_t *) = VLC_TICK_FROM_MS(
-var_InheritInteger( demux, "live-caching" ) );
+{
+vlc_tick_t *pd = va_arg(args, vlc_tick_t *);
+
+*pd = VLC_TICK_FROM_MS(var_InheritInteger(demux, "live-caching"));
+if (*pd > sys->interval)
+*pd = sys->interval; /* cap at one frame, more than enough */
 return VLC_SUCCESS;
+}
 
 case DEMUX_GET_TIME:
 *va_arg (args, vlc_tick_t *) = vlc_tick_now() - sys->start;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] vout: add a resize acknowledgement callback

2021-03-15 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Feb  9 
18:39:56 2021 +0200| [919ba1c9d3f66bda7b737824f87651ad9014d72c] | committer: 
Rémi Denis-Courmont

vout: add a resize acknowledgement callback

For perfect rendering synchronisation, the change of window size must
be acknowledged after the last picture is rendered in the old size,
and before the first picture is rendered in the new size.

As of c9d6d95f291b1e2c0e4f374f87790af091282c1e, the window resize is
processed synchronously. This provides for the "after" requirement. But
it failed to address the "before" requirement: the video output thread
can end render a picture so soon after the resize so the window
callback thread has not had time to perform acknowledgement procedures.

This adds a callback to the window resize event which is called before
the display lock (or equivalent) is released. This is guaranteed to be
invoked before the video output thread has the opportunity to render
anything.

Other options were considered:

1) Invoking a callback to the window provider from the video output
   thread code code.
   -> This can delay the callback unreasonably.
   -> Taking the window lock on the video output thread is undesirable
  if at all possible.

2) Invoking a windowing system type-specific callback to the window
   provider from every display of that windowing system.
   -> Same delay and locking problems as 1.
   -> Requires patching several display plugins.

3) Exposing the display lock to the window plugin, via new callbacks.
   -> This leaks internal implementation of the core to window
  providers.
   -> This gets really confusing as some callbacks would need explicit
  locking and others not.

In comparison, this patch seems like the least of evils.

The callback is passed a parameter rather than as a property of the
window to distinguish it from the existing window callbacks which are
not reentrant.

Refs #25112.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=919ba1c9d3f66bda7b737824f87651ad9014d72c
---

 include/vlc_vout_window.h| 20 ++--
 modules/video_output/splitter.c  |  6 +-
 src/video_output/opengl.c|  6 +-
 src/video_output/video_output.c  |  6 +-
 src/video_output/vout_internal.h |  3 ++-
 src/video_output/window.c| 21 +++--
 6 files changed, 54 insertions(+), 8 deletions(-)

diff --git a/include/vlc_vout_window.h b/include/vlc_vout_window.h
index ea16d4b414..dd4e67a86e 100644
--- a/include/vlc_vout_window.h
+++ b/include/vlc_vout_window.h
@@ -173,6 +173,11 @@ typedef struct vout_window_cfg_t {
 
 } vout_window_cfg_t;
 
+/**
+ * Callback prototype for window event acknowledgement.
+ */
+typedef void (*vout_window_ack_cb)(struct vout_window_t *, void *);
+
 /**
  * Window event callbacks structure.
  *
@@ -199,8 +204,19 @@ struct vout_window_callbacks {
  * change is requested. It may also occur asynchronously as a consequence
  * of external events from the windowing system, or deferred processing of
  * a size change request.
+ *
+ * If a non-NULL acknowledgement callback is specified, it is called
+ * synchronously after the consumer of the window has been notified of the
+ * size change, and before any further processing by the consumer. In other
+ * words, the callback invocation is after all rendering operations using
+ * the previous old window size, and before all rendering operations using
+ * the new window size.
+ *
+ * \param cb optional acknowledgement callback function (NULL to ignore)
+ * \param opaque opaque data pointer for the acknowledgement callback
  */
-void (*resized)(struct vout_window_t *, unsigned width, unsigned height);
+void (*resized)(struct vout_window_t *, unsigned width, unsigned height,
+vout_window_ack_cb cb, void *opaque);
 
 /**
  * Callback for window closing.
@@ -543,7 +559,7 @@ void vout_window_Disable(vout_window_t *window);
 static inline void vout_window_ReportSize(vout_window_t *window,
   unsigned width, unsigned height)
 {
-window->owner.cbs->resized(window, width, height);
+window->owner.cbs->resized(window, width, height, NULL, NULL);
 }
 
 /**
diff --git a/modules/video_output/splitter.c b/modules/video_output/splitter.c
index 6ca82e34c1..9a2a1544e7 100644
--- a/modules/video_output/splitter.c
+++ b/modules/video_output/splitter.c
@@ -135,7 +135,8 @@ static void vlc_vidsplit_Close(vout_display_t *vd)
 }
 
 static void vlc_vidsplit_window_Resized(vout_window_t *wnd,
-unsigned width, unsigned height)
+unsigned width, unsigned height,
+vout_window_ack_cb cb, void *opaque)
 {
 struct vlc_vidsplit_part *part = wnd->owner.sys;
 
@@ -145,6 +146,9 @@ static void vlc_vidsplit_win

[vlc-commits] v4l2: fix best resolution search

2021-03-09 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Mar  9 
18:11:52 2021 +0200| [dd9cdd1c52ec08d7b7889182c0829332797d03af] | committer: 
Rémi Denis-Courmont

v4l2: fix best resolution search

Actually provide the resolution being tested for frame rates
to FindMaxRate().

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dd9cdd1c52ec08d7b7889182c0829332797d03af
---

 modules/access/v4l2/video.c | 28 +---
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/modules/access/v4l2/video.c b/modules/access/v4l2/video.c
index 1949933c72..45968a1996 100644
--- a/modules/access/v4l2/video.c
+++ b/modules/access/v4l2/video.c
@@ -473,6 +473,8 @@ int SetupFormat (vlc_object_t *obj, int fd, uint32_t fourcc,
 
 msg_Dbg (obj, " frame size %"PRIu32"x%"PRIu32,
  fse.discrete.width, fse.discrete.height);
+fmt->fmt.pix.width = fse.discrete.width;
+fmt->fmt.pix.height = fse.discrete.height;
 FindMaxRate (obj, fd, fmt, _it, _it);
 
 int64_t c = fcmp (_it, _it);
@@ -481,14 +483,16 @@ int SetupFormat (vlc_object_t *obj, int fd, uint32_t 
fourcc,
 {
 best_it = cur_it;
 best_area = area;
-fmt->fmt.pix.width = fse.discrete.width;
-fmt->fmt.pix.height = fse.discrete.height;
+width = fmt->fmt.pix.width;
+height = fmt->fmt.pix.height;
 }
 
 fse.index++;
 }
 while (v4l2_ioctl (fd, VIDIOC_ENUM_FRAMESIZES, ) >= 0);
 
+fmt->fmt.pix.width = width;
+fmt->fmt.pix.height = height;
 msg_Dbg (obj, " best discrete frame size: %"PRIu32"x%"PRIu32,
  fmt->fmt.pix.width, fmt->fmt.pix.height);
 break;
@@ -504,29 +508,31 @@ int SetupFormat (vlc_object_t *obj, int fd, uint32_t 
fourcc,
  fse.stepwise.step_width, fse.stepwise.step_height);
 
 /* FIXME: slow and dumb */
-for (width =  fse.stepwise.min_width;
- width <= fse.stepwise.max_width;
- width += fse.stepwise.step_width)
-for (height =  fse.stepwise.min_height;
- height <= fse.stepwise.max_height;
- height += fse.stepwise.step_height)
+for (fmt->fmt.pix.width =  fse.stepwise.min_width;
+ fmt->fmt.pix.width <= fse.stepwise.max_width;
+ fmt->fmt.pix.width += fse.stepwise.step_width)
+for (fmt->fmt.pix.height =  fse.stepwise.min_height;
+ fmt->fmt.pix.height <= fse.stepwise.max_height;
+ fmt->fmt.pix.height += fse.stepwise.step_height)
 {
 struct v4l2_fract cur_it;
 
 FindMaxRate (obj, fd, fmt, _it, _it);
 
 int64_t c = fcmp (_it, _it);
-uint64_t area = width * height;
+uint64_t area = fmt->fmt.pix.width * fmt->fmt.pix.height;
 
 if (c < 0 || (c == 0 && area > best_area))
 {
 best_it = cur_it;
 best_area = area;
-fmt->fmt.pix.width = width;
-fmt->fmt.pix.height = height;
+width = fmt->fmt.pix.width;
+height = fmt->fmt.pix.height;
 }
 }
 
+fmt->fmt.pix.width = width;
+fmt->fmt.pix.height = height;
 msg_Dbg (obj, " best frame size: %"PRIu32"x%"PRIu32,
  fmt->fmt.pix.width, fmt->fmt.pix.height);
 break;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] v4l2: typo in debug

2021-03-09 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Mar  9 
17:06:51 2021 +0200| [e0d0214c0a46191a0e65f31ebcab9e11a7454653] | committer: 
Rémi Denis-Courmont

v4l2: typo in debug

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e0d0214c0a46191a0e65f31ebcab9e11a7454653
---

 modules/access/v4l2/video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/access/v4l2/video.c b/modules/access/v4l2/video.c
index 473cfdb9d3..1949933c72 100644
--- a/modules/access/v4l2/video.c
+++ b/modules/access/v4l2/video.c
@@ -439,7 +439,7 @@ int SetupFormat (vlc_object_t *obj, int fd, uint32_t fourcc,
 
 if (var_InheritURational(obj, _it.denominator, _it.numerator,
  CFG_PREFIX"fps") == VLC_SUCCESS)
-msg_Dbg (obj, " requested frame internal: %"PRIu32"/%"PRIu32,
+msg_Dbg (obj, " requested frame interval: %"PRIu32"/%"PRIu32,
  min_it.numerator, min_it.denominator);
 else
 min_it = zero;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] v4l2: typo

2021-03-09 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Mar  9 
17:03:40 2021 +0200| [caf49489bd212ad903a5300e9aa97842eb2ea233] | committer: 
Rémi Denis-Courmont

v4l2: typo

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=caf49489bd212ad903a5300e9aa97842eb2ea233
---

 modules/access/v4l2/video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/access/v4l2/video.c b/modules/access/v4l2/video.c
index 4a4802368b..473cfdb9d3 100644
--- a/modules/access/v4l2/video.c
+++ b/modules/access/v4l2/video.c
@@ -314,7 +314,7 @@ static const struct v4l2_fract zero = { 0, 1 };
  * Finds the highest frame rate up to a specific limit possible with a certain
  * V4L2 format.
  * @param fmt V4L2 capture format [IN]
- * @param min_it minimum frame internal [IN]
+ * @param min_it minimum frame interval [IN]
  * @param it V4L2 frame interval [OUT]
  * @return 0 on success, -1 on error.
  */

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] fluidsynth: search /usr/share/soundfonts (fixes #25742)

2021-02-17 Thread Rémi Denis-Courmont
vlc/vlc-3.0 | branch: master | Rémi Denis-Courmont  | Wed Feb 
17 20:49:38 2021 +0200| [749948666d471e5e890aca731be1b49d1808e909] | committer: 
Rémi Denis-Courmont

fluidsynth: search /usr/share/soundfonts (fixes #25742)

(cherry picked from commit 4f3ebb95b92195b82eea68e2e0510534bf13fec1)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=749948666d471e5e890aca731be1b49d1808e909
---

 modules/codec/fluidsynth.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/modules/codec/fluidsynth.c b/modules/codec/fluidsynth.c
index f461f3fd14..1212603281 100644
--- a/modules/codec/fluidsynth.c
+++ b/modules/codec/fluidsynth.c
@@ -129,7 +129,10 @@ static int Open (vlc_object_t *p_this)
 {
 glob_t gl;
 
-glob ("/usr/share/sounds/sf2/*.sf2", GLOB_NOESCAPE, NULL, );
+glob("/usr/share/sounds/sf2/*.sf2", GLOB_NOESCAPE, NULL, );
+glob("/usr/share/soundfonts/*.sf2", GLOB_NOESCAPE | GLOB_APPEND, NULL,
+ );
+
 for (size_t i = 0; i < gl.gl_pathc; i++)
 {
 const char *path = gl.gl_pathv[i];

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] fluidsynth: search /usr/share/soundfonts (fixes #25742)

2021-02-17 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Wed Feb 17 
20:49:38 2021 +0200| [4f3ebb95b92195b82eea68e2e0510534bf13fec1] | committer: 
Rémi Denis-Courmont

fluidsynth: search /usr/share/soundfonts (fixes #25742)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4f3ebb95b92195b82eea68e2e0510534bf13fec1
---

 modules/codec/fluidsynth.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/modules/codec/fluidsynth.c b/modules/codec/fluidsynth.c
index 2e704097dd..2913781844 100644
--- a/modules/codec/fluidsynth.c
+++ b/modules/codec/fluidsynth.c
@@ -127,7 +127,10 @@ static int Open (vlc_object_t *p_this)
 {
 glob_t gl;
 
-glob ("/usr/share/sounds/sf2/*.sf2", GLOB_NOESCAPE, NULL, );
+glob("/usr/share/sounds/sf2/*.sf2", GLOB_NOESCAPE, NULL, );
+glob("/usr/share/soundfonts/*.sf2", GLOB_NOESCAPE | GLOB_APPEND, NULL,
+ );
+
 for (size_t i = 0; i < gl.gl_pathc; i++)
 {
 const char *path = gl.gl_pathv[i];

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] ytdl: fix/update parameter for playlist extraction

2021-02-12 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Feb  2 
19:21:25 2021 +0200| [af9f18300650e2c6b67f0372b6613d6d8be7d9ae] | committer: 
Rémi Denis-Courmont

ytdl: fix/update parameter for playlist extraction

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=af9f18300650e2c6b67f0372b6613d6d8be7d9ae
---

 share/ytdl-extract.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/share/ytdl-extract.py b/share/ytdl-extract.py
index bce6a82ee9..88f00e026b 100755
--- a/share/ytdl-extract.py
+++ b/share/ytdl-extract.py
@@ -33,7 +33,7 @@ class logger(object):
 
 def url_extract(url):
 opts = {
-'extract_flat': True,
+'extract_flat': 'in_playlist',
 'logger': logger(),
 'youtube_include_dash_manifest': False,
 }

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] include: use vlc_rational_t for display zoom

2021-02-12 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Feb  9 
18:13:18 2021 +0200| [91033fbb2d712487cbb8f5538c76e3bb52cde85e] | committer: 
Rémi Denis-Courmont

include: use vlc_rational_t for display zoom

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=91033fbb2d712487cbb8f5538c76e3bb52cde85e
---

 include/vlc_vout_display.h | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 58a0c2e430..36018a9542 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -119,10 +119,7 @@ typedef struct vout_display_cfg {
 bool is_display_filled;
 
 /** Zoom ratio */
-struct {
-unsigned num;
-unsigned den;
-} zoom;
+vlc_rational_t zoom;
 
 vlc_viewpoint_t viewpoint;
 } vout_display_cfg_t;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] vout: use vlc_rational_t for crop ratio

2021-02-12 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Feb  9 
18:13:35 2021 +0200| [21b2004eef4330fc018ca22dd05897f759766652] | committer: 
Rémi Denis-Courmont

vout: use vlc_rational_t for crop ratio

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=21b2004eef4330fc018ca22dd05897f759766652
---

 src/video_output/vout_internal.h | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index 02e7b90612..fb24b51ee8 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -107,10 +107,7 @@ enum vout_crop_mode {
 struct vout_crop {
 enum vout_crop_mode mode;
 union {
-struct {
-unsigned num;
-unsigned den;
-} ratio;
+vlc_rational_t ratio;
 struct {
 unsigned x;
 unsigned y;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] omxil: fix integer types on LP64 platforms

2021-02-12 Thread Rémi Denis-Courmont
vlc/vlc-3.0 | branch: master | Rémi Denis-Courmont  | Fri Feb 
12 18:35:59 2021 +0200| [f128680a57f9c06928100c12b37d4b7850d179f3] | committer: 
Rémi Denis-Courmont

omxil: fix integer types on LP64 platforms

This resyncs the integer type definition with the official
OpenMAX IL 1.1.2 sources. In particular, this fixes U32 and S32 which
were wrongly defined as long thus breaking binary compatibility on
Linux/arm64.

Fixes LP#1913530.

(cherry picked from commit 368c2f3762ae7aff909ae008c58d967e63d2efaf)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=f128680a57f9c06928100c12b37d4b7850d179f3
---

 modules/codec/omxil/OMX_Types.h | 20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/modules/codec/omxil/OMX_Types.h b/modules/codec/omxil/OMX_Types.h
index 76fa234e7d..38ca04d44c 100644
--- a/modules/codec/omxil/OMX_Types.h
+++ b/modules/codec/omxil/OMX_Types.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008 The Khronos Group Inc. 
+ * Copyright (c) 2016 The Khronos Group Inc.
  * 
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -31,6 +31,8 @@
 #ifndef OMX_Types_h
 #define OMX_Types_h
 
+#include 
+
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
@@ -130,22 +132,22 @@ extern "C" {
   */ 
 
 /** OMX_U8 is an 8 bit unsigned quantity that is byte aligned */
-typedef unsigned char OMX_U8;
+typedef uint8_t OMX_U8;
 
 /** OMX_S8 is an 8 bit signed quantity that is byte aligned */
-typedef signed char OMX_S8;
+typedef int8_t OMX_S8;
 
 /** OMX_U16 is a 16 bit unsigned quantity that is 16 bit word aligned */
-typedef unsigned short OMX_U16;
+typedef uint16_t OMX_U16;
 
 /** OMX_S16 is a 16 bit signed quantity that is 16 bit word aligned */
-typedef signed short OMX_S16;
+typedef int16_t OMX_S16;
 
 /** OMX_U32 is a 32 bit unsigned quantity that is 32 bit word aligned */
-typedef unsigned long OMX_U32;
+typedef uint32_t OMX_U32;
 
 /** OMX_S32 is a 32 bit signed quantity that is 32 bit word aligned */
-typedef signed long OMX_S32;
+typedef int32_t OMX_S32;
 
 
 /* Users with compilers that cannot accept the "long long" designation should
@@ -173,10 +175,10 @@ typedef signed   __int64  OMX_S64;
 #else /* _WIN32 */
 
 /** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */
-typedef unsigned long long OMX_U64;
+typedef uint64_t OMX_U64;
 
 /** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */
-typedef signed long long OMX_S64;
+typedef int64_t OMX_S64;
 
 #endif /* _WIN32 */
 #endif

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] omxil: fix integer types on LP64 platforms

2021-02-12 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Fri Feb 12 
18:35:59 2021 +0200| [368c2f3762ae7aff909ae008c58d967e63d2efaf] | committer: 
Rémi Denis-Courmont

omxil: fix integer types on LP64 platforms

This resyncs the integer type definition with the official
OpenMAX IL 1.1.2 sources. In particular, this fixes U32 and S32 which
were wrongly defined as long thus breaking binary compatibility on
Linux/arm64.

Fixes LP#1913530.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=368c2f3762ae7aff909ae008c58d967e63d2efaf
---

 modules/codec/omxil/OMX_Types.h | 20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/modules/codec/omxil/OMX_Types.h b/modules/codec/omxil/OMX_Types.h
index 76fa234e7d..38ca04d44c 100644
--- a/modules/codec/omxil/OMX_Types.h
+++ b/modules/codec/omxil/OMX_Types.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008 The Khronos Group Inc. 
+ * Copyright (c) 2016 The Khronos Group Inc.
  * 
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -31,6 +31,8 @@
 #ifndef OMX_Types_h
 #define OMX_Types_h
 
+#include 
+
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
@@ -130,22 +132,22 @@ extern "C" {
   */ 
 
 /** OMX_U8 is an 8 bit unsigned quantity that is byte aligned */
-typedef unsigned char OMX_U8;
+typedef uint8_t OMX_U8;
 
 /** OMX_S8 is an 8 bit signed quantity that is byte aligned */
-typedef signed char OMX_S8;
+typedef int8_t OMX_S8;
 
 /** OMX_U16 is a 16 bit unsigned quantity that is 16 bit word aligned */
-typedef unsigned short OMX_U16;
+typedef uint16_t OMX_U16;
 
 /** OMX_S16 is a 16 bit signed quantity that is 16 bit word aligned */
-typedef signed short OMX_S16;
+typedef int16_t OMX_S16;
 
 /** OMX_U32 is a 32 bit unsigned quantity that is 32 bit word aligned */
-typedef unsigned long OMX_U32;
+typedef uint32_t OMX_U32;
 
 /** OMX_S32 is a 32 bit signed quantity that is 32 bit word aligned */
-typedef signed long OMX_S32;
+typedef int32_t OMX_S32;
 
 
 /* Users with compilers that cannot accept the "long long" designation should
@@ -173,10 +175,10 @@ typedef signed   __int64  OMX_S64;
 #else /* _WIN32 */
 
 /** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */
-typedef unsigned long long OMX_U64;
+typedef uint64_t OMX_U64;
 
 /** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */
-typedef signed long long OMX_S64;
+typedef int64_t OMX_S64;
 
 #endif /* _WIN32 */
 #endif

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] vout: remove no-op assignments

2021-02-08 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sat Feb  6 
17:50:59 2021 +0200| [03694150b2fb57aed63b4b1f9d5da57c66a5eaef] | committer: 
Rémi Denis-Courmont

vout: remove no-op assignments

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=03694150b2fb57aed63b4b1f9d5da57c66a5eaef
---

 src/video_output/display.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/video_output/display.c b/src/video_output/display.c
index 3dd0faa574..06fb16ffc1 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -457,8 +457,8 @@ static int vout_UpdateSourceCrop(vout_display_t *vd)
 {
 vout_display_priv_t *osys = container_of(vd, vout_display_priv_t, display);
 video_format_t fmt = osys->source;
-unsigned crop_num = osys->crop.num;
-unsigned crop_den = osys->crop.den;
+const unsigned crop_num = osys->crop.num;
+const unsigned crop_den = osys->crop.den;
 
 if (crop_num != 0 && crop_den != 0) {
 VoutDisplayCropRatio(>crop.left,  >crop.top,
@@ -503,8 +503,6 @@ static int vout_UpdateSourceCrop(vout_display_t *vd)
 (osys->source.i_x_offset + 
osys->source.i_visible_width);
 osys->crop.bottom = bottom -
 (osys->source.i_y_offset + 
osys->source.i_visible_height);
-osys->crop.num= crop_num;
-osys->crop.den= crop_den;
 return ret;
 }
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] vout: use struct vout_crop in display

2021-02-08 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sat Feb  6 
18:14:24 2021 +0200| [63384a250570bf26c7cedd3061f6df64f8958cbf] | committer: 
Rémi Denis-Courmont

vout: use struct vout_crop in display

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=63384a250570bf26c7cedd3061f6df64f8958cbf
---

 src/video_output/display.c | 105 -
 1 file changed, 36 insertions(+), 69 deletions(-)

diff --git a/src/video_output/display.c b/src/video_output/display.c
index 6d91d57849..06dd9533db 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -263,15 +263,7 @@ typedef struct {
 
 /* */
 vout_display_cfg_t cfg;
-
-struct {
-int  left;
-int  top;
-int  right;
-int  bottom;
-unsigned num;
-unsigned den;
-} crop;
+struct vout_crop crop;
 
 /* */
 video_format_t source;
@@ -457,35 +449,48 @@ static int vout_UpdateSourceCrop(vout_display_t *vd)
 {
 vout_display_priv_t *osys = container_of(vd, vout_display_priv_t, display);
 video_format_t fmt = osys->source;
-const unsigned crop_num = osys->crop.num;
-const unsigned crop_den = osys->crop.den;
+int left, top, right, bottom;
 
-if (crop_num != 0 && crop_den != 0) {
-VoutDisplayCropRatio(>crop.left,  >crop.top,
- >crop.right, >crop.bottom,
- >source, crop_num, crop_den);
+switch (osys->crop.mode) {
+case VOUT_CROP_NONE:
+left = top = right = bottom = 0;
+break;
+case VOUT_CROP_RATIO:
+VoutDisplayCropRatio(, , , , >source,
+ osys->crop.ratio.num, osys->crop.ratio.den);
+break;
+case VOUT_CROP_WINDOW:
+left = osys->crop.window.x;
+top = osys->crop.window.y;
+right = osys->crop.window.width;
+bottom = osys->crop.window.height;
+break;
+case VOUT_CROP_BORDER:
+left = osys->crop.border.left;
+top = osys->crop.border.top;
+right = -(int)osys->crop.border.right;
+bottom = -(int)osys->crop.border.bottom;
+break;
 }
 
 const int right_max  = osys->source.i_x_offset
+ osys->source.i_visible_width;
 const int bottom_max = osys->source.i_y_offset
+ osys->source.i_visible_height;
-int left = VLC_CLIP((int)osys->source.i_x_offset + osys->crop.left,
-  0, right_max - 1);
-int top  = VLC_CLIP((int)osys->source.i_y_offset + osys->crop.top,
-0, bottom_max - 1);
-int right, bottom;
-
-if (osys->crop.right <= 0)
-right = (int)(osys->source.i_x_offset + osys->source.i_visible_width) 
+ osys->crop.right;
+
+left = VLC_CLIP((int)osys->source.i_x_offset + left, 0, right_max - 1);
+top  = VLC_CLIP((int)osys->source.i_y_offset + top, 0, bottom_max - 1);
+
+if (right <= 0)
+right = (int)(osys->source.i_x_offset + osys->source.i_visible_width) 
+ right;
 else
-right = (int)osys->source.i_x_offset + osys->crop.right;
+right = (int)osys->source.i_x_offset + right;
 right = VLC_CLIP(right, left + 1, right_max);
 
-if (osys->crop.bottom <= 0)
-bottom = (int)(osys->source.i_y_offset + 
osys->source.i_visible_height) + osys->crop.bottom;
+if (bottom <= 0)
+bottom = (int)(osys->source.i_y_offset + 
osys->source.i_visible_height) + bottom;
 else
-bottom = (int)osys->source.i_y_offset + osys->crop.bottom;
+bottom = (int)osys->source.i_y_offset + bottom;
 bottom = VLC_CLIP(bottom, top + 1, bottom_max);
 
 osys->source.i_x_offset   = left;
@@ -513,8 +518,7 @@ static int vout_SetSourceAspect(vout_display_t *vd,
 ret = -1;
 
 /* If a crop ratio is requested, recompute the parameters */
-if (osys->crop.num != 0 && osys->crop.den != 0
- && vout_UpdateSourceCrop(vd))
+if (osys->crop.mode != VOUT_CROP_NONE && vout_UpdateSourceCrop(vd))
 ret = -1;
 
 return ret;
@@ -622,41 +626,9 @@ void vout_SetDisplayCrop(vout_display_t *vd,
  const struct vout_crop *restrict crop)
 {
 vout_display_priv_t *osys = container_of(vd, vout_display_priv_t, display);
-unsigned crop_num = 0, crop_den = 0, left = 0, top = 0;
-int right = 0, bottom = 0;
-
-switch (crop->mode) {
-case VOUT_CROP_NONE:
-break;
-case VOUT_CROP_RATIO:
-crop_num = crop->ratio.num;
-crop_den = crop->ratio.den;
-break;
-case VOUT_CROP_WINDOW:
-left = crop->window.x;
-top =

[vlc-commits] vout: merge all three vout_SetCrop*() functions

2021-02-08 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sat Feb  6 
17:04:39 2021 +0200| [a2156b735b3349a0d823057f4fb96c9558f2fb6d] | committer: 
Rémi Denis-Courmont

vout: merge all three vout_SetCrop*() functions

...into a single function using struct vout_crop.

Note that the negative guards are removed as the values are unsigned.
No function changes.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a2156b735b3349a0d823057f4fb96c9558f2fb6d
---

 src/video_output/video_output.c | 109 
 1 file changed, 10 insertions(+), 99 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index d6370a35a8..4a76e9f595 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -637,71 +637,14 @@ void vout_ChangeDisplayAspectRatio(vout_thread_t *vout,
 vlc_mutex_unlock(>display_lock);
 }
 
-static void vout_SetCropRatio(vout_thread_sys_t *sys, unsigned num, unsigned 
den)
+static void vout_SetCrop(vout_thread_sys_t *sys,
+ const struct vout_crop *restrict crop)
 {
-if (num != 0 && den != 0) {
-sys->source.crop.mode = VOUT_CROP_RATIO;
-sys->source.crop.ratio.num = num;
-sys->source.crop.ratio.den = den;
-} else
-sys->source.crop.mode = VOUT_CROP_NONE;
-}
-
-static void vout_SetCropWindow(vout_thread_sys_t *sys,
- int x, int y, int width, int height)
-{
-if (x < 0)
-x = 0;
-if (y < 0)
-y = 0;
-if (width < 0)
-width = 0;
-if (height < 0)
-height = 0;
-
-sys->source.crop.mode = VOUT_CROP_WINDOW;
-sys->source.crop.window.x = x;
-sys->source.crop.window.y = y;
-sys->source.crop.window.width = width;
-sys->source.crop.window.height = height;
-}
-
-void vout_ChangeCropWindow(vout_thread_t *vout,
-   int x, int y, int width, int height)
-{
-vout_thread_sys_t *sys = VOUT_THREAD_TO_SYS(vout);
-assert(!sys->dummy);
-
-vlc_mutex_lock(>window_lock);
-vout_SetCropWindow(sys, x, y, width, height);
-
-vout_UpdateWindowSizeLocked(sys);
-
-vlc_mutex_lock(>display_lock);
-vlc_mutex_unlock(>window_lock);
-
-if (sys->display != NULL)
-vout_SetDisplayCrop(sys->display, 0, 0, x, y, width, height);
-vlc_mutex_unlock(>display_lock);
-}
-
-static void vout_SetCropBorder(vout_thread_sys_t *sys,
- int left, int top, int right, int bottom)
-{
-if (left < 0)
-left = 0;
-if (top < 0)
-top = 0;
-if (right < 0)
-right = 0;
-if (bottom < 0)
-bottom = 0;
+sys->source.crop = *crop;
 
-sys->source.crop.mode = VOUT_CROP_BORDER;
-sys->source.crop.border.left = left;
-sys->source.crop.border.right = right;
-sys->source.crop.border.top = top;
-sys->source.crop.border.bottom = bottom;
+if (crop->mode == VOUT_CROP_RATIO
+ && (crop->ratio.num == 0 || crop->ratio.den == 0))
+sys->source.crop.mode = VOUT_CROP_NONE;
 }
 
 void vout_ChangeCrop(vout_thread_t *vout,
@@ -711,23 +654,7 @@ void vout_ChangeCrop(vout_thread_t *vout,
 assert(!sys->dummy);
 
 vlc_mutex_lock(>window_lock);
-switch (crop->mode) {
-case VOUT_CROP_NONE:
-vout_SetCropRatio(sys, 0, 0);
-break;
-case VOUT_CROP_RATIO:
-vout_SetCropRatio(sys, crop->ratio.num, crop->ratio.den);
-break;
-case VOUT_CROP_WINDOW:
-vout_SetCropWindow(sys, crop->window.x, crop->window.y,
-   crop->window.width, crop->window.height);
-break;
-case VOUT_CROP_BORDER:
-vout_SetCropBorder(sys, crop->border.left, crop->border.top,
-   crop->border.right, crop->border.bottom);
-break;
-}
-
+vout_SetCrop(sys, crop);
 vout_UpdateWindowSizeLocked(sys);
 
 vlc_mutex_lock(>display_lock);
@@ -750,7 +677,8 @@ void vout_ChangeCrop(vout_thread_t *vout,
 case VOUT_CROP_BORDER:
 vout_SetDisplayCrop(sys->display, 0, 0,
 crop->border.left, crop->border.top,
--crop->border.right, -crop->border.bottom);
+-(int)crop->border.right,
+-(int)crop->border.bottom);
 break;
 }
 
@@ -2232,24 +2160,7 @@ static void vout_InitSource(vout_thread_sys_t *vout)
 struct vout_crop crop;
 
 if (vout_ParseCrop(, psz_crop))
-{
-switch (crop.mode)
-{
-case VOUT_CROP_RATIO:
-vout_SetCropRatio(vout, crop.ratio.num, crop.ratio.den);
-b

[vlc-commits] vout: add vout_CropEqual() helper

2021-02-08 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sat Feb  6 
18:23:52 2021 +0200| [21ad125944ed747ba776f7d96c4b26413c56d1ed] | committer: 
Rémi Denis-Courmont

vout: add vout_CropEqual() helper

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=21ad125944ed747ba776f7d96c4b26413c56d1ed
---

 src/video_output/vout_internal.h | 20 
 1 file changed, 20 insertions(+)

diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index f795af64e5..02e7b90612 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -126,6 +126,26 @@ struct vout_crop {
 };
 };
 
+static inline bool vout_CropEqual(const struct vout_crop *a,
+  const struct vout_crop *b)
+{
+if (a->mode != b->mode)
+return false;
+
+switch (a->mode) {
+case VOUT_CROP_NONE:
+return true;
+case VOUT_CROP_RATIO:
+return a->ratio.num * b->ratio.den == b->ratio.num * a->ratio.den;
+case VOUT_CROP_WINDOW:
+return memcmp(>window, >window, sizeof (a->window)) == 0;
+case VOUT_CROP_BORDER:
+return memcmp(>border, >border, sizeof (a->border)) == 0;
+default:
+vlc_assert_unreachable();
+}
+}
+
 bool vout_ParseCrop(struct vout_crop *, const char *crop_str);
 bool GetAspectRatio(const char *ar_str, unsigned *num, unsigned *den);
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] vout: don't clobber crop borders when updating

2021-02-08 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sat Feb  6 
17:59:10 2021 +0200| [0697ef19db666888c304a87893d47d4ffef60467] | committer: 
Rémi Denis-Courmont

vout: don't clobber crop borders when updating

The vout_UpdateSourceCrop() function uses the crop borders as both
inputs and outputs. There does not seem to be any good reason to
overwrite the values though.

Within vout_UpdateSourceCrop(), the value should actually not change
(much like the aspect ratio numerator and denominator in the previous
patchset), except for rounding errors and out-of-bound results.

The values are used in only one other function, vout_SetDisplayCrop().
There, old and new values are compared to avoid needlessly resetting
the display. Those comparisons actually work correctly only if the
values are *not* modified by vout_UpdateSourceCrop().

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0697ef19db666888c304a87893d47d4ffef60467
---

 src/video_output/display.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/src/video_output/display.c b/src/video_output/display.c
index 06fb16ffc1..6d91d57849 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -495,15 +495,7 @@ static int vout_UpdateSourceCrop(vout_display_t *vd)
 video_format_Print(VLC_OBJECT(vd), "SOURCE ", );
 video_format_Print(VLC_OBJECT(vd), "CROPPED ", >source);
 
-int ret = vout_display_Control(vd, VOUT_DISPLAY_CHANGE_SOURCE_CROP);
-osys->crop.left   = left - osys->source.i_x_offset;
-osys->crop.top= top  - osys->source.i_y_offset;
-/* FIXME for right/bottom we should keep the 'type' border vs window */
-osys->crop.right  = right -
-(osys->source.i_x_offset + 
osys->source.i_visible_width);
-osys->crop.bottom = bottom -
-(osys->source.i_y_offset + 
osys->source.i_visible_height);
-return ret;
+return vout_display_Control(vd, VOUT_DISPLAY_CHANGE_SOURCE_CROP);
 }
 
 static int vout_SetSourceAspect(vout_display_t *vd,

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] vout: merge all three vout_ChangeCrop*()

2021-02-08 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sat Feb  6 
16:59:49 2021 +0200| [3339a4c65fb0826b728fce028af29ccc05665dd5] | committer: 
Rémi Denis-Courmont

vout: merge all three vout_ChangeCrop*()

...into a single function using struct vout_crop.
This also fixes setting the "crop" variable to the empty string to
actually undo the crop settings. It was incorrectly ignored.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3339a4c65fb0826b728fce028af29ccc05665dd5
---

 src/video_output/video_output.c  | 61 +---
 src/video_output/vout_internal.h |  4 +--
 src/video_output/vout_intf.c | 23 +++
 3 files changed, 43 insertions(+), 45 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 9ca6dab765..d6370a35a8 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -647,24 +647,6 @@ static void vout_SetCropRatio(vout_thread_sys_t *sys, 
unsigned num, unsigned den
 sys->source.crop.mode = VOUT_CROP_NONE;
 }
 
-void vout_ChangeCropRatio(vout_thread_t *vout, unsigned num, unsigned den)
-{
-vout_thread_sys_t *sys = VOUT_THREAD_TO_SYS(vout);
-assert(!sys->dummy);
-
-vlc_mutex_lock(>window_lock);
-vout_SetCropRatio(sys, num, den);
-
-vout_UpdateWindowSizeLocked(sys);
-
-vlc_mutex_lock(>display_lock);
-vlc_mutex_unlock(>window_lock);
-
-if (sys->display != NULL)
-vout_SetDisplayCrop(sys->display, num, den, 0, 0, 0, 0);
-vlc_mutex_unlock(>display_lock);
-}
-
 static void vout_SetCropWindow(vout_thread_sys_t *sys,
  int x, int y, int width, int height)
 {
@@ -722,14 +704,29 @@ static void vout_SetCropBorder(vout_thread_sys_t *sys,
 sys->source.crop.border.bottom = bottom;
 }
 
-void vout_ChangeCropBorder(vout_thread_t *vout,
-   int left, int top, int right, int bottom)
+void vout_ChangeCrop(vout_thread_t *vout,
+ const struct vout_crop *restrict crop)
 {
 vout_thread_sys_t *sys = VOUT_THREAD_TO_SYS(vout);
 assert(!sys->dummy);
 
 vlc_mutex_lock(>window_lock);
-vout_SetCropBorder(sys, left, top, right, bottom);
+switch (crop->mode) {
+case VOUT_CROP_NONE:
+vout_SetCropRatio(sys, 0, 0);
+break;
+case VOUT_CROP_RATIO:
+vout_SetCropRatio(sys, crop->ratio.num, crop->ratio.den);
+break;
+case VOUT_CROP_WINDOW:
+vout_SetCropWindow(sys, crop->window.x, crop->window.y,
+   crop->window.width, crop->window.height);
+break;
+case VOUT_CROP_BORDER:
+vout_SetCropBorder(sys, crop->border.left, crop->border.top,
+   crop->border.right, crop->border.bottom);
+break;
+}
 
 vout_UpdateWindowSizeLocked(sys);
 
@@ -737,8 +734,26 @@ void vout_ChangeCropBorder(vout_thread_t *vout,
 vlc_mutex_unlock(>window_lock);
 
 if (sys->display != NULL)
-vout_SetDisplayCrop(sys->display, 0, 0,
-left, top, -right, -bottom);
+switch (crop->mode) {
+case VOUT_CROP_NONE:
+vout_SetDisplayCrop(sys->display, 0, 0, 0, 0, 0, 0);
+break;
+case VOUT_CROP_RATIO:
+vout_SetDisplayCrop(sys->display, crop->ratio.num,
+crop->ratio.den, 0, 0, 0, 0);
+break;
+case VOUT_CROP_WINDOW:
+vout_SetDisplayCrop(sys->display, 0, 0,
+crop->window.x, crop->window.y,
+crop->window.width, crop->window.height);
+break;
+case VOUT_CROP_BORDER:
+vout_SetDisplayCrop(sys->display, 0, 0,
+crop->border.left, crop->border.top,
+-crop->border.right, -crop->border.bottom);
+break;
+}
+
 vlc_mutex_unlock(>display_lock);
 }
 
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index 42e5748d54..f795af64e5 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -137,9 +137,7 @@ void vout_ChangeDisplaySize(vout_thread_t *, unsigned 
width, unsigned height);
 void vout_ChangeDisplayFilled(vout_thread_t *, bool is_filled);
 void vout_ChangeZoom(vout_thread_t *, unsigned num, unsigned den);
 void vout_ChangeDisplayAspectRatio(vout_thread_t *, unsigned num, unsigned 
den);
-void vout_ChangeCropRatio(vout_thread_t *, unsigned num, unsigned den);
-void vout_ChangeCropWindow(vout_thread_t *, int x, int y, int width, int 
height);
-void vout_ChangeCropBorder(vout_thread_t *, int left, int top, int right, int 
bottom);

[vlc-commits] vout: parse crop string into dedicated structure

2021-02-08 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sat Feb  6 
16:43:45 2021 +0200| [ade9dd9cd1030bcf5aaddb0ba27c4b167103ccac] | committer: 
Rémi Denis-Courmont

vout: parse crop string into dedicated structure

This changes the parser function to output into a single structure
rather than half a dozen different variables.

No functional changes.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ade9dd9cd1030bcf5aaddb0ba27c4b167103ccac
---

 src/video_output/video_output.c  | 18 --
 src/video_output/vout_internal.h |  5 +
 src/video_output/vout_intf.c | 41 +++-
 3 files changed, 28 insertions(+), 36 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index d01bf880d6..9ca6dab765 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -2214,24 +2214,22 @@ static void vout_InitSource(vout_thread_sys_t *vout)
 
 char *psz_crop = var_InheritString(>obj, "crop");
 if (psz_crop) {
-unsigned num, den;
-unsigned y, x;
-unsigned width, height;
-enum vout_crop_mode mode;
+struct vout_crop crop;
 
-if (GetCropMode(psz_crop, , , ,
-, , , ))
+if (vout_ParseCrop(, psz_crop))
 {
-switch (mode)
+switch (crop.mode)
 {
 case VOUT_CROP_RATIO:
-vout_SetCropRatio(vout, num, den);
+vout_SetCropRatio(vout, crop.ratio.num, crop.ratio.den);
 break;
 case VOUT_CROP_WINDOW:
-vout_SetCropWindow(vout, x, y, width, height);
+vout_SetCropWindow(vout, crop.window.x, crop.window.y,
+   crop.window.width, crop.window.height);
 break;
 case VOUT_CROP_BORDER:
-vout_SetCropBorder(vout, x, y, width, height);
+vout_SetCropBorder(vout, crop.border.left, crop.border.top,
+   crop.border.right, crop.border.bottom);
 break;
 case VOUT_CROP_NONE:
 break;
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index a351106224..42e5748d54 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -126,10 +126,7 @@ struct vout_crop {
 };
 };
 
-bool GetCropMode(const char *crop_str, enum vout_crop_mode *mode,
-unsigned *num, unsigned *den,
-unsigned *x, unsigned *y,
-unsigned *width, unsigned *height );
+bool vout_ParseCrop(struct vout_crop *, const char *crop_str);
 bool GetAspectRatio(const char *ar_str, unsigned *num, unsigned *den);
 
 /* TODO to move them to vlc_vout.h */
diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c
index a4ea6bf5af..daa1d70eab 100644
--- a/src/video_output/vout_intf.c
+++ b/src/video_output/vout_intf.c
@@ -449,22 +449,21 @@ exit:
 free( psz_path );
 }
 
-bool GetCropMode(const char *crop_str, enum vout_crop_mode *mode,
-unsigned *num, unsigned *den,
-unsigned *x, unsigned *y,
-unsigned *width, unsigned *height )
+bool vout_ParseCrop(struct vout_crop *restrict cfg, const char *crop_str)
 {
-if (sscanf(crop_str, "%u:%u", num, den) == 2) {
-*mode = VOUT_CROP_RATIO;
+if (sscanf(crop_str, "%u:%u", >ratio.num, >ratio.den) == 2) {
+cfg->mode = VOUT_CROP_RATIO;
 } else if (sscanf(crop_str, "%ux%u+%u+%u",
-  width, height, x, y) == 4) {
-*mode = VOUT_CROP_WINDOW;
+  >window.width, >window.height,
+  >window.x, >window.y) == 4) {
+cfg->mode = VOUT_CROP_WINDOW;
 } else if (sscanf(crop_str, "%u+%u+%u+%u",
-x, y, width, height) == 4) {
-*mode = VOUT_CROP_BORDER;
+  >border.left, >border.top,
+  >border.right, >border.bottom) == 4) {
+cfg->mode = VOUT_CROP_BORDER;
 } else if (*crop_str == '\0') {
-*mode = VOUT_CROP_RATIO;
-*num = *den = 0;
+cfg->mode = VOUT_CROP_RATIO;
+cfg->ratio.num = cfg->ratio.den = 0;
 } else {
 return false;
 }
@@ -479,23 +478,21 @@ static int CropCallback( vlc_object_t *object, char const 
*cmd,
 {
 vout_thread_t *vout = (vout_thread_t *)object;
 VLC_UNUSED(cmd); VLC_UNUSED(oldval); VLC_UNUSED(data);
-unsigned num, den;
-unsigned y, x;
-unsigned width, height;
-enum vout_crop_mode mode;
+struct vout_crop crop;
 
-if (GetCropMode(newval.psz_string, , , ,
-, , , )) {
-switch (mode)
+if (vout_ParseCrop(, newval.psz_string)) {
+switch (crop.

[vlc-commits] vout: handle crop=0:0 case in parser

2021-02-08 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sat Feb  6 
17:38:23 2021 +0200| [ba8632047c114083f1e4c77e1c5a3cbf2c65ef97] | committer: 
Rémi Denis-Courmont

vout: handle crop=0:0 case in parser

...and simplify accordingly.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ba8632047c114083f1e4c77e1c5a3cbf2c65ef97
---

 src/video_output/video_output.c | 18 +++---
 src/video_output/vout_intf.c|  8 +---
 2 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 5d9502fed9..d04d3f4d11 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -637,16 +637,6 @@ void vout_ChangeDisplayAspectRatio(vout_thread_t *vout,
 vlc_mutex_unlock(>display_lock);
 }
 
-static void vout_SetCrop(vout_thread_sys_t *sys,
- const struct vout_crop *restrict crop)
-{
-sys->source.crop = *crop;
-
-if (crop->mode == VOUT_CROP_RATIO
- && (crop->ratio.num == 0 || crop->ratio.den == 0))
-sys->source.crop.mode = VOUT_CROP_NONE;
-}
-
 void vout_ChangeCrop(vout_thread_t *vout,
  const struct vout_crop *restrict crop)
 {
@@ -654,7 +644,7 @@ void vout_ChangeCrop(vout_thread_t *vout,
 assert(!sys->dummy);
 
 vlc_mutex_lock(>window_lock);
-vout_SetCrop(sys, crop);
+sys->source.crop = *crop;
 vout_UpdateWindowSizeLocked(sys);
 
 vlc_mutex_lock(>display_lock);
@@ -2115,10 +2105,8 @@ static void vout_InitSource(vout_thread_sys_t *vout)
 
 char *psz_crop = var_InheritString(>obj, "crop");
 if (psz_crop) {
-struct vout_crop crop;
-
-if (vout_ParseCrop(, psz_crop))
-vout_SetCrop(vout, );
+if (!vout_ParseCrop(>source.crop, psz_crop))
+vout->source.crop.mode = VOUT_CROP_NONE;
 free(psz_crop);
 }
 }
diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c
index 1a20350527..0ed4f6bb87 100644
--- a/src/video_output/vout_intf.c
+++ b/src/video_output/vout_intf.c
@@ -452,7 +452,10 @@ exit:
 bool vout_ParseCrop(struct vout_crop *restrict cfg, const char *crop_str)
 {
 if (sscanf(crop_str, "%u:%u", >ratio.num, >ratio.den) == 2) {
-cfg->mode = VOUT_CROP_RATIO;
+if (cfg->ratio.num != 0 && cfg->ratio.den != 0)
+cfg->mode = VOUT_CROP_RATIO;
+else
+cfg->mode = VOUT_CROP_NONE;
 } else if (sscanf(crop_str, "%ux%u+%u+%u",
   >window.width, >window.height,
   >window.x, >window.y) == 4) {
@@ -462,8 +465,7 @@ bool vout_ParseCrop(struct vout_crop *restrict cfg, const 
char *crop_str)
   >border.right, >border.bottom) == 4) {
 cfg->mode = VOUT_CROP_BORDER;
 } else if (*crop_str == '\0') {
-cfg->mode = VOUT_CROP_RATIO;
-cfg->ratio.num = cfg->ratio.den = 0;
+cfg->mode = VOUT_CROP_NONE;
 } else {
 return false;
 }

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] vout: use struct vout_crop for vout_SetDisplayCrop()

2021-02-08 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sat Feb  6 
17:20:38 2021 +0200| [f3e233c6b7a7db8ac087239a11ba8c85289e0402] | committer: 
Rémi Denis-Courmont

vout: use struct vout_crop for vout_SetDisplayCrop()

No functional changes.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f3e233c6b7a7db8ac087239a11ba8c85289e0402
---

 src/video_output/display.c  | 27 --
 src/video_output/video_output.c | 50 -
 src/video_output/vout_wrapper.h |  4 ++--
 3 files changed, 31 insertions(+), 50 deletions(-)

diff --git a/src/video_output/display.c b/src/video_output/display.c
index b66fe39c55..3dd0faa574 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -42,6 +42,7 @@
 
 #include "display.h"
 #include "window.h"
+#include "vout_internal.h"
 
 /*
  * FIXME/TODO see how to have direct rendering here (interact with vout.c)
@@ -628,10 +629,32 @@ void vout_SetDisplayAspect(vout_display_t *vd, unsigned 
dar_num, unsigned dar_de
 }
 
 void vout_SetDisplayCrop(vout_display_t *vd,
- unsigned crop_num, unsigned crop_den,
- unsigned left, unsigned top, int right, int bottom)
+ const struct vout_crop *restrict crop)
 {
 vout_display_priv_t *osys = container_of(vd, vout_display_priv_t, display);
+unsigned crop_num = 0, crop_den = 0, left = 0, top = 0;
+int right = 0, bottom = 0;
+
+switch (crop->mode) {
+case VOUT_CROP_NONE:
+break;
+case VOUT_CROP_RATIO:
+crop_num = crop->ratio.num;
+crop_den = crop->ratio.den;
+break;
+case VOUT_CROP_WINDOW:
+left = crop->window.x;
+top = crop->window.y;
+right = crop->window.width;
+bottom = crop->window.height;
+break;
+case VOUT_CROP_BORDER:
+left = crop->border.left;
+top = crop->border.top;
+right = -(int)crop->border.right;
+bottom = -(int)crop->border.bottom;
+break;
+}
 
 if (osys->crop.left  != (int)left  || osys->crop.top != (int)top ||
 osys->crop.right != right || osys->crop.bottom != bottom ||
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 4a76e9f595..5d9502fed9 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -661,27 +661,7 @@ void vout_ChangeCrop(vout_thread_t *vout,
 vlc_mutex_unlock(>window_lock);
 
 if (sys->display != NULL)
-switch (crop->mode) {
-case VOUT_CROP_NONE:
-vout_SetDisplayCrop(sys->display, 0, 0, 0, 0, 0, 0);
-break;
-case VOUT_CROP_RATIO:
-vout_SetDisplayCrop(sys->display, crop->ratio.num,
-crop->ratio.den, 0, 0, 0, 0);
-break;
-case VOUT_CROP_WINDOW:
-vout_SetDisplayCrop(sys->display, 0, 0,
-crop->window.x, crop->window.y,
-crop->window.width, crop->window.height);
-break;
-case VOUT_CROP_BORDER:
-vout_SetDisplayCrop(sys->display, 0, 0,
-crop->border.left, crop->border.top,
--(int)crop->border.right,
--(int)crop->border.bottom);
-break;
-}
-
+vout_SetDisplayCrop(sys->display, crop);
 vlc_mutex_unlock(>display_lock);
 }
 
@@ -1699,8 +1679,7 @@ static int vout_Start(vout_thread_sys_t *vout, 
vlc_video_context *vctx, const vo
 sys->filter.chain_interactive = filter_chain_NewVideo(>obj, true, 
);
 
 vout_display_cfg_t dcfg;
-int x = 0, y = 0, w = 0, h = 0;
-unsigned crop_num = 0, crop_den = 0;
+struct vout_crop crop;
 unsigned num, den;
 
 vlc_mutex_lock(>window_lock);
@@ -1715,28 +1694,7 @@ static int vout_Start(vout_thread_sys_t *vout, 
vlc_video_context *vctx, const vo
 #endif
 
 dcfg = sys->display_cfg;
-
-switch (sys->source.crop.mode) {
-case VOUT_CROP_NONE:
-break;
-case VOUT_CROP_RATIO:
-crop_num = sys->source.crop.ratio.num;
-crop_den = sys->source.crop.ratio.den;
-break;
-case VOUT_CROP_WINDOW:
-x = sys->source.crop.window.x;
-y = sys->source.crop.window.y;
-w = sys->source.crop.window.width;
-h = sys->source.crop.window.height;
-break;
-case VOUT_CROP_BORDER:
-x = sys->source.crop.border.left;
-y = sys->source.crop.bord

[vlc-commits] vout: define crop configuration as a type

2021-02-08 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sat Feb  6 
16:31:45 2021 +0200| [99d330411073b83f72b8c545d3aa57f0907820ff] | committer: 
Rémi Denis-Courmont

vout: define crop configuration as a type

This creates a separate structure type for the crop configuration.
No functional changes.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=99d330411073b83f72b8c545d3aa57f0907820ff
---

 src/video_output/video_output.c  | 22 +-
 src/video_output/vout_internal.h | 23 +++
 2 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 323b40c084..d01bf880d6 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -82,27 +82,7 @@ typedef struct vout_thread_sys_t
 /* */
 struct {
 vlc_rational_t dar;
-struct {
-enum vout_crop_mode mode;
-union {
-struct {
-unsigned num;
-unsigned den;
-} ratio;
-struct {
-unsigned x;
-unsigned y;
-unsigned width;
-unsigned height;
-} window;
-struct {
-unsigned left;
-unsigned right;
-unsigned top;
-unsigned bottom;
-} border;
-};
-} crop;
+struct vout_crop crop;
 } source;
 
 /* Snapshot interface */
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index ef92f1c889..a351106224 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -103,6 +103,29 @@ int vout_ChangeSource( vout_thread_t *p_vout, const 
video_format_t *fmt );
 enum vout_crop_mode {
 VOUT_CROP_NONE, VOUT_CROP_RATIO, VOUT_CROP_WINDOW, VOUT_CROP_BORDER,
 };
+
+struct vout_crop {
+enum vout_crop_mode mode;
+union {
+struct {
+unsigned num;
+unsigned den;
+} ratio;
+struct {
+unsigned x;
+unsigned y;
+unsigned width;
+unsigned height;
+} window;
+struct {
+unsigned left;
+unsigned right;
+unsigned top;
+unsigned bottom;
+} border;
+};
+};
+
 bool GetCropMode(const char *crop_str, enum vout_crop_mode *mode,
 unsigned *num, unsigned *den,
 unsigned *x, unsigned *y,

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] Revert "pulse: use pa_stream_begin_write()" (fixes #25187)

2021-02-08 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sat Feb  6 
11:34:32 2021 +0200| [bab6469b0a73bd3801a58fd1c3bba4ecbcb40e55] | committer: 
Rémi Denis-Courmont

Revert "pulse: use pa_stream_begin_write()" (fixes #25187)

Contrary to claims in the commit message, it introduces an extra memory
copy of all audio samples for no apparent reasons.

This reverts commit 0bdc7268dc450de0e4b2944726f366cb340eca21.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bab6469b0a73bd3801a58fd1c3bba4ecbcb40e55
---

 modules/audio_output/pulse.c | 47 ++--
 1 file changed, 32 insertions(+), 15 deletions(-)

diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index fba8fd6840..907f32fab6 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -458,6 +458,30 @@ static int TimeGet(audio_output_t *aout, vlc_tick_t 
*restrict delay)
 return ret;
 }
 
+/* Memory free callback. The block_t address is in front of the data. */
+static void data_free(void *data)
+{
+block_t **pp = data, *block;
+
+memcpy(, pp - 1, sizeof (block));
+block_Release(block);
+}
+
+static void *data_convert(block_t **pp)
+{
+block_t *block = *pp;
+/* In most cases, there is enough head room, and this is really cheap: */
+block = block_Realloc(block, sizeof (block), block->i_buffer);
+*pp = block;
+if (unlikely(block == NULL))
+return NULL;
+
+memcpy(block->p_buffer, , sizeof (block));
+block->p_buffer += sizeof (block);
+block->i_buffer -= sizeof (block);
+return block->p_buffer;
+}
+
 /**
  * Queue one audio frame to the playback stream
  */
@@ -466,6 +490,11 @@ static void Play(audio_output_t *aout, block_t *block, 
vlc_tick_t date)
 aout_sys_t *sys = aout->sys;
 pa_stream *s = sys->stream;
 
+const void *ptr = data_convert();
+if (unlikely(ptr == NULL))
+return;
+
+size_t len = block->i_buffer;
 
 /* Note: The core already holds the output FIFO lock at this point.
  * Therefore we must not under any circumstances (try to) acquire the
@@ -486,24 +515,12 @@ static void Play(audio_output_t *aout, block_t *block, 
vlc_tick_t date)
 pa_operation_unref(pa_stream_flush(s, NULL, NULL));
 }
 #endif
-while (block->i_buffer > 0)
-{
-void *ptr;
-size_t len = block->i_buffer;
-
-if (pa_stream_begin_write(s, , ))
-vlc_pa_error(aout, "cannot begin write", sys->context);
 
-memcpy(ptr, block->p_buffer, len);
-block->p_buffer += len;
-block->i_buffer -= len;
-
-if (pa_stream_write(s, ptr, len, NULL, 0, PA_SEEK_RELATIVE) < 0)
-vlc_pa_error(aout, "cannot write", sys->context);
+if (pa_stream_write(s, ptr, len, data_free, 0, PA_SEEK_RELATIVE) < 0) {
+vlc_pa_error(aout, "cannot write", sys->context);
+block_Release(block);
 }
 
-block_Release(block);
-
 pa_threaded_mainloop_unlock(sys->mainloop);
 }
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] Revert "url: Remove duplicated path separators" (fixes #25374)

2021-02-07 Thread Rémi Denis-Courmont
vlc/vlc-3.0 | branch: master | Rémi Denis-Courmont  | Fri Feb  
5 23:50:29 2021 +0200| [af6c9e78cf4f5595ba55976138177a4b0b4fe140] | committer: 
Rémi Denis-Courmont

Revert "url: Remove duplicated path separators" (fixes #25374)

This was just plain wrong. Multiple forward slashes does not generally
have the same meaning as a single one. This notably broke some FTP and
DLNA servers.

This reverts commit 043988a2519f557856f14578b790da66283645fc.

(cherry picked from commit 2090c051abb8d3b15fd1824c394897eedda63c7f)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=af6c9e78cf4f5595ba55976138177a4b0b4fe140
---

 src/test/url.c | 20 
 src/text/url.c | 21 -
 2 files changed, 41 deletions(-)

diff --git a/src/test/url.c b/src/test/url.c
index e170d8b0ab..ab02571ac7 100644
--- a/src/test/url.c
+++ b/src/test/url.c
@@ -158,16 +158,6 @@ static void test_fixup_noop(const char *expected)
 test(vlc_uri_fixup, expected, expected);
 }
 
-static char *vlc_uri_resolve_separators_test(const char *in)
-{
-return vlc_uri_resolve("file:///a/b/c//d.ext", in);
-}
-
-static void test_separators(const char *reference, const char *expected)
-{
-test(vlc_uri_resolve_separators_test, reference, expected);
-}
-
 int main (void)
 {
 (void)setvbuf (stdout, NULL, _IONBF, 0);
@@ -373,16 +363,6 @@ int main (void)
 
 for (size_t i = 0; i < ARRAY_SIZE(rfc3986_cases); i += 2)
 test_rfc3986(rfc3986_cases[i], rfc3986_cases[i + 1]);
-static const char* separators_patterns[] = {
-"../",  "file:///a/b/",
-"./",   "file:///a/b/c/",
-"../../../../../../../","file:///",
-"..///","file:///a/b/",
-".///", "file:///a/b/c/",
-"..//..//", "file:///a/",
-};
-for (size_t i = 0; i < ARRAY_SIZE(separators_patterns); i += 2)
-test_separators(separators_patterns[i], separators_patterns[i + 1]);
 
 /* Check that fixup does not mangle valid URIs */
 static const char *valid_uris[] =
diff --git a/src/text/url.c b/src/text/url.c
index c3c36015d7..83bba30e09 100644
--- a/src/text/url.c
+++ b/src/text/url.c
@@ -401,26 +401,6 @@ static bool vlc_uri_path_validate(const char *str)
 return vlc_uri_component_validate(str, "/@:");
 }
 
-static void vlc_uri_fixup_duplicated_separators(char *str)
-{
-if (str == NULL)
-return;
-char *input = str, *output = str;
-while (*input)
-{
-assert(input >= output);
-if (*input == '/')
-{
-*output++ = *input;
-while (*input == '/')
-input++;
-}
-else
-*output++ = *input++;
-}
-*output = 0;
-}
-
 static int vlc_UrlParseInner(vlc_url_t *restrict url, const char *str)
 {
 url->psz_protocol = NULL;
@@ -568,7 +548,6 @@ static int vlc_UrlParseInner(vlc_url_t *restrict url, const 
char *str)
 {
 url->psz_path = cur;
 }
-vlc_uri_fixup_duplicated_separators(url->psz_path);
 
 return ret;
 }

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] Revert "url: Remove duplicated path separators" (fixes #25374)

2021-02-07 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Fri Feb  5 
23:50:29 2021 +0200| [2090c051abb8d3b15fd1824c394897eedda63c7f] | committer: 
Rémi Denis-Courmont

Revert "url: Remove duplicated path separators" (fixes #25374)

This was just plain wrong. Multiple forward slashes does not generally
have the same meaning as a single one. This notably broke some FTP and
DLNA servers.

This reverts commit 043988a2519f557856f14578b790da66283645fc.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2090c051abb8d3b15fd1824c394897eedda63c7f
---

 src/test/url.c | 20 
 src/text/url.c | 21 -
 2 files changed, 41 deletions(-)

diff --git a/src/test/url.c b/src/test/url.c
index 5f31047c2d..d2b4361169 100644
--- a/src/test/url.c
+++ b/src/test/url.c
@@ -164,16 +164,6 @@ static void test_rfc3986(const char *reference, const char 
*expected)
 test(vlc_uri_resolve_rfc3986_test, reference, expected);
 }
 
-static char *vlc_uri_resolve_separators_test(const char *in)
-{
-return vlc_uri_resolve("file:///a/b/c//d.ext", in);
-}
-
-static void test_separators(const char *reference, const char *expected)
-{
-test(vlc_uri_resolve_separators_test, reference, expected);
-}
-
 int main (void)
 {
 (void)setvbuf (stdout, NULL, _IONBF, 0);
@@ -385,16 +375,6 @@ int main (void)
 
 for (size_t i = 0; i < ARRAY_SIZE(rfc3986_cases); i += 2)
 test_rfc3986(rfc3986_cases[i], rfc3986_cases[i + 1]);
-static const char* separators_patterns[] = {
-"../",  "file:///a/b/",
-"./",   "file:///a/b/c/",
-"../../../../../../../","file:///",
-"..///","file:///a/b/",
-".///", "file:///a/b/c/",
-"..//..//", "file:///a/",
-};
-for (size_t i = 0; i < ARRAY_SIZE(separators_patterns); i += 2)
-test_separators(separators_patterns[i], separators_patterns[i + 1]);
 
 /* Check that fixup does not mangle valid URIs */
 static const char *valid_uris[] =
diff --git a/src/text/url.c b/src/text/url.c
index 9e5eb6cff7..0c15a9bcb7 100644
--- a/src/text/url.c
+++ b/src/text/url.c
@@ -407,26 +407,6 @@ static bool vlc_uri_path_validate(const char *str)
 return vlc_uri_component_validate(str, "/@:");
 }
 
-static void vlc_uri_fixup_duplicated_separators(char *str)
-{
-if (str == NULL)
-return;
-char *input = str, *output = str;
-while (*input)
-{
-assert(input >= output);
-if (*input == '/')
-{
-*output++ = *input;
-while (*input == '/')
-input++;
-}
-else
-*output++ = *input++;
-}
-*output = 0;
-}
-
 static int vlc_UrlParseInner(vlc_url_t *restrict url, const char *str)
 {
 url->psz_protocol = NULL;
@@ -571,7 +551,6 @@ static int vlc_UrlParseInner(vlc_url_t *restrict url, const 
char *str)
 {
 url->psz_path = cur;
 }
-vlc_uri_fixup_duplicated_separators(url->psz_path);
 
 return ret;
 }

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] qt: reparent video window to root whence UI closes

2021-02-06 Thread Rémi Denis-Courmont
vlc/vlc-3.0 | branch: master | Rémi Denis-Courmont  | Fri Feb  
5 19:46:15 2021 +0200| [3463f12d15aa8ae793b4e96518fa44f4f19edf7f] | committer: 
Rémi Denis-Courmont

qt: reparent video window to root whence UI closes

The video window has to exist until it is closed by its owner, i.e.
WindowClose() is called. If it stayed as a child of the main UI window,
it would be destroyed with the main UI window.

This reparents it (back) to the root window before the main UI window
gets destroyed. This works around #21875.

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=3463f12d15aa8ae793b4e96518fa44f4f19edf7f
---

 modules/gui/qt/components/interface_widgets.cpp |  2 ++
 modules/gui/qt/main_interface.cpp   |  2 ++
 modules/gui/qt/qt.cpp   | 25 +
 3 files changed, 29 insertions(+)

diff --git a/modules/gui/qt/components/interface_widgets.cpp 
b/modules/gui/qt/components/interface_widgets.cpp
index 74e82eab58..ff44bf2e44 100644
--- a/modules/gui/qt/components/interface_widgets.cpp
+++ b/modules/gui/qt/components/interface_widgets.cpp
@@ -229,6 +229,7 @@ QSize VideoWidget::physicalSize() const
 }
 
 void WindowResized(vout_window_t *, const QSize&);
+void WindowReleased(vout_window_t *);
 
 void VideoWidget::reportSize()
 {
@@ -378,6 +379,7 @@ void VideoWidget::release( void )
 
 if( stable )
 {
+WindowReleased(p_window);
 layout->removeWidget( stable );
 stable->deleteLater();
 stable = NULL;
diff --git a/modules/gui/qt/main_interface.cpp 
b/modules/gui/qt/main_interface.cpp
index 259dcf7109..a57506533d 100644
--- a/modules/gui/qt/main_interface.cpp
+++ b/modules/gui/qt/main_interface.cpp
@@ -1664,6 +1664,8 @@ void MainInterface::closeEvent( QCloseEvent *e )
 //  hide();
 if ( b_minimalView )
 setMinimalView( false );
+if( videoWidget )
+releaseVideoSlot();
 emit askToQuit(); /* ask THEDP to quit, so we have a unique method */
 /* Accept session quit. Otherwise we break the desktop mamager. */
 e->accept();
diff --git a/modules/gui/qt/qt.cpp b/modules/gui/qt/qt.cpp
index ded2a908de..eda2752897 100644
--- a/modules/gui/qt/qt.cpp
+++ b/modules/gui/qt/qt.cpp
@@ -714,6 +714,8 @@ typedef struct {
 #ifdef QT5_HAS_X11
 Display *dpy;
 #endif
+bool orphaned;
+QMutex lock;
 } vout_window_qt_t;
 
 static int WindowOpen( vout_window_t *p_wnd, const vout_window_cfg_t *cfg )
@@ -748,6 +750,7 @@ static int WindowOpen( vout_window_t *p_wnd, const 
vout_window_cfg_t *cfg )
 vout_window_qt_t *sys = new vout_window_qt_t;
 
 sys->mi = p_intf->p_sys->p_mi;
+sys->orphaned = false;
 p_wnd->sys = (vout_window_sys_t *)sys;
 msg_Dbg( p_wnd, "requesting video window..." );
 
@@ -785,6 +788,8 @@ static int WindowOpen( vout_window_t *p_wnd, const 
vout_window_cfg_t *cfg )
 #ifdef QT5_HAS_X11
 if (QX11Info::isPlatformX11())
 {
+QMutexLocker locker2(>lock);
+
 XReparentWindow(sys->dpy, xid, p_wnd->handle.xid, 0, 0);
 XMapWindow(sys->dpy, xid);
 XSync(sys->dpy, True);
@@ -824,6 +829,26 @@ static int WindowControl( vout_window_t *p_wnd, int 
i_query, va_list args )
 return sys->mi->controlVideo(i_query, args);
 }
 
+void WindowReleased(vout_window_t *wnd)
+{
+vout_window_qt_t *sys = (vout_window_qt_t *)wnd->sys;
+QMutexLocker locker(>lock);
+
+msg_Warn(wnd, "orphaned video window");
+sys->orphaned = true;
+#if defined (QT5_HAS_X11)
+if (QX11Info::isPlatformX11())
+{   /* In the unlikely event that WindowOpen() has not yet reparented the
+ * window, WindowOpen() will skip reparenting. Then this call will be
+ * a no-op.
+ */
+XReparentWindow(sys->dpy, wnd->handle.xid,
+RootWindow(sys->dpy, DefaultScreen(sys->dpy)), 0, 0);
+XSync(sys->dpy, True);
+}
+#endif
+}
+
 static void WindowClose( vout_window_t *p_wnd )
 {
 vout_window_qt_t *sys = (vout_window_qt_t *)p_wnd->sys;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] qt: create another indirection X11 window

2021-02-06 Thread Rémi Denis-Courmont
vlc/vlc-3.0 | branch: master | Rémi Denis-Courmont  | Fri Feb  
5 19:25:48 2021 +0200| [7b7f767b4e1d0c97db918e07dbf0dc41cb4138d8] | committer: 
Rémi Denis-Courmont

qt: create another indirection X11 window

The main window may be destroyed before the video window. This notably
occurs if the user requests to close the main UI via window decorations.
While Qt allows those requests to be rejected, doing so would
reintroduce obnoxious bug #4606.

The Qt-X11 display connection will be closed as well as it belongs to
the QApplication instance.

This creates a separate window belonging to a separate display
connection, and which is not tied to the QApplication and QMainWindow
instances. Unfortunately, this adds yet another connection to the X11
display server in the VLC process in addition to QApplication's and the
video display's. And that connection won't process events.

Refs #21875.

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=7b7f767b4e1d0c97db918e07dbf0dc41cb4138d8
---

 modules/gui/qt/components/interface_widgets.cpp |  4 +-
 modules/gui/qt/qt.cpp   | 59 -
 2 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/modules/gui/qt/components/interface_widgets.cpp 
b/modules/gui/qt/components/interface_widgets.cpp
index ced7d9f8c7..74e82eab58 100644
--- a/modules/gui/qt/components/interface_widgets.cpp
+++ b/modules/gui/qt/components/interface_widgets.cpp
@@ -228,13 +228,15 @@ QSize VideoWidget::physicalSize() const
 return current_size;
 }
 
+void WindowResized(vout_window_t *, const QSize&);
+
 void VideoWidget::reportSize()
 {
 if( !p_window )
 return;
 
 QSize size = physicalSize();
-vout_window_ReportSize( p_window, size.width(), size.height() );
+WindowResized(p_window, size);
 }
 
 /* Set the Widget to the correct Size */
diff --git a/modules/gui/qt/qt.cpp b/modules/gui/qt/qt.cpp
index 1ebea361aa..ded2a908de 100644
--- a/modules/gui/qt/qt.cpp
+++ b/modules/gui/qt/qt.cpp
@@ -361,6 +361,7 @@ static void Abort( void *obj )
 
 #if defined (QT5_HAS_X11)
 # include 
+# include 
 
 static void *ThreadXCB( void *data )
 {
@@ -710,6 +711,9 @@ static int WindowControl( vout_window_t *, int i_query, 
va_list );
 
 typedef struct {
 MainInterface *mi;
+#ifdef QT5_HAS_X11
+Display *dpy;
+#endif
 } vout_window_qt_t;
 
 static int WindowOpen( vout_window_t *p_wnd, const vout_window_cfg_t *cfg )
@@ -744,20 +748,69 @@ static int WindowOpen( vout_window_t *p_wnd, const 
vout_window_cfg_t *cfg )
 vout_window_qt_t *sys = new vout_window_qt_t;
 
 sys->mi = p_intf->p_sys->p_mi;
+p_wnd->sys = (vout_window_sys_t *)sys;
 msg_Dbg( p_wnd, "requesting video window..." );
 
+#ifdef QT5_HAS_X11
+Window xid;
+
+if (QX11Info::isPlatformX11())
+{
+sys->dpy = XOpenDisplay(NULL);
+if (unlikely(sys->dpy == NULL))
+{
+delete sys;
+return VLC_EGENERIC;
+}
+
+int snum = DefaultScreen(sys->dpy);
+unsigned long black = BlackPixel(sys->dpy, snum);
+
+xid = XCreateSimpleWindow(sys->dpy, RootWindow(sys->dpy, snum),
+  0, 0, cfg->width, cfg->height,
+  0, black, black);
+}
+#endif
+
 if (!sys->mi->getVideo(p_wnd, cfg->width, cfg->height, cfg->is_fullscreen))
 {
+#ifdef QT5_HAS_X11
+if (QX11Info::isPlatformX11())
+XCloseDisplay(sys->dpy);
+#endif
 delete sys;
 return VLC_EGENERIC;
 }
 
+#ifdef QT5_HAS_X11
+if (QX11Info::isPlatformX11())
+{
+XReparentWindow(sys->dpy, xid, p_wnd->handle.xid, 0, 0);
+XMapWindow(sys->dpy, xid);
+XSync(sys->dpy, True);
+p_wnd->handle.xid = xid;
+}
+#endif
 p_wnd->info.has_double_click = true;
 p_wnd->control = WindowControl;
-p_wnd->sys = (vout_window_sys_t *)sys;
 return VLC_SUCCESS;
 }
 
+void WindowResized(vout_window_t *wnd, const QSize& size)
+{
+#ifdef QT5_HAS_X11
+vout_window_qt_t *sys = (vout_window_qt_t *)wnd->sys;
+
+if (QX11Info::isPlatformX11())
+{
+XResizeWindow(sys->dpy, wnd->handle.xid, size.width(), size.height());
+XClearWindow(sys->dpy, wnd->handle.xid);
+XSync(sys->dpy, True);
+}
+#endif
+vout_window_ReportSize(wnd, size.width(), size.height());
+}
+
 static int WindowControl( vout_window_t *p_wnd, int i_query, va_list args )
 {
 vout_window_qt_t *sys = (vout_window_qt_t *)p_wnd->sys;
@@ -793,5 +846,9 @@ static void WindowClose( vout_window_t *p_wnd )
 else
 msg_Warn (p_wnd, "video already released");
 
+#if defined (QT5_HAS_X11)
+if (QX11Info::isPlatformX11())
+XCloseDisplay(sys->dpy);
+#endif
 delete sys;
 }

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] qt: reparent video window to root whence UI closes

2021-02-06 Thread Rémi Denis-Courmont
vlc/vlc-3.0 | branch: master | Rémi Denis-Courmont  | Fri Feb  
5 19:46:15 2021 +0200| [4d147a3d3804fce2451938ee5145e94794f12dbf] | committer: 
Rémi Denis-Courmont

qt: reparent video window to root whence UI closes

The video window has to exist until it is closed by its owner, i.e.
WindowClose() is called. If it stayed as a child of the main UI window,
it would be destroyed with the main UI window.

This reparents it (back) to the root window before the main UI window
gets destroyed. This works around #21875.

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=4d147a3d3804fce2451938ee5145e94794f12dbf
---

 modules/gui/qt/components/interface_widgets.cpp |  2 ++
 modules/gui/qt/main_interface.cpp   |  2 ++
 modules/gui/qt/qt.cpp   | 24 +++-
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/modules/gui/qt/components/interface_widgets.cpp 
b/modules/gui/qt/components/interface_widgets.cpp
index 74e82eab58..ff44bf2e44 100644
--- a/modules/gui/qt/components/interface_widgets.cpp
+++ b/modules/gui/qt/components/interface_widgets.cpp
@@ -229,6 +229,7 @@ QSize VideoWidget::physicalSize() const
 }
 
 void WindowResized(vout_window_t *, const QSize&);
+void WindowReleased(vout_window_t *);
 
 void VideoWidget::reportSize()
 {
@@ -378,6 +379,7 @@ void VideoWidget::release( void )
 
 if( stable )
 {
+WindowReleased(p_window);
 layout->removeWidget( stable );
 stable->deleteLater();
 stable = NULL;
diff --git a/modules/gui/qt/main_interface.cpp 
b/modules/gui/qt/main_interface.cpp
index 259dcf7109..a57506533d 100644
--- a/modules/gui/qt/main_interface.cpp
+++ b/modules/gui/qt/main_interface.cpp
@@ -1664,6 +1664,8 @@ void MainInterface::closeEvent( QCloseEvent *e )
 //  hide();
 if ( b_minimalView )
 setMinimalView( false );
+if( videoWidget )
+releaseVideoSlot();
 emit askToQuit(); /* ask THEDP to quit, so we have a unique method */
 /* Accept session quit. Otherwise we break the desktop mamager. */
 e->accept();
diff --git a/modules/gui/qt/qt.cpp b/modules/gui/qt/qt.cpp
index ded2a908de..8acf42808a 100644
--- a/modules/gui/qt/qt.cpp
+++ b/modules/gui/qt/qt.cpp
@@ -28,6 +28,7 @@
 
 #define VLC_MODULE_LICENSE VLC_LICENSE_GPL_2_PLUS
 
+#include 
 #include 
 #include 
 #include 
@@ -714,6 +715,7 @@ typedef struct {
 #ifdef QT5_HAS_X11
 Display *dpy;
 #endif
+std::atomic orphaned;
 } vout_window_qt_t;
 
 static int WindowOpen( vout_window_t *p_wnd, const vout_window_cfg_t *cfg )
@@ -748,6 +750,7 @@ static int WindowOpen( vout_window_t *p_wnd, const 
vout_window_cfg_t *cfg )
 vout_window_qt_t *sys = new vout_window_qt_t;
 
 sys->mi = p_intf->p_sys->p_mi;
+sys->orphaned = false;
 p_wnd->sys = (vout_window_sys_t *)sys;
 msg_Dbg( p_wnd, "requesting video window..." );
 
@@ -783,7 +786,7 @@ static int WindowOpen( vout_window_t *p_wnd, const 
vout_window_cfg_t *cfg )
 }
 
 #ifdef QT5_HAS_X11
-if (QX11Info::isPlatformX11())
+if (QX11Info::isPlatformX11() && likely(!sys->orphaned))
 {
 XReparentWindow(sys->dpy, xid, p_wnd->handle.xid, 0, 0);
 XMapWindow(sys->dpy, xid);
@@ -824,6 +827,25 @@ static int WindowControl( vout_window_t *p_wnd, int 
i_query, va_list args )
 return sys->mi->controlVideo(i_query, args);
 }
 
+void WindowReleased(vout_window_t *wnd)
+{
+vout_window_qt_t *sys = (vout_window_qt_t *)wnd->sys;
+
+msg_Warn(wnd, "orphaned video window");
+sys->orphaned = true;
+#if defined (QT5_HAS_X11)
+if (QX11Info::isPlatformX11())
+{   /* In the unlikely event that WindowOpen() has not yet reparented the
+ * window, WindowOpen() will skip reparenting. Then this call will be
+ * a no-op.
+ */
+XReparentWindow(sys->dpy, wnd->handle.xid,
+RootWindow(sys->dpy, DefaultScreen(sys->dpy)), 0, 0);
+XSync(sys->dpy, True);
+}
+#endif
+}
+
 static void WindowClose( vout_window_t *p_wnd )
 {
 vout_window_qt_t *sys = (vout_window_qt_t *)p_wnd->sys;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] qt: add a private structure for window provider

2021-02-06 Thread Rémi Denis-Courmont
vlc/vlc-3.0 | branch: master | Rémi Denis-Courmont  | Sat Feb  
6 15:00:02 2021 +0200| [562331eda1dbe35e98dc0cd057fc1a5c58cf0210] | committer: 
Rémi Denis-Courmont

qt: add a private structure for window provider

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=562331eda1dbe35e98dc0cd057fc1a5c58cf0210
---

 modules/gui/qt/qt.cpp | 33 ++---
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/modules/gui/qt/qt.cpp b/modules/gui/qt/qt.cpp
index cbd197750a..1ebea361aa 100644
--- a/modules/gui/qt/qt.cpp
+++ b/modules/gui/qt/qt.cpp
@@ -708,6 +708,10 @@ static void ShowDialog( intf_thread_t *p_intf, int 
i_dialog_event, int i_arg,
  */
 static int WindowControl( vout_window_t *, int i_query, va_list );
 
+typedef struct {
+MainInterface *mi;
+} vout_window_qt_t;
+
 static int WindowOpen( vout_window_t *p_wnd, const vout_window_cfg_t *cfg )
 {
 if( cfg->is_standalone )
@@ -737,21 +741,26 @@ static int WindowOpen( vout_window_t *p_wnd, const 
vout_window_cfg_t *cfg )
 if (unlikely(!active))
 return VLC_EGENERIC;
 
-MainInterface *p_mi = p_intf->p_sys->p_mi;
+vout_window_qt_t *sys = new vout_window_qt_t;
+
+sys->mi = p_intf->p_sys->p_mi;
 msg_Dbg( p_wnd, "requesting video window..." );
 
-if( !p_mi->getVideo( p_wnd, cfg->width, cfg->height, cfg->is_fullscreen ) )
+if (!sys->mi->getVideo(p_wnd, cfg->width, cfg->height, cfg->is_fullscreen))
+{
+delete sys;
 return VLC_EGENERIC;
+}
 
 p_wnd->info.has_double_click = true;
 p_wnd->control = WindowControl;
-p_wnd->sys = (vout_window_sys_t*)p_mi;
+p_wnd->sys = (vout_window_sys_t *)sys;
 return VLC_SUCCESS;
 }
 
 static int WindowControl( vout_window_t *p_wnd, int i_query, va_list args )
 {
-MainInterface *p_mi = (MainInterface *)p_wnd->sys;
+vout_window_qt_t *sys = (vout_window_qt_t *)p_wnd->sys;
 QMutexLocker locker ();
 
 if (unlikely(!active))
@@ -759,12 +768,12 @@ static int WindowControl( vout_window_t *p_wnd, int 
i_query, va_list args )
 msg_Warn (p_wnd, "video already released before control");
 return VLC_EGENERIC;
 }
-return p_mi->controlVideo( i_query, args );
+return sys->mi->controlVideo(i_query, args);
 }
 
 static void WindowClose( vout_window_t *p_wnd )
 {
-MainInterface *p_mi = (MainInterface *)p_wnd->sys;
+vout_window_qt_t *sys = (vout_window_qt_t *)p_wnd->sys;
 QMutexLocker locker ();
 
 /* Normally, the interface terminates after the video. In the contrary, the
@@ -776,11 +785,13 @@ static void WindowClose( vout_window_t *p_wnd )
  * That assumes the video output will behave sanely if it window is
  * destroyed asynchronously.
  * XCB and Xlib-XCB are fine with that. Plain Xlib wouldn't, */
-if (unlikely(!active))
+if (likely(active))
 {
-msg_Warn (p_wnd, "video already released");
-return;
+msg_Dbg(p_wnd, "releasing video...");
+sys->mi->releaseVideo();
 }
-msg_Dbg (p_wnd, "releasing video...");
-p_mi->releaseVideo();
+else
+msg_Warn (p_wnd, "video already released");
+
+delete sys;
 }

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] configure: ignore too new SRT

2021-01-24 Thread Rémi Denis-Courmont
vlc/vlc-3.0 | branch: master | Rémi Denis-Courmont  | Sun Jan 
17 12:16:51 2021 +0200| [3aad852a05d9a3b2469328cb9ea2e20b0acbce5c] | committer: 
Rémi Denis-Courmont

configure: ignore too new SRT

SRT does not maintain backward source compatibility. This breaks the
build on, e.g., Debian unstable.

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=3aad852a05d9a3b2469328cb9ea2e20b0acbce5c
---

 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index fbd2ccd3a3..348bb63c78 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4016,7 +4016,7 @@ AM_CONDITIONAL([HAVE_LIRC], [test "${have_lirc}" = "yes"])
 dnl
 dnl  SRT plugin
 dnl
-PKG_ENABLE_MODULES_VLC([SRT], [access_srt access_output_srt], [srt >= 1.2.2], 
[SRT input/output plugin], [auto], [], [], [-DENABLE_SRT])
+PKG_ENABLE_MODULES_VLC([SRT], [access_srt access_output_srt], [srt >= 1.2.2 
srt < 1.3.0], [SRT input/output plugin], [auto], [], [], [-DENABLE_SRT])
 
 EXTEND_HELP_STRING([Visualisations and Video filter plugins:])
 dnl

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] resource: inline RequestSout()

2021-01-21 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Jan 19 
20:15:31 2021 +0200| [a08aaed0b92f7ba4aad70479c1d9878119431ef9] | committer: 
Rémi Denis-Courmont

resource: inline RequestSout()

(no functional changes)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a08aaed0b92f7ba4aad70479c1d9878119431ef9
---

 src/input/resource.c | 68 ++--
 1 file changed, 29 insertions(+), 39 deletions(-)

diff --git a/src/input/resource.c b/src/input/resource.c
index 1f8a5d5e0e..7c4716251c 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -141,42 +141,6 @@ static void DestroySout( input_resource_t *p_resource )
 p_resource->p_sout = NULL;
 }
 
-static sout_instance_t *RequestSout( input_resource_t *p_resource,
- sout_instance_t *p_sout, const char 
*psz_sout )
-{
-#ifdef ENABLE_SOUT
-assert( !p_sout );
-
-/* Check the validity of the sout */
-if( p_resource->p_sout &&
-strcmp( p_resource->p_sout->psz_sout, psz_sout ) )
-{
-msg_Dbg( p_resource->p_parent, "destroying unusable sout" );
-DestroySout( p_resource );
-}
-
-if( p_resource->p_sout )
-{
-/* Reuse it */
-msg_Dbg( p_resource->p_parent, "reusing sout" );
-msg_Dbg( p_resource->p_parent, "you probably want to use gather 
stream_out" );
-}
-else
-{
-/* Create a new one */
-p_resource->p_sout = sout_NewInstance( p_resource->p_parent, 
psz_sout );
-}
-
-p_sout = p_resource->p_sout;
-p_resource->p_sout = NULL;
-
-return p_sout;
-#else
-VLC_UNUSED (p_resource); VLC_UNUSED (p_sout); VLC_UNUSED (psz_sout);
-return NULL;
-#endif
-}
-
 /* */
 static void DestroyVout( input_resource_t *p_resource )
 {
@@ -609,12 +573,38 @@ void input_resource_StopFreeVout(input_resource_t 
*p_resource)
 /* */
 sout_instance_t *input_resource_RequestSout( input_resource_t *p_resource, 
const char *psz_sout )
 {
+sout_instance_t *sout;
+
 assert(psz_sout != NULL);
 vlc_mutex_lock( _resource->lock );
-sout_instance_t *p_ret = RequestSout( p_resource, NULL, psz_sout );
-vlc_mutex_unlock( _resource->lock );
+#ifdef ENABLE_SOUT
+/* Check the validity of the sout */
+if (p_resource->p_sout != NULL
+ && strcmp(p_resource->p_sout->psz_sout, psz_sout) != 0)
+{
+msg_Dbg(p_resource->p_parent, "destroying unusable sout");
+DestroySout(p_resource);
+}
 
-return p_ret;
+sout = p_resource->p_sout;
+
+if (sout != NULL)
+{
+/* Reuse it */
+msg_Dbg(p_resource->p_parent, "reusing sout");
+msg_Dbg(p_resource->p_parent, "you probably want to use gather 
stream_out");
+p_resource->p_sout = NULL;
+}
+else
+{
+/* Create a new one */
+sout = sout_NewInstance(p_resource->p_parent, psz_sout);
+}
+#else
+sout = NULL;
+#endif
+vlc_mutex_unlock( _resource->lock );
+return sout;
 }
 
 void input_resource_PutSout(input_resource_t *resource, sout_instance_t *sout)

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] resource: add an assertion

2021-01-21 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Jan 19 
20:03:13 2021 +0200| [a2c0bd0824c08f64051b236e40ad5398ac38116e] | committer: 
Rémi Denis-Courmont

resource: add an assertion

(This is trivially verified by the only call site.)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a2c0bd0824c08f64051b236e40ad5398ac38116e
---

 src/input/resource.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/input/resource.c b/src/input/resource.c
index 8c16802452..27ce970860 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -623,6 +623,7 @@ void input_resource_StopFreeVout(input_resource_t 
*p_resource)
 /* */
 sout_instance_t *input_resource_RequestSout( input_resource_t *p_resource, 
sout_instance_t *p_sout, const char *psz_sout )
 {
+assert(psz_sout != NULL);
 vlc_mutex_lock( _resource->lock );
 sout_instance_t *p_ret = RequestSout( p_resource, p_sout, psz_sout );
 vlc_mutex_unlock( _resource->lock );

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] resource: remove now dead code

2021-01-21 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Jan 19 
20:09:26 2021 +0200| [92e6839960c4707a1a653f394b39528aba03ec7f] | committer: 
Rémi Denis-Courmont

resource: remove now dead code

This is dead because psz_sout can no longer be NULL.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=92e6839960c4707a1a653f394b39528aba03ec7f
---

 src/input/resource.c | 16 +---
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/src/input/resource.c b/src/input/resource.c
index f4af95f39e..1f8a5d5e0e 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -145,13 +145,7 @@ static sout_instance_t *RequestSout( input_resource_t 
*p_resource,
  sout_instance_t *p_sout, const char 
*psz_sout )
 {
 #ifdef ENABLE_SOUT
-if( !p_sout && !psz_sout )
-{
-DestroySout( p_resource );
-return NULL;
-}
-
-assert( !p_sout || ( !p_resource->p_sout && !psz_sout ) );
+assert( !p_sout );
 
 /* Check the validity of the sout */
 if( p_resource->p_sout &&
@@ -161,8 +155,6 @@ static sout_instance_t *RequestSout( input_resource_t 
*p_resource,
 DestroySout( p_resource );
 }
 
-if( psz_sout )
-{
 if( p_resource->p_sout )
 {
 /* Reuse it */
@@ -179,12 +171,6 @@ static sout_instance_t *RequestSout( input_resource_t 
*p_resource,
 p_resource->p_sout = NULL;
 
 return p_sout;
-}
-else
-{
-p_resource->p_sout = p_sout;
-return NULL;
-}
 #else
 VLC_UNUSED (p_resource); VLC_UNUSED (p_sout); VLC_UNUSED (psz_sout);
 return NULL;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] input: call input_resource_TerminateSout()

2021-01-21 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Jan 19 
19:39:47 2021 +0200| [002ee12f61fe13030e61d857b66c0a51e981db7b] | committer: 
Rémi Denis-Courmont

input: call input_resource_TerminateSout()

(no functional changes)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=002ee12f61fe13030e61d857b66c0a51e981db7b
---

 src/input/input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/input/input.c b/src/input/input.c
index 730d99db01..08d5300d7d 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -818,7 +818,7 @@ static int InitSout( input_thread_t * p_input )
 }
 else
 {
-input_resource_RequestSout( priv->p_resource, NULL, NULL );
+input_resource_TerminateSout( priv->p_resource );
 }
 free( psz );
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] resource: remove now always NULL parameter

2021-01-21 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Jan 19 
20:03:27 2021 +0200| [1d350359032819bf193bd7d141fbae34cf5045b2] | committer: 
Rémi Denis-Courmont

resource: remove now always NULL parameter

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1d350359032819bf193bd7d141fbae34cf5045b2
---

 src/input/input.c| 2 +-
 src/input/resource.c | 4 ++--
 src/input/resource.h | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/input/input.c b/src/input/input.c
index 4ac78a14c6..0319505532 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -806,7 +806,7 @@ static int InitSout( input_thread_t * p_input )
 }
 if( psz && strncasecmp( priv->p_item->psz_uri, "vlc:", 4 ) )
 {
-priv->p_sout  = input_resource_RequestSout( priv->p_resource, NULL, 
psz );
+priv->p_sout  = input_resource_RequestSout( priv->p_resource, psz );
 if( priv->p_sout == NULL )
 {
 input_ChangeState( p_input, ERROR_S, VLC_TICK_INVALID );
diff --git a/src/input/resource.c b/src/input/resource.c
index 27ce970860..d2c1ab844f 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -621,11 +621,11 @@ void input_resource_StopFreeVout(input_resource_t 
*p_resource)
 }
 
 /* */
-sout_instance_t *input_resource_RequestSout( input_resource_t *p_resource, 
sout_instance_t *p_sout, const char *psz_sout )
+sout_instance_t *input_resource_RequestSout( input_resource_t *p_resource, 
const char *psz_sout )
 {
 assert(psz_sout != NULL);
 vlc_mutex_lock( _resource->lock );
-sout_instance_t *p_ret = RequestSout( p_resource, p_sout, psz_sout );
+sout_instance_t *p_ret = RequestSout( p_resource, NULL, psz_sout );
 vlc_mutex_unlock( _resource->lock );
 
 return p_ret;
diff --git a/src/input/resource.h b/src/input/resource.h
index 66fdf997f8..bd1023379d 100644
--- a/src/input/resource.h
+++ b/src/input/resource.h
@@ -35,7 +35,7 @@ void input_resource_SetInput( input_resource_t *, 
input_thread_t * );
 /**
  * This function handles sout request.
  */
-sout_instance_t *input_resource_RequestSout( input_resource_t *, 
sout_instance_t *, const char *psz_sout );
+sout_instance_t *input_resource_RequestSout( input_resource_t *, const char * 
);
 void input_resource_PutSout(input_resource_t *, sout_instance_t *);
 
 vout_thread_t *input_resource_RequestVout(input_resource_t *, 
vlc_video_context *,

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] resource: inline RequestSout()

2021-01-21 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Jan 19 
20:07:04 2021 +0200| [656d2a834ae7a08f97dd6e451974303c540c7506] | committer: 
Rémi Denis-Courmont

resource: inline RequestSout()

... into input_resource_PutSout() - with constant expansion.

(No functional changes, except trivially if !ENABLE_SOUT)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=656d2a834ae7a08f97dd6e451974303c540c7506
---

 src/input/resource.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/input/resource.c b/src/input/resource.c
index d2c1ab844f..f4af95f39e 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -633,8 +633,15 @@ sout_instance_t *input_resource_RequestSout( 
input_resource_t *p_resource, const
 
 void input_resource_PutSout(input_resource_t *resource, sout_instance_t *sout)
 {
+if (sout == NULL)
+{
+input_resource_TerminateSout(resource);
+return;
+}
+
 vlc_mutex_lock(>lock);
-RequestSout(resource, sout, NULL);
+assert(resource->p_sout == NULL);
+resource->p_sout = sout;
 vlc_mutex_unlock(>lock);
 }
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] resource: inline propagate RequestSout()

2021-01-21 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Jan 19 
19:42:16 2021 +0200| [0c311bfbda0f05cfea613d71ab0ce3aa0b69bff5] | committer: 
Rémi Denis-Courmont

resource: inline propagate RequestSout()

...and input_resource_RequestSout() into input_resource_TerminateSout().
No functional changes.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0c311bfbda0f05cfea613d71ab0ce3aa0b69bff5
---

 src/input/resource.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/input/resource.c b/src/input/resource.c
index ff05b5a32b..044fb8b7e5 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -629,7 +629,10 @@ sout_instance_t *input_resource_RequestSout( 
input_resource_t *p_resource, sout_
 
 return p_ret;
 }
+
 void input_resource_TerminateSout( input_resource_t *p_resource )
 {
-input_resource_RequestSout( p_resource, NULL, NULL );
+vlc_mutex_lock( _resource->lock );
+DestroySout(p_resource);
+vlc_mutex_unlock( _resource->lock );
 }

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] input: add input_resource_PutSout()

2021-01-21 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Jan 19 
19:56:51 2021 +0200| [603b9ced95eb1aa78132663a36be923064a8d3ff] | committer: 
Rémi Denis-Courmont

input: add input_resource_PutSout()

This mimicks input_resource_PutVout(), except in the case that the
second parameter is NULL:
- PutVout() asserts that that is not the case.
- PutSout() destroys the resource sout.
It is unclear if this is really intended. If not, this should be
addressed later on (this patch makes no functional changes).

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=603b9ced95eb1aa78132663a36be923064a8d3ff
---

 src/input/input.c| 12 ++--
 src/input/resource.c |  7 +++
 src/input/resource.h |  1 +
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/input/input.c b/src/input/input.c
index 08d5300d7d..4ac78a14c6 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -1356,8 +1356,8 @@ error:
 if( input_priv(p_input)->p_resource )
 {
 if( input_priv(p_input)->p_sout )
-input_resource_RequestSout( input_priv(p_input)->p_resource,
- input_priv(p_input)->p_sout, NULL );
+input_resource_PutSout( input_priv(p_input)->p_resource,
+input_priv(p_input)->p_sout );
 input_resource_SetInput( input_priv(p_input)->p_resource, NULL );
 if( input_priv(p_input)->p_resource )
 {
@@ -1424,8 +1424,8 @@ static void End( input_thread_t * p_input )
 vlc_mutex_unlock( _priv(p_input)->p_item->lock );
 
 /* */
-input_resource_RequestSout( input_priv(p_input)->p_resource,
- input_priv(p_input)->p_sout, NULL );
+input_resource_PutSout( input_priv(p_input)->p_resource,
+input_priv(p_input)->p_sout );
 input_resource_SetInput( input_priv(p_input)->p_resource, NULL );
 if( input_priv(p_input)->p_resource )
 {
@@ -1797,8 +1797,8 @@ static void ControlUpdateRenderer( input_thread_t 
*p_input, bool b_enable )
 }
 else
 {
-input_resource_RequestSout( input_priv(p_input)->p_resource,
-input_priv(p_input)->p_sout, NULL );
+input_resource_PutSout( input_priv(p_input)->p_resource,
+input_priv(p_input)->p_sout );
 input_priv(p_input)->p_sout = NULL;
 }
 }
diff --git a/src/input/resource.c b/src/input/resource.c
index 044fb8b7e5..8c16802452 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -630,6 +630,13 @@ sout_instance_t *input_resource_RequestSout( 
input_resource_t *p_resource, sout_
 return p_ret;
 }
 
+void input_resource_PutSout(input_resource_t *resource, sout_instance_t *sout)
+{
+vlc_mutex_lock(>lock);
+RequestSout(resource, sout, NULL);
+vlc_mutex_unlock(>lock);
+}
+
 void input_resource_TerminateSout( input_resource_t *p_resource )
 {
 vlc_mutex_lock( _resource->lock );
diff --git a/src/input/resource.h b/src/input/resource.h
index f6f3b4be60..66fdf997f8 100644
--- a/src/input/resource.h
+++ b/src/input/resource.h
@@ -36,6 +36,7 @@ void input_resource_SetInput( input_resource_t *, 
input_thread_t * );
  * This function handles sout request.
  */
 sout_instance_t *input_resource_RequestSout( input_resource_t *, 
sout_instance_t *, const char *psz_sout );
+void input_resource_PutSout(input_resource_t *, sout_instance_t *);
 
 vout_thread_t *input_resource_RequestVout(input_resource_t *, 
vlc_video_context *,
  const vout_configuration_t *,

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] sout: remove unused variable

2021-01-21 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Jan 19 
19:29:06 2021 +0200| [59793dcc0fd1c369a630d0aafa61d33bd9f68755] | committer: 
Rémi Denis-Courmont

sout: remove unused variable

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=59793dcc0fd1c369a630d0aafa61d33bd9f68755
---

 src/stream_output/stream_output.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/stream_output/stream_output.c 
b/src/stream_output/stream_output.c
index 7d2b633c7b..49ff5017e9 100644
--- a/src/stream_output/stream_output.c
+++ b/src/stream_output/stream_output.c
@@ -243,8 +243,6 @@ int sout_InputSendBuffer( sout_instance_t *p_sout,
   sout_packetizer_input_t *p_input,
   block_t *p_buffer )
 {
-int i_ret;
-
 if( p_input->b_flushed )
 {
 p_buffer->i_flags |= BLOCK_FLAG_DISCONTINUITY;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] resource: check if sout is NULL just once

2021-01-21 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Jan 19 
19:36:20 2021 +0200| [87c360248f0764f78093e3fbf29e408fd1eb3264] | committer: 
Rémi Denis-Courmont

resource: check if sout is NULL just once

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=87c360248f0764f78093e3fbf29e408fd1eb3264
---

 src/input/resource.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/input/resource.c b/src/input/resource.c
index 530da5d6eb..ff05b5a32b 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -133,7 +133,10 @@ static void DestroySout( input_resource_t *p_resource )
 {
 #ifdef ENABLE_SOUT
 if( p_resource->p_sout )
+{
+msg_Dbg( p_resource->p_parent, "destroying stream output" );
 sout_DeleteInstance( p_resource->p_sout );
+}
 #endif
 p_resource->p_sout = NULL;
 }
@@ -144,11 +147,7 @@ static sout_instance_t *RequestSout( input_resource_t 
*p_resource,
 #ifdef ENABLE_SOUT
 if( !p_sout && !psz_sout )
 {
-if( p_resource->p_sout )
-{
-msg_Dbg( p_resource->p_parent, "destroying useless sout" );
-DestroySout( p_resource );
-}
+DestroySout( p_resource );
 return NULL;
 }
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] sout: remove the instance lock

2021-01-19 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Oct 11 
17:24:27 2020 +0300| [555e70af56ab4c56293907a9ba252bfdc04ffb22] | committer: 
Rémi Denis-Courmont

sout: remove the instance lock

This becomes redundant with the previous change.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=555e70af56ab4c56293907a9ba252bfdc04ffb22
---

 src/stream_output/stream_output.c | 26 +++---
 src/stream_output/stream_output.h |  2 --
 2 files changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/stream_output/stream_output.c 
b/src/stream_output/stream_output.c
index b39b976c44..7d2b633c7b 100644
--- a/src/stream_output/stream_output.c
+++ b/src/stream_output/stream_output.c
@@ -110,7 +110,6 @@ sout_instance_t *sout_NewInstance( vlc_object_t *p_parent, 
const char *psz_dest
 p_sout->psz_sout= strdup( psz_dest );
 p_sout->b_wants_substreams = false;
 
-vlc_mutex_init( _sout->lock );
 p_sout->p_stream = NULL;
 
 p_sout->p_stream = sout_StreamChainNew(p_parent, psz_chain, NULL);
@@ -149,12 +148,7 @@ void sout_DeleteInstance( sout_instance_t * p_sout )
 
 bool sout_instance_ControlsPace( sout_instance_t *sout )
 {
-bool ret;
-
-vlc_mutex_lock( >lock );
-ret = !sout_StreamIsSynchronous(sout->p_stream);
-vlc_mutex_unlock( >lock );
-return ret;
+return !sout_StreamIsSynchronous(sout->p_stream);
 }
 
 /*
@@ -182,9 +176,7 @@ sout_packetizer_input_t *sout_InputNew( sout_instance_t 
*p_sout,
 (char *)_fmt->i_codec, (void *)p_input);
 
 /* *** add it to the stream chain */
-vlc_mutex_lock( _sout->lock );
 p_input->id = sout_StreamIdAdd( p_sout->p_stream, p_fmt );
-vlc_mutex_unlock( _sout->lock );
 
 if( p_input->id == NULL )
 {
@@ -206,10 +198,7 @@ int sout_InputDelete( sout_instance_t *p_sout,
 
 msg_Dbg(p_sout->p_stream, "removing an output ES (%p)", (void *)p_input);
 
-vlc_mutex_lock( _sout->lock );
 sout_StreamIdDel( p_sout->p_stream, p_input->id );
-vlc_mutex_unlock( _sout->lock );
-
 free( p_input );
 
 return( VLC_SUCCESS);
@@ -221,12 +210,9 @@ static int sout_InputControlVa( sout_instance_t *p_sout,
 {
 if( i_query == SOUT_INPUT_SET_SPU_HIGHLIGHT )
 {
-vlc_mutex_lock( _sout->lock );
-int i_ret = sout_StreamControl( p_sout->p_stream,
+return sout_StreamControl( p_sout->p_stream,
 SOUT_STREAM_ID_SPU_HIGHLIGHT,
 p_input->id, va_arg(args, void *) );
-vlc_mutex_unlock( _sout->lock );
-return i_ret;
 }
 return VLC_EGENERIC;
 }
@@ -246,9 +232,7 @@ int sout_InputControl( sout_instance_t *p_sout,
 void sout_InputFlush( sout_instance_t *p_sout,
   sout_packetizer_input_t *p_input )
 {
-vlc_mutex_lock( _sout->lock );
 sout_StreamFlush( p_sout->p_stream, p_input->id );
-vlc_mutex_unlock( _sout->lock );
 p_input->b_flushed = true;
 }
 
@@ -266,11 +250,7 @@ int sout_InputSendBuffer( sout_instance_t *p_sout,
 p_buffer->i_flags |= BLOCK_FLAG_DISCONTINUITY;
 p_input->b_flushed = false;
 }
-vlc_mutex_lock( _sout->lock );
-i_ret = sout_StreamIdSend( p_sout->p_stream, p_input->id, p_buffer );
-vlc_mutex_unlock( _sout->lock );
-
-return i_ret;
+return sout_StreamIdSend( p_sout->p_stream, p_input->id, p_buffer );
 }
 
 #undef sout_AccessOutNew
diff --git a/src/stream_output/stream_output.h 
b/src/stream_output/stream_output.h
index 98f192e807..09b6a1505e 100644
--- a/src/stream_output/stream_output.h
+++ b/src/stream_output/stream_output.h
@@ -35,8 +35,6 @@ struct sout_instance_t
 char *psz_sout;
 
 boolb_wants_substreams;
-
-vlc_mutex_t lock;
 sout_stream_t   *p_stream;
 };
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] sout: lock sout_stream_t individually

2021-01-19 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Oct 11 
17:17:29 2020 +0300| [3a6927053cc8522bff8862c92cc0267dfa0a1341] | committer: 
Rémi Denis-Courmont

sout: lock sout_stream_t individually

The stream output is called from multiple threads without
synchronisation, notably at least one thread per ES decoder. Normally,
the stream output instance (sout_instance_t) lock will serialise all
calls to the first stream output module instance (sout_stream_t) in the
stream output chain.

This is not practical if there is also concurrency within the chain.
One notable case is when the select/duplicate module is used in filter
mode and one of the select/duplicate target is threaded, e.g.:

 #duplicate{dst=transcode{...},dst=transcode{...}}:std{...}

In that example, the standard output can be called from both transcode
filters.

To solve this, add a lock for each element in the stream output chain.
Alternatively, we could drop filter mode from select/duplicate, leaving
only the (more common) output mode where duplicate is the last element
in the chain.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3a6927053cc8522bff8862c92cc0267dfa0a1341
---

 src/stream_output/stream_output.c | 44 ++-
 1 file changed, 39 insertions(+), 5 deletions(-)

diff --git a/src/stream_output/stream_output.c 
b/src/stream_output/stream_output.c
index ce46cf3ea4..b39b976c44 100644
--- a/src/stream_output/stream_output.c
+++ b/src/stream_output/stream_output.c
@@ -743,38 +743,71 @@ static void mrl_Clean( mrl_t *p_mrl )
 
 struct sout_stream_private {
 sout_stream_t stream;
+vlc_mutex_t lock;
 module_t *module;
 };
 
 #define sout_stream_priv(s) \
 container_of(s, struct sout_stream_private, stream)
 
+static void sout_StreamLock(sout_stream_t *s)
+{
+vlc_mutex_lock(_stream_priv(s)->lock);
+}
+
+static void sout_StreamUnlock(sout_stream_t *s)
+{
+vlc_mutex_unlock(_stream_priv(s)->lock);
+}
+
 void *sout_StreamIdAdd(sout_stream_t *s, const es_format_t *fmt)
 {
-return s->ops->add(s, fmt);
+void *id;
+
+sout_StreamLock(s);
+id = s->ops->add(s, fmt);
+sout_StreamUnlock(s);
+return id;
 }
 
 void sout_StreamIdDel(sout_stream_t *s, void *id)
 {
+sout_StreamLock(s);
 s->ops->del(s, id);
+sout_StreamUnlock(s);
 }
 
 int sout_StreamIdSend(sout_stream_t *s, void *id, block_t *b)
 {
-return s->ops->send(s, id, b);
+int val;
+
+sout_StreamLock(s);
+val = s->ops->send(s, id, b);
+sout_StreamUnlock(s);
+return val;
 }
 
 void sout_StreamFlush(sout_stream_t *s, void *id)
 {
 if (s->ops->flush != NULL)
+{
+sout_StreamLock(s);
 s->ops->flush(s, id);
+sout_StreamUnlock(s);
+}
 }
 
 int sout_StreamControlVa(sout_stream_t *s, int i_query, va_list args)
 {
-if (s->ops->control == NULL)
-return VLC_EGENERIC;
-return s->ops->control(s, i_query, args);
+int val = VLC_EGENERIC;
+
+if (s->ops->control != NULL)
+{
+sout_StreamLock(s);
+val = s->ops->control(s, i_query, args);
+sout_StreamUnlock(s);
+}
+return val;
 }
 
 /* Destroy a "stream_out" module */
@@ -830,6 +863,7 @@ static sout_stream_t *sout_StreamNew( vlc_object_t *parent, 
char *psz_name,
 if (unlikely(priv == NULL))
 return NULL;
 
+vlc_mutex_init(>lock);
 p_stream = >stream;
 p_stream->psz_name = psz_name;
 p_stream->p_cfg= p_cfg;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mpjpeg mux: do not use block_FifoCount()

2021-01-19 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Mon Oct 12 
21:05:24 2020 +0300| [2a6cc8a2d36af970c9b659bbbe1d7e44dcca08f6] | committer: 
Rémi Denis-Courmont

mpjpeg mux: do not use block_FifoCount()

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2a6cc8a2d36af970c9b659bbbe1d7e44dcca08f6
---

 modules/mux/mpjpeg.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/modules/mux/mpjpeg.c b/modules/mux/mpjpeg.c
index 5850d8a237..70ea28a35b 100644
--- a/modules/mux/mpjpeg.c
+++ b/modules/mux/mpjpeg.c
@@ -136,22 +136,32 @@ static void DelStream( sout_mux_t *p_mux, sout_input_t 
*p_input )
 msg_Dbg( p_mux, "removing input" );
 }
 
+static block_t *block_FifoTryGet(block_fifo_t *fifo)
+{
+block_t *block;
+
+vlc_fifo_Lock(fifo);
+block = vlc_fifo_DequeueUnlocked(fifo);
+vlc_fifo_Unlock(fifo);
+return block;
+}
+
 static int Mux( sout_mux_t *p_mux )
 {
 block_fifo_t *p_fifo;
+block_t *p_data;
 
 if( !p_mux->i_nb_inputs ) return VLC_SUCCESS;
 
 p_fifo = p_mux->pp_inputs[0]->p_fifo;
 
-while( block_FifoCount( p_fifo ) > 0 )
+while ((p_data = block_FifoTryGet(p_fifo)) != NULL)
 {
 static const char psz_hfmt[] = "\r\n"
 "--"BOUNDARY"\r\n"
 "Content-Type: image/jpeg\r\n"
 "Content-Length: %zu\r\n"
 "\r\n";
-block_t *p_data = block_FifoGet( p_fifo );
 block_t *p_header = block_Alloc( sizeof( psz_hfmt ) + 20 );
 
 if( p_header == NULL ) /* uho! */

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mutex: remove write-only variable

2021-01-13 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Jan 12 
18:52:57 2021 +0200| [222367a03fd40043aa767fa8e55b8dbc1cec12ee] | committer: 
Rémi Denis-Courmont

mutex: remove write-only variable

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=222367a03fd40043aa767fa8e55b8dbc1cec12ee
---

 src/misc/threads.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/misc/threads.c b/src/misc/threads.c
index 196e0dc1d0..15311b5214 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -157,10 +157,8 @@ bool vlc_mutex_held(const vlc_mutex_t *mtx)
 
 void vlc_mutex_lock(vlc_mutex_t *mtx)
 {
-unsigned value;
-
 /* This is the Drepper (non-recursive) mutex algorithm
- * from his "Futexes are tricky" paper. The mutex can value be:
+ * from his "Futexes are tricky" paper. The mutex value can be:
  * - 0: the mutex is free
  * - 1: the mutex is locked and uncontended
  * - 2: the mutex is contended (i.e., unlock needs to wake up a waiter)
@@ -170,8 +168,7 @@ void vlc_mutex_lock(vlc_mutex_t *mtx)
 
 int canc = vlc_savecancel(); /* locking is never a cancellation point */
 
-while ((value = atomic_exchange_explicit(>value, 2,
- memory_order_acquire)) != 0)
+while (atomic_exchange_explicit(>value, 2, memory_order_acquire))
 vlc_atomic_wait(>value, 2);
 
 vlc_restorecancel(canc);

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] threads: remove vlc_rwlock_destroy()

2021-01-13 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Jan 10 
14:03:00 2021 +0200| [6e6c2850a17867e3bf12a2fff8dfe3281335797a] | committer: 
Rémi Denis-Courmont

threads: remove vlc_rwlock_destroy()

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6e6c2850a17867e3bf12a2fff8dfe3281335797a
---

 include/vlc_threads.h | 8 
 src/libvlccore.sym| 1 -
 src/misc/messages.c   | 1 -
 src/misc/threads.c| 5 -
 4 files changed, 15 deletions(-)

diff --git a/include/vlc_threads.h b/include/vlc_threads.h
index 2054e632f0..0aac31afbf 100644
--- a/include/vlc_threads.h
+++ b/include/vlc_threads.h
@@ -544,17 +544,9 @@ typedef struct vlc_rwlock
 
 /**
  * Initializes a read/write lock.
- *
- * After use, a read/write lock must be deinitialized with
- * vlc_rwlock_destroy().
  */
 VLC_API void vlc_rwlock_init(vlc_rwlock_t *);
 
-/**
- * Destroys an initialized unused read/write lock.
- */
-VLC_API void vlc_rwlock_destroy(vlc_rwlock_t *);
-
 /**
  * Acquires a read/write lock for reading.
  *
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 2cfe0d376c..71267d5dfc 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -651,7 +651,6 @@ vlc_lrand48
 vlc_mrand48
 vlc_qsort
 vlc_restorecancel
-vlc_rwlock_destroy
 vlc_rwlock_init
 vlc_rwlock_rdlock
 vlc_rwlock_unlock
diff --git a/src/misc/messages.c b/src/misc/messages.c
index 898e4be56f..7fe374947b 100644
--- a/src/misc/messages.c
+++ b/src/misc/messages.c
@@ -332,7 +332,6 @@ static void vlc_LogSwitchClose(void *d)
 logswitch->backend = _log;
 backend->ops->destroy(backend);
 
-vlc_rwlock_destroy(>lock);
 free(logswitch);
 }
 
diff --git a/src/misc/threads.c b/src/misc/threads.c
index 460fabc3c8..dcb604c0aa 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -391,11 +391,6 @@ void vlc_rwlock_init (vlc_rwlock_t *lock)
 lock->state = 0;
 }
 
-void vlc_rwlock_destroy (vlc_rwlock_t *lock)
-{
-(void) lock;
-}
-
 void vlc_rwlock_rdlock (vlc_rwlock_t *lock)
 {
 vlc_mutex_lock (>mutex);

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] threads: use common vlc_rwlock_t on all platforms

2021-01-13 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Dec 22 
22:37:31 2020 +0200| [4bf5c6f766fe0750102aa28cba1e62237ef4bc1c] | committer: 
Rémi Denis-Courmont

threads: use common vlc_rwlock_t on all platforms

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4bf5c6f766fe0750102aa28cba1e62237ef4bc1c
---

 include/vlc_threads.h | 32 ++--
 src/misc/threads.c|  4 
 src/posix/thread.c| 30 --
 3 files changed, 10 insertions(+), 56 deletions(-)

diff --git a/include/vlc_threads.h b/include/vlc_threads.h
index 21f4e46c27..2054e632f0 100644
--- a/include/vlc_threads.h
+++ b/include/vlc_threads.h
@@ -60,7 +60,6 @@ typedef struct vlc_thread *vlc_thread_t;
 # define VLC_THREAD_CANCELED NULL
 
 # define LIBVLC_NEED_SLEEP
-#define LIBVLC_NEED_RWLOCK
 typedef struct vlc_threadvar *vlc_threadvar_t;
 typedef struct vlc_timer *vlc_timer_t;
 
@@ -89,7 +88,6 @@ static inline int vlc_poll(struct pollfd *fds, unsigned nfds, 
int timeout)
 typedef struct vlc_thread *vlc_thread_t;
 #define VLC_THREAD_CANCELED NULL
 
-#define LIBVLC_NEED_RWLOCK
 typedef struct vlc_threadvar *vlc_threadvar_t;
 typedef struct vlc_timer *vlc_timer_t;
 
@@ -130,7 +128,6 @@ static inline int vlc_poll (struct pollfd *fds, unsigned 
nfds, int timeout)
 # include 
 # define LIBVLC_USE_PTHREAD_CLEANUP   1
 # define LIBVLC_NEED_SLEEP
-# define LIBVLC_NEED_RWLOCK
 
 typedef struct vlc_thread *vlc_thread_t;
 #define VLC_THREAD_CANCELED NULL
@@ -191,22 +188,6 @@ typedef struct
  */
 #define VLC_THREAD_CANCELED PTHREAD_CANCELED
 
-/**
- * Read/write lock.
- *
- * Storage space for a slim reader/writer lock.
- *
- * \ingroup rwlock
- */
-typedef pthread_rwlock_t vlc_rwlock_t;
-
-/**
- * Static initializer for (static) read/write lock.
- *
- * \ingroup rwlock
- */
-#define VLC_STATIC_RWLOCK PTHREAD_RWLOCK_INITIALIZER
-
 /**
  * Thread-local key handle.
  *
@@ -544,15 +525,22 @@ VLC_API int vlc_sem_timedwait(vlc_sem_t *sem, vlc_tick_t 
deadline) VLC_USED;
  * @{
  */
 
-#ifdef LIBVLC_NEED_RWLOCK
+/**
+ * Read/write lock.
+ *
+ * Storage space for a slim reader/writer lock.
+ */
 typedef struct vlc_rwlock
 {
 vlc_mutex_t   mutex;
 vlc_cond_twait;
 long  state;
 } vlc_rwlock_t;
-# define VLC_STATIC_RWLOCK { VLC_STATIC_MUTEX, VLC_STATIC_COND, 0 }
-#endif
+
+/**
+ * Static initializer for (static) read/write lock.
+ */
+#define VLC_STATIC_RWLOCK { VLC_STATIC_MUTEX, VLC_STATIC_COND, 0 }
 
 /**
  * Initializes a read/write lock.
diff --git a/src/misc/threads.c b/src/misc/threads.c
index 15311b5214..460fabc3c8 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -372,10 +372,7 @@ int vlc_cond_timedwait_daytime(vlc_cond_t *cond, 
vlc_mutex_t *mutex,
 return ret;
 }
 
-#ifdef LIBVLC_NEED_RWLOCK
 /*** Generic read/write locks ***/
-#include 
-#include 
 /* NOTE:
  * lock->state is a signed long integer:
  *  - The sign bit is set when the lock is held for writing.
@@ -444,7 +441,6 @@ void vlc_rwlock_unlock (vlc_rwlock_t *lock)
 }
 vlc_mutex_unlock (>mutex);
 }
-#endif /* LIBVLC_NEED_RWLOCK */
 
 /*** Generic semaphores ***/
 
diff --git a/src/posix/thread.c b/src/posix/thread.c
index 91eab74716..d617bd7292 100644
--- a/src/posix/thread.c
+++ b/src/posix/thread.c
@@ -103,36 +103,6 @@ vlc_thread_fatal (const char *action, int error,
 # define VLC_THREAD_ASSERT( action ) ((void)val)
 #endif
 
-void vlc_rwlock_init (vlc_rwlock_t *lock)
-{
-if (unlikely(pthread_rwlock_init (lock, NULL)))
-abort ();
-}
-
-void vlc_rwlock_destroy (vlc_rwlock_t *lock)
-{
-int val = pthread_rwlock_destroy (lock);
-VLC_THREAD_ASSERT ("destroying R/W lock");
-}
-
-void vlc_rwlock_rdlock (vlc_rwlock_t *lock)
-{
-int val = pthread_rwlock_rdlock (lock);
-VLC_THREAD_ASSERT ("acquiring R/W lock for reading");
-}
-
-void vlc_rwlock_wrlock (vlc_rwlock_t *lock)
-{
-int val = pthread_rwlock_wrlock (lock);
-VLC_THREAD_ASSERT ("acquiring R/W lock for writing");
-}
-
-void vlc_rwlock_unlock (vlc_rwlock_t *lock)
-{
-int val = pthread_rwlock_unlock (lock);
-VLC_THREAD_ASSERT ("releasing R/W lock");
-}
-
 int vlc_threadvar_create (vlc_threadvar_t *key, void (*destr) (void *))
 {
 return pthread_key_create (key, destr);

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] httpd: do not disable timeout for RTSP

2021-01-12 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 22 
18:53:28 2020 +0200| [38d214bc4f2ef68dfe6859383e12a20ae91e62de] | committer: 
Thomas Guillem

httpd: do not disable timeout for RTSP

Use the same timeout for the RTSP connection as for the RTSP session.
A shorter timeout is inefficient, as it requires clients to reconnect
to refresh the session anyway. A longer timeout is pointless as the
session would timeout and the RTP streams would stop regardless of the
connection staying alive.

Signed-off-by: Thomas Guillem 

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=38d214bc4f2ef68dfe6859383e12a20ae91e62de
---

 src/network/httpd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/network/httpd.c b/src/network/httpd.c
index 9a0a352566..2f7f20c362 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -917,8 +917,8 @@ httpd_host_t *vlc_https_HostNew(vlc_object_t *obj)
 
 httpd_host_t *vlc_rtsp_HostNew(vlc_object_t *p_this)
 {
-/* XXX: for QT I have to disable timeout. Try to find why */
-return httpd_HostCreate(p_this, "rtsp-host", "rtsp-port", NULL, 0);
+unsigned timeout = var_InheritInteger(p_this, "rtsp-timeout");
+return httpd_HostCreate(p_this, "rtsp-host", "rtsp-port", NULL, timeout);
 }
 
 static struct httpd

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] httpd: store timeout date rather than activity date

2021-01-12 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 22 
18:53:24 2020 +0200| [2fd2b843c4af0e42c6848bc88ab03173500cc52c] | committer: 
Thomas Guillem

httpd: store timeout date rather than activity date

This should not make any functional differences.

Signed-off-by: Thomas Guillem 

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2fd2b843c4af0e42c6848bc88ab03173500cc52c
---

 src/network/httpd.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/network/httpd.c b/src/network/httpd.c
index 52c8e5bdf3..24f7912e27 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -146,7 +146,7 @@ struct httpd_client_t
 boolb_stream_mode;
 uint8_t i_state;
 
-vlc_tick_t i_activity_date;
+vlc_tick_t i_timeout_date;
 vlc_tick_t i_activity_timeout;
 
 /* buffer for reading header */
@@ -1204,8 +1204,8 @@ void httpd_MsgAdd(httpd_message_t *msg, const char *name, 
const char *psz_value,
 static void httpd_ClientInit(httpd_client_t *cl, vlc_tick_t now)
 {
 cl->i_state = HTTPD_CLIENT_RECEIVING;
-cl->i_activity_date = now;
 cl->i_activity_timeout = VLC_TICK_FROM_SEC(10);
+cl->i_timeout_date = now + cl->i_activity_timeout;
 cl->i_buffer_size = HTTPD_CL_BUFSIZE;
 cl->i_buffer = 0;
 cl->p_buffer = xmalloc(cl->i_buffer_size);
@@ -1744,15 +1744,14 @@ static void httpdLoop(httpd_host_t *host)
 }
 
 if (cl->i_state == HTTPD_CLIENT_DEAD
- || (cl->i_activity_timeout > 0
-  && cl->i_activity_date + cl->i_activity_timeout < now)) {
+ || (cl->i_activity_timeout > 0 && cl->i_timeout_date < now)) {
 host->client_count--;
 httpd_ClientDestroy(cl);
 continue;
 }
 
 if (val == 0) {
-cl->i_activity_date = now;
+cl->i_timeout_date = now + cl->i_activity_timeout;
 delay = 0;
 }
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] httpd: fix crash on allocation failure

2021-01-12 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 22 
18:53:26 2020 +0200| [6151df07a69fb18dc93fea4527d959c0ba7b5380] | committer: 
Thomas Guillem

httpd: fix crash on allocation failure

Signed-off-by: Thomas Guillem 

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6151df07a69fb18dc93fea4527d959c0ba7b5380
---

 src/network/httpd.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/network/httpd.c b/src/network/httpd.c
index 2a893ba4ad..5a8aea918d 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -2037,6 +2037,12 @@ static void httpdLoop(httpd_host_t *host)
 
 cl = httpd_ClientNew(sk, now);
 
+if (unlikely(cl == NULL))
+{
+vlc_tls_Close(sk);
+continue;
+}
+
 if (host->p_tls != NULL)
 cl->i_state = HTTPD_CLIENT_TLS_HS_OUT;
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] httpd: inline httpd_ClientInit()

2021-01-12 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 22 
18:53:25 2020 +0200| [c717de53ab803a9e41e36f1a8494be09a393cf3c] | committer: 
Thomas Guillem

httpd: inline httpd_ClientInit()

No functional changes.

Signed-off-by: Thomas Guillem 

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c717de53ab803a9e41e36f1a8494be09a393cf3c
---

 src/network/httpd.c | 26 ++
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/src/network/httpd.c b/src/network/httpd.c
index 24f7912e27..2a893ba4ad 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -1201,21 +1201,6 @@ void httpd_MsgAdd(httpd_message_t *msg, const char 
*name, const char *psz_value,
 msg->i_headers++;
 }
 
-static void httpd_ClientInit(httpd_client_t *cl, vlc_tick_t now)
-{
-cl->i_state = HTTPD_CLIENT_RECEIVING;
-cl->i_activity_timeout = VLC_TICK_FROM_SEC(10);
-cl->i_timeout_date = now + cl->i_activity_timeout;
-cl->i_buffer_size = HTTPD_CL_BUFSIZE;
-cl->i_buffer = 0;
-cl->p_buffer = xmalloc(cl->i_buffer_size);
-cl->i_keyframe_wait_to_pass = -1;
-cl->b_stream_mode = false;
-
-httpd_MsgInit(>query);
-httpd_MsgInit(>answer);
-}
-
 char* httpd_ClientIP(const httpd_client_t *cl, char *ip, int *port)
 {
 return net_GetPeerAddress(vlc_tls_GetFD(cl->sock), ip, port) ? NULL : ip;
@@ -1245,8 +1230,17 @@ static httpd_client_t *httpd_ClientNew(vlc_tls_t *sock, 
vlc_tick_t now)
 
 cl->sock= sock;
 cl->url = NULL;
+cl->i_state = HTTPD_CLIENT_RECEIVING;
+cl->i_activity_timeout = VLC_TICK_FROM_SEC(10);
+cl->i_timeout_date = now + cl->i_activity_timeout;
+cl->i_buffer_size = HTTPD_CL_BUFSIZE;
+cl->i_buffer = 0;
+cl->p_buffer = xmalloc(cl->i_buffer_size);
+cl->i_keyframe_wait_to_pass = -1;
+cl->b_stream_mode = false;
 
-httpd_ClientInit(cl, now);
+httpd_MsgInit(>query);
+httpd_MsgInit(>answer);
 return cl;
 }
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] httpd: set timeout duration per host rather than client

2021-01-12 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 22 
18:53:27 2020 +0200| [ce3269d4a20aba2f87fc3e512131cb31b9561b3e] | committer: 
Thomas Guillem

httpd: set timeout duration per host rather than client

Signed-off-by: Thomas Guillem 

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ce3269d4a20aba2f87fc3e512131cb31b9561b3e
---

 src/network/httpd.c | 31 +++
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/src/network/httpd.c b/src/network/httpd.c
index 5a8aea918d..9a0a352566 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -96,6 +96,7 @@ struct httpd_host_t
 
 size_t client_count;
 struct vlc_list clients;
+unsigned timeout_sec;
 
 /* TLS data */
 vlc_tls_server_t *p_tls;
@@ -147,7 +148,6 @@ struct httpd_client_t
 uint8_t i_state;
 
 vlc_tick_t i_timeout_date;
-vlc_tick_t i_activity_timeout;
 
 /* buffer for reading header */
 int i_buffer_size;
@@ -882,12 +882,13 @@ void httpd_StreamDelete(httpd_stream_t *stream)
  */
 static void* httpd_HostThread(void *);
 static httpd_host_t *httpd_HostCreate(vlc_object_t *, const char *,
-   const char *, vlc_tls_server_t *);
+  const char *, vlc_tls_server_t *,
+  unsigned);
 
 /* create a new host */
 httpd_host_t *vlc_http_HostNew(vlc_object_t *p_this)
 {
-return httpd_HostCreate(p_this, "http-host", "http-port", NULL);
+return httpd_HostCreate(p_this, "http-host", "http-port", NULL, 10);
 }
 
 httpd_host_t *vlc_https_HostNew(vlc_object_t *obj)
@@ -911,12 +912,13 @@ httpd_host_t *vlc_https_HostNew(vlc_object_t *obj)
 free(key);
 free(cert);
 
-return httpd_HostCreate(obj, "http-host", "https-port", tls);
+return httpd_HostCreate(obj, "http-host", "https-port", tls, 10);
 }
 
 httpd_host_t *vlc_rtsp_HostNew(vlc_object_t *p_this)
 {
-return httpd_HostCreate(p_this, "rtsp-host", "rtsp-port", NULL);
+/* XXX: for QT I have to disable timeout. Try to find why */
+return httpd_HostCreate(p_this, "rtsp-host", "rtsp-port", NULL, 0);
 }
 
 static struct httpd
@@ -928,7 +930,8 @@ static struct httpd
 static httpd_host_t *httpd_HostCreate(vlc_object_t *p_this,
const char *hostvar,
const char *portvar,
-   vlc_tls_server_t *p_tls)
+   vlc_tls_server_t *p_tls,
+   unsigned timeout_sec)
 {
 httpd_host_t *host;
 unsigned port = var_InheritInteger(p_this, portvar);
@@ -975,6 +978,7 @@ static httpd_host_t *httpd_HostCreate(vlc_object_t *p_this,
 vlc_list_init(>urls);
 host->client_count = 0;
 vlc_list_init(>clients);
+host->timeout_sec = timeout_sec;
 host->p_tls= p_tls;
 
 /* create the thread */
@@ -1222,7 +1226,7 @@ static void httpd_ClientDestroy(httpd_client_t *cl)
 free(cl);
 }
 
-static httpd_client_t *httpd_ClientNew(vlc_tls_t *sock, vlc_tick_t now)
+static httpd_client_t *httpd_ClientNew(vlc_tls_t *sock)
 {
 httpd_client_t *cl = malloc(sizeof(httpd_client_t));
 
@@ -1231,8 +1235,6 @@ static httpd_client_t *httpd_ClientNew(vlc_tls_t *sock, 
vlc_tick_t now)
 cl->sock= sock;
 cl->url = NULL;
 cl->i_state = HTTPD_CLIENT_RECEIVING;
-cl->i_activity_timeout = VLC_TICK_FROM_SEC(10);
-cl->i_timeout_date = now + cl->i_activity_timeout;
 cl->i_buffer_size = HTTPD_CL_BUFSIZE;
 cl->i_buffer = 0;
 cl->p_buffer = xmalloc(cl->i_buffer_size);
@@ -1565,10 +1567,6 @@ static int httpd_ClientRecv(httpd_client_t *cl)
 return 0;
 }
 
-/* XXX: for QT I have to disable timeout. Try to find why */
-if (cl->query.i_proto == HTTPD_PROTO_RTSP)
-cl->i_activity_timeout = 0;
-
 return 0;
 }
 
@@ -1738,14 +1736,14 @@ static void httpdLoop(httpd_host_t *host)
 }
 
 if (cl->i_state == HTTPD_CLIENT_DEAD
- || (cl->i_activity_timeout > 0 && cl->i_timeout_date < now)) {
+ || (host->timeout_sec > 0 && cl->i_timeout_date < now)) {
 host->client_count--;
 httpd_ClientDestroy(cl);
 continue;
 }
 
 if (val == 0) {
-cl->i_timeout_date = now + cl->i_activity_timeout;
+cl->i_timeout_date = now + VLC_TICK_FROM_SEC(host->timeout_sec);
 delay = 0;
 }
 
@@ -2035,7 +2033,7 @@ static void httpdLoop(httpd_host_t *host)
 sk = tls;
 }
 
-cl = httpd_ClientNew(sk, now);
+cl = httpd_ClientNew(sk);
 

[vlc-commits] ftp: do not include . and .. in directory listing

2021-01-10 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Jan 10 
14:04:14 2021 +0200| [6c1b2cfffd4eabad741fd8400e671ea1421aaf90] | committer: 
Rémi Denis-Courmont

ftp: do not include . and .. in directory listing

This causes obvious serious problems with recursion.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6c1b2cfffd4eabad741fd8400e671ea1421aaf90
---

 modules/access/ftp.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/modules/access/ftp.c b/modules/access/ftp.c
index 9c79084e62..d38815f782 100644
--- a/modules/access/ftp.c
+++ b/modules/access/ftp.c
@@ -956,6 +956,13 @@ static int DirRead (stream_t *p_access, input_item_node_t 
*p_current_node)
 else
 psz_file = psz_line;
 
+/* Exclude this and parent directory */
+if (strcmp(psz_file, ".") == 0 || strcmp(psz_file, "..") == 0)
+{
+free(psz_line);
+continue;
+}
+
 char *psz_filename = vlc_uri_encode( psz_file );
 
 if (unlikely(psz_filename == NULL))

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] ftp: use memstream to format URLs

2021-01-10 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Jan 10 
14:03:23 2021 +0200| [4c1ba46ce9ffd78f54b5f38684e09d47f9e0dbcb] | committer: 
Rémi Denis-Courmont

ftp: use memstream to format URLs

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4c1ba46ce9ffd78f54b5f38684e09d47f9e0dbcb
---

 modules/access/ftp.c | 40 
 1 file changed, 28 insertions(+), 12 deletions(-)

diff --git a/modules/access/ftp.c b/modules/access/ftp.c
index d1de89ac13..9c79084e62 100644
--- a/modules/access/ftp.c
+++ b/modules/access/ftp.c
@@ -38,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -955,22 +956,37 @@ static int DirRead (stream_t *p_access, input_item_node_t 
*p_current_node)
 else
 psz_file = psz_line;
 
-char *psz_uri;
 char *psz_filename = vlc_uri_encode( psz_file );
-if( psz_filename != NULL &&
-asprintf( _uri, "%s://%s:%d%s%s/%s",
-  ( p_sys->tlsmode == NONE ) ? "ftp" :
-  ( ( p_sys->tlsmode == IMPLICIT ) ? "ftps" : "ftpes" ),
-  p_sys->url.psz_host, p_sys->url.i_port,
-  p_sys->url.psz_path ? "/" : "",
-  p_sys->url.psz_path ? p_sys->url.psz_path : "",
-  psz_filename ) != -1 )
+
+if (unlikely(psz_filename == NULL))
+continue;
+
+struct vlc_memstream ms;
+
+vlc_memstream_open();
+vlc_memstream_puts(, "ftp");
+if (p_sys->tlsmode != NONE)
 {
-i_ret = vlc_readdir_helper_additem( , psz_uri, NULL, psz_file,
+if (p_sys->tlsmode != IMPLICIT)
+vlc_memstream_putc(, 'e');
+vlc_memstream_putc(, 's');
+}
+vlc_memstream_puts(, "://");
+vlc_memstream_puts(, p_sys->url.psz_host);
+vlc_memstream_printf(, ":%d", p_sys->url.i_port);
+if (p_sys->url.psz_path != NULL)
+vlc_memstream_printf(, "/%s", p_sys->url.psz_path);
+vlc_memstream_puts(, psz_filename);
+free(psz_filename);
+
+if (likely(vlc_memstream_close() == 0))
+{
+msg_Err(p_access, "%s -> %s", p_sys->url.psz_path, ms.ptr);
+
+i_ret = vlc_readdir_helper_additem( , ms.ptr, NULL, psz_file,
 type, ITEM_NET );
-free( psz_uri );
+free(ms.ptr);
 }
-free( psz_filename );
 free( psz_line );
 }
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] ftp: add missing brackets for IPv6 literals

2021-01-10 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Jan 10 
14:08:42 2021 +0200| [7c10ffdd52ac543ff0d7d3df84c5ef652170f321] | committer: 
Rémi Denis-Courmont

ftp: add missing brackets for IPv6 literals

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7c10ffdd52ac543ff0d7d3df84c5ef652170f321
---

 modules/access/ftp.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/modules/access/ftp.c b/modules/access/ftp.c
index f0157c66d5..593cf942df 100644
--- a/modules/access/ftp.c
+++ b/modules/access/ftp.c
@@ -979,7 +979,11 @@ static int DirRead (stream_t *p_access, input_item_node_t 
*p_current_node)
 vlc_memstream_putc(, 's');
 }
 vlc_memstream_puts(, "://");
-vlc_memstream_puts(, p_sys->url.psz_host);
+
+if (strchr(p_sys->url.psz_host, ':') != NULL)
+vlc_memstream_printf(, "[%s]", p_sys->url.psz_host);
+else
+vlc_memstream_puts(, p_sys->url.psz_host);
 
 if (p_sys->url.i_port != ((p_sys->tlsmode != IMPLICIT) ? IPPORT_FTP
: IPPORT_FTPS))

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] ftp: skip port number if it's the default

2021-01-10 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Jan 10 
14:07:09 2021 +0200| [48ad967a79879bf7385edea92d1cc46d7251] | committer: 
Rémi Denis-Courmont

ftp: skip port number if it's the default

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=48ad967a79879bf7385edea92d1cc46d7251
---

 modules/access/ftp.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/modules/access/ftp.c b/modules/access/ftp.c
index d38815f782..f0157c66d5 100644
--- a/modules/access/ftp.c
+++ b/modules/access/ftp.c
@@ -980,7 +980,11 @@ static int DirRead (stream_t *p_access, input_item_node_t 
*p_current_node)
 }
 vlc_memstream_puts(, "://");
 vlc_memstream_puts(, p_sys->url.psz_host);
-vlc_memstream_printf(, ":%d", p_sys->url.i_port);
+
+if (p_sys->url.i_port != ((p_sys->tlsmode != IMPLICIT) ? IPPORT_FTP
+   : IPPORT_FTPS))
+vlc_memstream_printf(, ":%d", p_sys->url.i_port);
+
 if (p_sys->url.psz_path != NULL)
 vlc_memstream_printf(, "/%s", p_sys->url.psz_path);
 vlc_memstream_puts(, psz_filename);

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] win32: do not (re)initialise config lock

2021-01-10 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Dec 22 
22:17:12 2020 +0200| [faa7b584fc17cc4ef00405c7139348964ca2224a] | committer: 
Rémi Denis-Courmont

win32: do not (re)initialise config lock

This is a static lock. As of 4.0.0-dev-11158-ga18c4d6570, there are no
needs to initialise static locks on Windows.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=faa7b584fc17cc4ef00405c7139348964ca2224a
---

 src/win32/thread.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/src/win32/thread.c b/src/win32/thread.c
index 60b4232e04..91f3c40eaa 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -785,8 +785,6 @@ void vlc_threads_setup(libvlc_int_t *vlc)
 
 #define LOOKUP(s) (((s##_) = (void *)GetProcAddress(h, #s)) != NULL)
 
-extern vlc_rwlock_t config_lock;
-
 BOOL WINAPI DllMain (HANDLE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
 {
 (void) hinstDll;
@@ -816,12 +814,10 @@ BOOL WINAPI DllMain (HANDLE hinstDll, DWORD fdwReason, 
LPVOID lpvReserved)
 InitializeCriticalSection(_lock);
 InitializeCriticalSection(_mutex);
 InitializeConditionVariable(_variable);
-vlc_rwlock_init (_lock);
 break;
 }
 
 case DLL_PROCESS_DETACH:
-vlc_rwlock_destroy (_lock);
 DeleteCriticalSection(_mutex);
 DeleteCriticalSection(_lock);
 TlsFree(thread_key);

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] skins: fix signed overflow in bitmap allocation

2021-01-10 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Dec 22 
19:06:02 2020 +0200| [12ebbfb1ccd1f9acfb26d818f3f5dbd7723af0a8] | committer: 
Rémi Denis-Courmont

skins: fix signed overflow in bitmap allocation

Reported-by GitHub team members: @erik-krogh, @geoffw0, @MathiasVP, @owen-mc

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=12ebbfb1ccd1f9acfb26d818f3f5dbd7723af0a8
---

 modules/gui/skins2/src/file_bitmap.cpp|  7 ++-
 modules/gui/skins2/src/ft2_bitmap.cpp | 10 --
 modules/gui/skins2/src/generic_bitmap.cpp | 10 --
 modules/gui/skins2/src/scaled_bitmap.cpp  |  8 ++--
 4 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/modules/gui/skins2/src/file_bitmap.cpp 
b/modules/gui/skins2/src/file_bitmap.cpp
index 658bdc122f..c9505be370 100644
--- a/modules/gui/skins2/src/file_bitmap.cpp
+++ b/modules/gui/skins2/src/file_bitmap.cpp
@@ -38,6 +38,7 @@ FileBitmap::FileBitmap( intf_thread_t *pIntf, image_handler_t 
*pImageHandler,
 {
 video_format_t fmt_out;
 picture_t *pPic;
+unsigned size;
 
 video_format_Init( _out, VLC_CODEC_RGBA );
 
@@ -61,7 +62,11 @@ FileBitmap::FileBitmap( intf_thread_t *pIntf, 
image_handler_t *pImageHandler,
 m_height = fmt_out.i_height;
 video_format_Clean( _out );
 
-m_pData = new uint8_t[m_height * m_width * 4];
+if (mul_overflow((unsigned)m_width, (unsigned)m_height, )
+ || mul_overflow(size, 4, ))
+throw std::bad_alloc();
+
+m_pData = new uint8_t[size];
 
 // Compute the alpha layer
 uint8_t *pData = m_pData, *pSrc = pPic->p->p_pixels;
diff --git a/modules/gui/skins2/src/ft2_bitmap.cpp 
b/modules/gui/skins2/src/ft2_bitmap.cpp
index 08ce4a3421..7b1c468705 100644
--- a/modules/gui/skins2/src/ft2_bitmap.cpp
+++ b/modules/gui/skins2/src/ft2_bitmap.cpp
@@ -27,9 +27,15 @@
 FT2Bitmap::FT2Bitmap( intf_thread_t *pIntf, int width, int height ):
 GenericBitmap( pIntf ), m_width( width ), m_height( height )
 {
+unsigned size;
+
+if (mul_overflow((unsigned)width, (unsigned)height, )
+ || mul_overflow(size, 4, ))
+throw std::bad_alloc();
+
 // Allocate memory for the buffer
-m_pData = new uint8_t[m_height * m_width * 4];
-memset( m_pData, 0, m_height * m_width * 4 );
+m_pData = new uint8_t[size];
+memset(m_pData, 0, size);
 }
 
 
diff --git a/modules/gui/skins2/src/generic_bitmap.cpp 
b/modules/gui/skins2/src/generic_bitmap.cpp
index 60edecca40..a0c40f404a 100644
--- a/modules/gui/skins2/src/generic_bitmap.cpp
+++ b/modules/gui/skins2/src/generic_bitmap.cpp
@@ -57,8 +57,14 @@ BitmapImpl::BitmapImpl( intf_thread_t *pIntf, int width, int 
height,
 GenericBitmap( pIntf, nbFrames, fps, nbLoops ), m_width( width ),
 m_height( height ), m_pData( NULL )
 {
-m_pData = new uint8_t[width * height * 4];
-memset( m_pData, 0, width * height * 4 );
+unsigned size;
+
+if (mul_overflow((unsigned)width, (unsigned)height, )
+ || mul_overflow(size, 4, ))
+throw std::bad_alloc();
+
+m_pData = new uint8_t[size];
+memset(m_pData, 0, size);
 }
 
 
diff --git a/modules/gui/skins2/src/scaled_bitmap.cpp 
b/modules/gui/skins2/src/scaled_bitmap.cpp
index a85877b381..0bcbd02c4c 100644
--- a/modules/gui/skins2/src/scaled_bitmap.cpp
+++ b/modules/gui/skins2/src/scaled_bitmap.cpp
@@ -28,10 +28,14 @@ ScaledBitmap::ScaledBitmap( intf_thread_t *pIntf, const 
GenericBitmap ,
 int width, int height ):
 GenericBitmap( pIntf ), m_width( width ), m_height( height )
 {
-// XXX We should check that width and height are positive...
+unsigned size;
+
+if (mul_overflow((unsigned)width, (unsigned)height, )
+ || mul_overflow(size, 4, ))
+throw std::bad_alloc();
 
 // Allocate memory for the buffer
-m_pData = new uint8_t[m_height * m_width * 4];
+m_pData = new uint8_t[size];
 
 int srcWidth = rBitmap.getWidth();
 int srcHeight = rBitmap.getHeight();

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] os2: do not (re)initialise config lock

2021-01-10 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Dec 22 
22:17:12 2020 +0200| [03a38d1c267a25b4b1ddf89af55f67f29fa158d0] | committer: 
Rémi Denis-Courmont

os2: do not (re)initialise config lock

This is a static lock. As of 4.0.0-dev-11158-ga18c4d6570, there are no
needs to initialise static locks on OS/2.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=03a38d1c267a25b4b1ddf89af55f67f29fa158d0
---

 src/os2/thread.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/os2/thread.c b/src/os2/thread.c
index 822b3f3b26..0d7bc9e79f 100644
--- a/src/os2/thread.c
+++ b/src/os2/thread.c
@@ -131,7 +131,6 @@ static ULONG vlc_Sleep (ULONG ulTimeout)
 
 static vlc_mutex_t super_mutex;
 static vlc_cond_t  super_variable;
-extern vlc_rwlock_t config_lock;
 
 int _CRT_init(void);
 void _CRT_term(void);
@@ -151,12 +150,10 @@ unsigned long _System _DLL_InitTerm(unsigned long hmod, 
unsigned long flag)
 vlc_mutex_init (_mutex);
 vlc_cond_init (_variable);
 vlc_threadvar_create (_key, NULL);
-vlc_rwlock_init (_lock);
 
 return 1;
 
 case 1 :/* Termination */
-vlc_rwlock_destroy (_lock);
 vlc_threadvar_delete (_key);
 
 _CRT_term();

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] variables: privatise the callback CV

2020-12-19 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Tue Dec 15 
21:39:08 2020 +0200| [5ab3e74bcd7a2e02a4860a524955be365557ef46] | committer: 
Rémi Denis-Courmont

variables: privatise the callback CV

The condition variable was shared across all variables of a given
object to save space, but it ends up waking up the wrong waiting
threads.

vlc_cond_t is not as large as it used to be. In fact, it could be as
small as a single pointer: if we required holding the mutex during
signal/broadcast. The nested mutex is only there to handle unprotected
signalling.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5ab3e74bcd7a2e02a4860a524955be365557ef46
---

 src/misc/objects.c   | 1 -
 src/misc/variables.c | 8 +---
 src/misc/variables.h | 1 -
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/misc/objects.c b/src/misc/objects.c
index 7b15ae91d0..f43549d1a1 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -69,7 +69,6 @@ int vlc_object_init(vlc_object_t *restrict obj, vlc_object_t 
*parent,
 priv->typename = typename;
 priv->var_root = NULL;
 vlc_mutex_init (>var_lock);
-vlc_cond_init (>var_wait);
 priv->resources = NULL;
 
 obj->priv = priv;
diff --git a/src/misc/variables.c b/src/misc/variables.c
index ed284cf4f4..f12e55d4e7 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -96,6 +96,8 @@ struct variable_t
 callback_entry_t*value_callbacks;
 /** Registered list callbacks */
 callback_entry_t*list_callbacks;
+
+vlc_cond_t   wait;
 };
 
 static int CmpBool( vlc_value_t v, vlc_value_t w )
@@ -228,7 +230,7 @@ static void WaitUnused(vlc_object_t *obj, variable_t *var)
 
 mutex_cleanup_push(>var_lock);
 while (var->b_incallback)
-vlc_cond_wait(>var_wait, >var_lock);
+vlc_cond_wait(>wait, >var_lock);
 vlc_cleanup_pop();
 }
 
@@ -256,7 +258,7 @@ static void TriggerCallback(vlc_object_t *obj, variable_t 
*var,
 
 vlc_mutex_lock(>var_lock);
 var->b_incallback = false;
-vlc_cond_broadcast(>var_wait);
+vlc_cond_broadcast(>wait);
 }
 
 static void TriggerListCallback(vlc_object_t *obj, variable_t *var,
@@ -283,7 +285,7 @@ static void TriggerListCallback(vlc_object_t *obj, 
variable_t *var,
 
 vlc_mutex_lock(>var_lock);
 var->b_incallback = false;
-vlc_cond_broadcast(>var_wait);
+vlc_cond_broadcast(>wait);
 }
 
 int (var_Create)( vlc_object_t *p_this, const char *psz_name, int i_type )
diff --git a/src/misc/variables.h b/src/misc/variables.h
index 5ef84f1b2a..711cd14b5a 100644
--- a/src/misc/variables.h
+++ b/src/misc/variables.h
@@ -40,7 +40,6 @@ struct vlc_object_internals
 /* Object variables */
 void   *var_root;
 vlc_mutex_t var_lock;
-vlc_cond_t  var_wait;
 
 /* Object resources */
 struct vlc_res *resources;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] tls: document vlc_tls_SocketOpenTCP parameters

2020-12-12 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sat Dec 12 
15:11:04 2020 +0200| [8b71a40554d0cf57ba59cbc61c502287296fcb92] | committer: 
Rémi Denis-Courmont

tls: document vlc_tls_SocketOpenTCP parameters

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8b71a40554d0cf57ba59cbc61c502287296fcb92
---

 include/vlc_tls.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/include/vlc_tls.h b/include/vlc_tls.h
index 18dbcd09ec..976e670d05 100644
--- a/include/vlc_tls.h
+++ b/include/vlc_tls.h
@@ -457,6 +457,10 @@ VLC_API vlc_tls_t *vlc_tls_SocketOpenAddrInfo(const struct 
addrinfo *ai,
  * This function resolves a hostname, and attempts to establish a TCP/IP
  * connection to the specified host and port number.
  *
+ * @param obj optional object to log errors (may be NULL)
+ * @param hostname remote host name or IP address literal to connect to
+ * @param port remote TCP port number to connect to
+ *
  * @note The function currently iterates through the addrinfo linked list.
  * Future versions may implement different behaviour (e.g. RFC6555).
  *

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] lua: appropriate --lua option and fix caption

2020-12-12 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Fri Dec 11 
17:12:06 2020 +0200| [7cda5b695bc3b319c1d0acfcdf0db64b09e9b3a7] | committer: 
Rémi Denis-Courmont

lua: appropriate --lua option and fix caption

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7cda5b695bc3b319c1d0acfcdf0db64b09e9b3a7
---

 modules/lua/vlc.c   | 3 +++
 src/libvlc-module.c | 4 
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/modules/lua/vlc.c b/modules/lua/vlc.c
index 8238efdf52..1fe5a6faa8 100644
--- a/modules/lua/vlc.c
+++ b/modules/lua/vlc.c
@@ -45,6 +45,8 @@
 /*
  * Module descriptor
  */
+
+#define LUA_TEXT N_("Enable Lua plugins")
 #define INTF_TEXT N_("Lua interface")
 #define INTF_LONGTEXT N_("Lua interface module to load")
 
@@ -78,6 +80,7 @@ vlc_module_begin ()
 set_category( CAT_INTERFACE )
 set_subcategory( SUBCAT_INTERFACE_MAIN )
 
+add_bool( "lua", true, LUA_TEXT, LUA_TEXT, true );
 add_string( "lua-intf", "dummy", INTF_TEXT, INTF_LONGTEXT, false )
 add_string( "lua-config", "", CONFIG_TEXT, CONFIG_LONGTEXT, false )
 set_capability( "interface", 0 )
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 9da8fa407b..5f3c93c53c 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -723,8 +723,6 @@ static const char *const ppsz_prefres[] = {
 "$n: Track num$p: Now playing$A: Date$D: Duration"  \
 "$Z: \"Now playing\" (Fall back on Title - Artist)" )
 
-#define INPUT_LUA_TEXT N_( "Disable all lua plugins" )
-
 // DEPRECATED
 #define SUB_CAT_LONGTEXT N_( \
 "These options allow you to modify the behavior of the subpictures " \
@@ -2000,8 +1998,6 @@ vlc_module_begin ()
 
 add_string( "input-title-format", "$Z", INPUT_TITLE_FORMAT_TEXT, 
INPUT_TITLE_FORMAT_LONGTEXT, false );
 
-add_bool( "lua", true, INPUT_LUA_TEXT, INPUT_LUA_TEXT, true );
-
 /* Decoder options */
 set_subcategory( SUBCAT_INPUT_VCODEC )
 add_category_hint(N_("Decoders"), CODEC_CAT_LONGTEXT)

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] gst: remove dead code

2020-12-04 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Fri Dec  4 
17:42:59 2020 +0200| [20dbaa1c801fac138fd4bc6c37f6c20c745af85e] | committer: 
Rémi Denis-Courmont

gst: remove dead code

gst_atomic_queue_new() cannot return NULL.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=20dbaa1c801fac138fd4bc6c37f6c20c745af85e
---

 modules/codec/gstreamer/gstdecode.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/modules/codec/gstreamer/gstdecode.c 
b/modules/codec/gstreamer/gstdecode.c
index 7cb798c6c6..f4302c9e2a 100644
--- a/modules/codec/gstreamer/gstdecode.c
+++ b/modules/codec/gstreamer/gstdecode.c
@@ -530,8 +530,6 @@ static int OpenDecoder( vlc_object_t *p_this )
 /* Queue: GStreamer thread will dump buffers into this queue,
  * DecodeBlock() will pop out the buffers from the queue */
 p_sys->p_que = gst_atomic_queue_new( 0 );
-VLC_GST_CHECK( p_sys->p_que, NULL, "failed to create queue",
-VLC_ENOMEM );
 
 p_sys->p_decode_src = gst_element_factory_make( "appsrc", NULL );
 VLC_GST_CHECK( p_sys->p_decode_src, NULL, "appsrc not found",

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] mux/ts: add missing error check

2020-12-04 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Mon Nov 30 
23:52:13 2020 +0200| [b66b683f07794af1cb95ea1fa68d353ee857f1b4] | committer: 
Rémi Denis-Courmont

mux/ts: add missing error check

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b66b683f07794af1cb95ea1fa68d353ee857f1b4
---

 modules/mux/mpeg/ts.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/modules/mux/mpeg/ts.c b/modules/mux/mpeg/ts.c
index 569735541b..c5df6a1d3b 100644
--- a/modules/mux/mpeg/ts.c
+++ b/modules/mux/mpeg/ts.c
@@ -493,6 +493,9 @@ static csa_t *csaSetup( vlc_object_t *p_this )
 
 csa_t *csa = csa_New();
 
+if( unlikely(csa == NULL) )
+return NULL;
+
 if( csa_SetCW( p_this, csa, csack, true ) )
 {
 free(csack);

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] gst: remove bogus error message

2020-12-04 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Fri Dec  4 
17:40:10 2020 +0200| [e7afa8c45d33b93b42b6928675e120c3a62039a7] | committer: 
Rémi Denis-Courmont

gst: remove bogus error message

A NULL list means there are no matching items. It is not an error per
se. In practice,  it will lead to an error later on, which will be
handled properly by existing code.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e7afa8c45d33b93b42b6928675e120c3a62039a7
---

 modules/codec/gstreamer/gstdecode.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/modules/codec/gstreamer/gstdecode.c 
b/modules/codec/gstreamer/gstdecode.c
index b57464d4a5..7cb798c6c6 100644
--- a/modules/codec/gstreamer/gstdecode.c
+++ b/modules/codec/gstreamer/gstdecode.c
@@ -496,7 +496,6 @@ static int OpenDecoder( vlc_object_t *p_this )
 /* Get the list of all the available gstreamer decoders */
 p_list = gst_element_factory_list_get_elements(
 GST_ELEMENT_FACTORY_TYPE_DECODER, GST_RANK_MARGINAL );
-VLC_GST_CHECK( p_list, NULL, "no decoder list found", VLC_ENOMOD );
 if( !dbin )
 {
 GList *p_l;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] csa: do not handle impossibly NULL object

2020-12-04 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Mon Nov 30 
23:58:49 2020 +0200| [7a388292db3dbed309630f1125bfe59386044062] | committer: 
Rémi Denis-Courmont

csa: do not handle impossibly NULL object

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7a388292db3dbed309630f1125bfe59386044062
---

 modules/mux/mpeg/csa.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/modules/mux/mpeg/csa.c b/modules/mux/mpeg/csa.c
index e6363cd965..ba16865f48 100644
--- a/modules/mux/mpeg/csa.c
+++ b/modules/mux/mpeg/csa.c
@@ -78,11 +78,8 @@ void csa_Delete( csa_t *c )
  */
 int csa_SetCW( vlc_object_t *p_caller, csa_t *c, char *psz_ck, bool set_odd )
 {
-if ( !c )
-{
-msg_Dbg( p_caller, "no CSA found" );
-return VLC_ENOOBJ;
-}
+assert(c != NULL);
+
 /* skip 0x */
 if( psz_ck[0] == '0' && ( psz_ck[1] == 'x' || psz_ck[1] == 'X' ) )
 {

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] gst: do not handle impossible error

2020-12-04 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Fri Dec  4 
17:38:42 2020 +0200| [88f3b319d3b8e1ae86e4fc889d8f9d3899e18e27] | committer: 
Rémi Denis-Courmont

gst: do not handle impossible error

Sorting a glib list cannot fail. A NULL result means the list was
empty, not that an error occurred.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=88f3b319d3b8e1ae86e4fc889d8f9d3899e18e27
---

 modules/codec/gstreamer/gstdecode.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/modules/codec/gstreamer/gstdecode.c 
b/modules/codec/gstreamer/gstdecode.c
index 020bc9ded6..b57464d4a5 100644
--- a/modules/codec/gstreamer/gstdecode.c
+++ b/modules/codec/gstreamer/gstdecode.c
@@ -502,8 +502,6 @@ static int OpenDecoder( vlc_object_t *p_this )
 GList *p_l;
 /* Sort them as per ranks */
 p_list = g_list_sort( p_list, gst_plugin_feature_rank_compare_func );
-VLC_GST_CHECK( p_list, NULL, "failed to sort decoders list",
-VLC_ENOMOD );
 p_l = g_list_find_custom( p_list, , find_decoder_func );
 VLC_GST_CHECK( p_l, NULL, "no suitable decoder found",
 VLC_ENOMOD );

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] omxil: remove dead code

2020-12-04 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Mon Nov 30 
23:28:13 2020 +0200| [4efe147379d039aae65e76663e24759ad97297fd] | committer: 
Rémi Denis-Courmont

omxil: remove dead code

That error code cannot be returned here.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4efe147379d039aae65e76663e24759ad97297fd
---

 modules/codec/omxil/mediacodec.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index 041faa9a46..e5dae9343f 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -1647,8 +1647,6 @@ static int DecodeBlock(decoder_t *p_dec, block_t 
*p_in_block)
 case VLC_SUCCESS:
 msg_Warn(p_dec, "Restarted from DecodeBlock");
 break;
-case VLC_ENOOBJ:
-break;
 default:
 msg_Err(p_dec, "StartMediaCodec failed");
 AbortDecoderLocked(p_dec);

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] demux/ts: handle allocation error

2020-12-04 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Mon Nov 30 
23:54:51 2020 +0200| [9c31f2666d3a6d230239d92532d1890c94ec1b62] | committer: 
Rémi Denis-Courmont

demux/ts: handle allocation error

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9c31f2666d3a6d230239d92532d1890c94ec1b62
---

 modules/demux/mpeg/ts.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/modules/demux/mpeg/ts.c b/modules/demux/mpeg/ts.c
index 54edd253ab..9c7c4625c6 100644
--- a/modules/demux/mpeg/ts.c
+++ b/modules/demux/mpeg/ts.c
@@ -454,8 +454,14 @@ static int Open( vlc_object_t *p_this )
 
 p_sys->csa = csa_New();
 
-psz_csa2 = var_CreateGetStringCommand( p_demux, "ts-csa2-ck" );
-i_res = csa_SetCW( (vlc_object_t*)p_demux, p_sys->csa, psz_string, 
true );
+if( p_sys->csa )
+{
+psz_csa2 = var_CreateGetStringCommand( p_demux, "ts-csa2-ck" );
+i_res = csa_SetCW( (vlc_object_t*)p_demux, p_sys->csa, psz_string, 
true );
+}
+else
+i_res = VLC_ENOMEM;
+
 if( i_res == VLC_SUCCESS && psz_csa2 && *psz_csa2 )
 {
 if( csa_SetCW( (vlc_object_t*)p_demux, p_sys->csa, psz_csa2, false 
) != VLC_SUCCESS )

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] csa: do not handle impossible NULL argument

2020-12-04 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Mon Nov 30 
23:58:10 2020 +0200| [811b77c304046b4b39ee614f57bd75029e2e4385] | committer: 
Rémi Denis-Courmont

csa: do not handle impossible NULL argument

The CSA structure cannot be NULL in this context.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=811b77c304046b4b39ee614f57bd75029e2e4385
---

 modules/mux/mpeg/csa.c | 6 +++---
 modules/mux/mpeg/csa.h | 2 +-
 modules/mux/mpeg/ts.c  | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/modules/mux/mpeg/csa.c b/modules/mux/mpeg/csa.c
index 19c2d6ad93..e6363cd965 100644
--- a/modules/mux/mpeg/csa.c
+++ b/modules/mux/mpeg/csa.c
@@ -26,6 +26,7 @@
 # include "config.h"
 #endif
 
+#include 
 #include 
 
 #include "csa.h"
@@ -124,15 +125,14 @@ int csa_SetCW( vlc_object_t *p_caller, csa_t *c, char 
*psz_ck, bool set_odd )
 /*
  * csa_UseKey:
  */
-int csa_UseKey( vlc_object_t *p_caller, csa_t *c, bool use_odd )
+void csa_UseKey( vlc_object_t *p_caller, csa_t *c, bool use_odd )
 {
-if ( !c ) return VLC_ENOOBJ;
+assert(c != NULL);
 c->use_odd = use_odd;
 #ifndef TS_NO_CSA_CK_MSG
 msg_Dbg( p_caller, "using the %s key for scrambling",
  use_odd ? "odd" : "even" );
 #endif
-return VLC_SUCCESS;
 }
 
 /*
diff --git a/modules/mux/mpeg/csa.h b/modules/mux/mpeg/csa.h
index bbe13c5985..7badc3823c 100644
--- a/modules/mux/mpeg/csa.h
+++ b/modules/mux/mpeg/csa.h
@@ -35,7 +35,7 @@ csa_t *csa_New( void );
 void   csa_Delete( csa_t * );
 
 intcsa_SetCW( vlc_object_t *p_caller, csa_t *c, char *psz_ck, bool odd );
-intcsa_UseKey( vlc_object_t *p_caller, csa_t *, bool use_odd );
+void   csa_UseKey( vlc_object_t *p_caller, csa_t *, bool use_odd );
 
 void   csa_Decrypt( csa_t *, uint8_t *pkt, int i_pkt_size );
 void   csa_Encrypt( csa_t *, uint8_t *pkt, int i_pkt_size );
diff --git a/modules/mux/mpeg/ts.c b/modules/mux/mpeg/ts.c
index d52289a325..569735541b 100644
--- a/modules/mux/mpeg/ts.c
+++ b/modules/mux/mpeg/ts.c
@@ -828,10 +828,10 @@ static int ActiveKeyCallback( vlc_object_t *p_this, char 
const *psz_cmd,
 return VLC_EBADVAR;
 
 vlc_mutex_lock( _sys->csa_lock );
-i_res = csa_UseKey( p_this, p_sys->csa, use_odd );
+csa_UseKey( p_this, p_sys->csa, use_odd );
 vlc_mutex_unlock( _sys->csa_lock );
 
-return i_res;
+return VLC_SUCCESS;
 }
 
 /*

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] cli: use vlc_dup2()

2020-11-30 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 29 
11:48:02 2020 +0200| [a4ca0de9e087e6a6a3bb86c585cf29ad5c553576] | committer: 
Rémi Denis-Courmont

cli: use vlc_dup2()

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a4ca0de9e087e6a6a3bb86c585cf29ad5c553576
---

 modules/control/cli/cli.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index 9c93a26f9a..2fa1e7b90d 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -224,11 +224,7 @@ static int LogOut(struct cli_client *cl, const char *const 
*args, size_t count,
 
 fflush(cl->stream);
 if (fd2 != 1)
-#ifdef HAVE_DUP3
-dup3(fd, fd2, O_CLOEXEC);
-#else
-dup2(fd, fd2), fcntl(fd2, F_SETFD, FD_CLOEXEC);
-#endif
+vlc_dup2(fd, fd2);
 else
 dup2(fd, fd2);
 fseek(cl->stream, 0, SEEK_SET);

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] filesystem: add vlc_dup2() wrapper

2020-11-30 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 29 
11:45:29 2020 +0200| [6788528b1331eb59328a4639ac2eac327f347b1b] | committer: 
Rémi Denis-Courmont

filesystem: add vlc_dup2() wrapper

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6788528b1331eb59328a4639ac2eac327f347b1b
---

 include/vlc_fs.h   | 17 +
 src/libvlccore.sym |  1 +
 src/posix/filesystem.c | 12 
 src/win32/filesystem.c |  8 
 4 files changed, 38 insertions(+)

diff --git a/include/vlc_fs.h b/include/vlc_fs.h
index 4a50288be0..9ad2028053 100644
--- a/include/vlc_fs.h
+++ b/include/vlc_fs.h
@@ -110,6 +110,23 @@ VLC_API int vlc_mkstemp( char * );
  */
 VLC_API int vlc_dup(int oldfd) VLC_USED;
 
+/**
+ * Replaces a file descriptor.
+ *
+ * This function duplicates a file descriptor to a specified file descriptor.
+ * This is primarily used to atomically replace a described file.
+ *
+ * @param oldfd source file descriptor to copy
+ * @param newfd destination file descriptor to replace
+ *
+ * @note Contrary to standard dup2(), the new file descriptor has the
+ * close-on-exec descriptor flag preset.
+ *
+ * @retval newfd success
+ * @retval -1 failure (see @c errno)
+ */
+VLC_API int vlc_dup2(int oldfd, int newfd);
+
 /**
  * Creates a pipe (see "man pipe" for further reference). The new file
  * descriptors have the close-on-exec flag preset.
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index e3a2de9f6d..2cfe0d376c 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -448,6 +448,7 @@ vlc_unlink
 vlc_rename
 vlc_getcwd
 vlc_dup
+vlc_dup2
 vlc_pipe
 vlc_write
 vlc_writev
diff --git a/src/posix/filesystem.c b/src/posix/filesystem.c
index 60a997d9e0..18105a643c 100644
--- a/src/posix/filesystem.c
+++ b/src/posix/filesystem.c
@@ -178,6 +178,18 @@ int vlc_dup (int oldfd)
 return fcntl (oldfd, F_DUPFD_CLOEXEC, 0);
 }
 
+int vlc_dup2(int oldfd, int newfd)
+{
+#ifdef HAVE_DUP3
+return dup3(oldfd, newfd, O_CLOEXEC);
+#else
+int ret = dup2(oldfd, newfd);
+if (ret >= 0)
+vlc_cloexec(newfd);
+return ret;
+#endif
+}
+
 int vlc_pipe (int fds[2])
 {
 #ifdef HAVE_PIPE2
diff --git a/src/win32/filesystem.c b/src/win32/filesystem.c
index d8e3cc1127..09b8ec70d3 100644
--- a/src/win32/filesystem.c
+++ b/src/win32/filesystem.c
@@ -304,6 +304,14 @@ int vlc_dup (int oldfd)
 return fd;
 }
 
+int vlc_dup2(int oldfd, int newfd)
+{
+int fd = dup2(oldfd, newfd);
+if (fd != -1)
+setmode(fd, O_BINARY);
+return fd;
+}
+
 int vlc_pipe (int fds[2])
 {
 #if VLC_WINSTORE_APP

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] hotkeys: fix flawed arithmetic (fixes #25141)

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 29 
23:02:38 2020 +0200| [30d647f78d40d0834f50e4b2702e00cdd275b00a] | committer: 
Rémi Denis-Courmont

hotkeys: fix flawed arithmetic (fixes #25141)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=30d647f78d40d0834f50e4b2702e00cdd275b00a
---

 modules/control/hotkeys.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index 7f554ff301..ad8ba0e6e7 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -223,8 +223,8 @@ INTF_ACTION_HANDLER(PlaylistBookmark)
 {
 bool set = action_id >= ACTIONID_SET_BOOKMARK1 &&
action_id <= ACTIONID_SET_BOOKMARK10;
-int id = set ? ACTIONID_SET_BOOKMARK1 : ACTIONID_PLAY_BOOKMARK1;
-id -= action_id - 1;
+int id = (set ? 1 - ACTIONID_SET_BOOKMARK1 : 1 - ACTIONID_PLAY_BOOKMARK1);
+id += action_id;
 char *bookmark_name;
 if (asprintf(_name, "bookmark%i", id) == -1)
 return;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] xcb/window: report initial mouse position (refs #24960)

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 29 
18:52:13 2020 +0200| [473c520b4b412ac91d87365213baefbb9ec95ddd] | committer: 
Rémi Denis-Courmont

xcb/window: report initial mouse position (refs #24960)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=473c520b4b412ac91d87365213baefbb9ec95ddd
---

 modules/video_output/xcb/window.c | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/modules/video_output/xcb/window.c 
b/modules/video_output/xcb/window.c
index 5e58d10ebf..5b71cbb6d1 100644
--- a/modules/video_output/xcb/window.c
+++ b/modules/video_output/xcb/window.c
@@ -557,7 +557,20 @@ static int Enable(vout_window_t *wnd, const 
vout_window_cfg_t *restrict cfg)
 
 /* Make the window visible */
 xcb_map_window(conn, window);
-xcb_flush(conn);
+
+/* Report initial pointer position.
+ * This will implicitly flush the XCB connection so that the window gets
+ * mapped by the display server shortly.
+ */
+xcb_query_pointer_cookie_t qpc = xcb_query_pointer(conn, window);
+xcb_query_pointer_reply_t *pr = xcb_query_pointer_reply(conn, qpc, NULL);
+
+if (pr != NULL)
+{
+vout_window_ReportMouseMoved(wnd, pr->win_x, pr->win_y);
+free(pr);
+}
+
 return VLC_SUCCESS;
 }
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] xcb/window: ignore the structure events

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 29 
19:03:53 2020 +0200| [555f29b0c0981567c6043f3fd8247fa49ffe5fa8] | committer: 
Rémi Denis-Courmont

xcb/window: ignore the structure events

No need to log those; we know what they and why we receive them.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=555f29b0c0981567c6043f3fd8247fa49ffe5fa8
---

 modules/video_output/xcb/window.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/modules/video_output/xcb/window.c 
b/modules/video_output/xcb/window.c
index 5b71cbb6d1..44771b7d5b 100644
--- a/modules/video_output/xcb/window.c
+++ b/modules/video_output/xcb/window.c
@@ -291,6 +291,15 @@ static int ProcessEvent(vout_window_t *wnd, 
xcb_generic_event_t *ev)
 vout_window_ReportClose (wnd);
 break;
 
+case XCB_UNMAP_NOTIFY:
+break;
+
+case XCB_MAP_NOTIFY:
+break;
+
+case XCB_REPARENT_NOTIFY:
+break;
+
 case XCB_MAPPING_NOTIFY:
 break;
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] xcb/window: reset cursor timer on map (fixes #24960)

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 29 
19:04:33 2020 +0200| [410224060e749192f1a1af221311795549df1fb7] | committer: 
Rémi Denis-Courmont

xcb/window: reset cursor timer on map (fixes #24960)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=410224060e749192f1a1af221311795549df1fb7
---

 modules/video_output/xcb/window.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/modules/video_output/xcb/window.c 
b/modules/video_output/xcb/window.c
index 44771b7d5b..8d65b0dcf7 100644
--- a/modules/video_output/xcb/window.c
+++ b/modules/video_output/xcb/window.c
@@ -295,6 +295,7 @@ static int ProcessEvent(vout_window_t *wnd, 
xcb_generic_event_t *ev)
 break;
 
 case XCB_MAP_NOTIFY:
+ret = 1;
 break;
 
 case XCB_REPARENT_NOTIFY:

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] cli: don't create listener thread for console mode

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 29 
12:39:18 2020 +0200| [7adefbdd15ad84a0dcba4df95de0d0ba534f] | committer: 
Rémi Denis-Courmont

cli: don't create listener thread for console mode

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7adefbdd15ad84a0dcba4df95de0d0ba534f
---

 modules/control/cli/cli.c | 20 
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index 5c10cd9ce4..0196b26d57 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -510,10 +510,10 @@ static void *Run(void *data)
 intf_thread_t *intf = data;
 intf_sys_t *sys = intf->p_sys;
 
-while (sys->pi_socket_listen != NULL)
-{
-assert(sys->pi_socket_listen != NULL);
+assert(sys->pi_socket_listen != NULL);
 
+for (;;)
+{
 int fd = net_Accept(intf, sys->pi_socket_listen);
 if (fd == -1)
 continue;
@@ -529,8 +529,6 @@ static void *Run(void *data)
 vlc_mutex_unlock(>clients_lock);
 }
 }
-
-return NULL;
 }
 
 #else
@@ -944,8 +942,8 @@ static int Activate( vlc_object_t *p_this )
 goto error;
 vlc_list_append(>node, _sys->clients);
 }
+else
 #endif
-
 if( vlc_clone( _sys->thread, Run, p_intf, VLC_THREAD_PRIORITY_LOW ) )
 goto error;
 
@@ -976,8 +974,14 @@ static void Deactivate( vlc_object_t *p_this )
 intf_thread_t *p_intf = (intf_thread_t*)p_this;
 intf_sys_t *p_sys = p_intf->p_sys;
 
-vlc_cancel( p_sys->thread );
-vlc_join( p_sys->thread, NULL );
+#ifndef _WIN32
+if (p_sys->pi_socket_listen != NULL)
+#endif
+{
+vlc_cancel(p_sys->thread);
+vlc_join(p_sys->thread, NULL);
+}
+
 DeregisterPlayer(p_intf, p_sys->player_cli);
 
 #ifndef _WIN32

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] cli: don't wait for exit to reap dead clients

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 29 
15:33:39 2020 +0200| [9095693cd4640b626cb3d7755a39ea609193fd6d] | committer: 
Rémi Denis-Courmont

cli: don't wait for exit to reap dead clients

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9095693cd4640b626cb3d7755a39ea609193fd6d
---

 modules/control/cli/cli.c | 15 ++-
 modules/control/cli/cli.h |  2 ++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index b71ff46a02..9c93a26f9a 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -442,6 +442,7 @@ static void *cli_client_thread(void *data)
 vlc_restorecancel(canc);
 }
 
+atomic_store_explicit(>zombie, true, memory_order_release);
 return NULL;
 }
 
@@ -454,6 +455,7 @@ static struct cli_client *cli_client_new(intf_thread_t 
*intf, int fd,
 
 cl->stream = stream;
 cl->fd = fd;
+atomic_init(>zombie, false);
 cl->intf = intf;
 vlc_mutex_init(>output_lock);
 
@@ -520,7 +522,6 @@ static void *Run(void *data)
 
 int canc = vlc_savecancel();
 struct cli_client *cl = cli_client_new_fd(intf, fd);
-vlc_restorecancel(canc);
 
 if (cl != NULL)
 {
@@ -528,6 +529,18 @@ static void *Run(void *data)
 vlc_list_append(>node, >clients);
 vlc_mutex_unlock(>clients_lock);
 }
+
+/* Reap any dead client */
+vlc_list_foreach (cl, >clients, node)
+if (atomic_load_explicit(>zombie, memory_order_acquire))
+{
+vlc_mutex_lock(>clients_lock);
+vlc_list_remove(>node);
+vlc_mutex_unlock(>clients_lock);
+cli_client_delete(cl);
+}
+
+vlc_restorecancel(canc);
 }
 }
 
diff --git a/modules/control/cli/cli.h b/modules/control/cli/cli.h
index 162c8c23cd..d1dde7b9c1 100644
--- a/modules/control/cli/cli.h
+++ b/modules/control/cli/cli.h
@@ -21,6 +21,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, 
USA.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -31,6 +32,7 @@ struct cli_client
 #ifndef _WIN32
 FILE *stream;
 int fd;
+atomic_bool zombie;
 vlc_mutex_t output_lock;
 struct vlc_list node;
 vlc_thread_t thread;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] cli: don't mess with stdout

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 29 
12:58:49 2020 +0200| [8cf92acf06b7cd2714c22160195614afa1d749a8] | committer: 
Rémi Denis-Courmont

cli: don't mess with stdout

If we don't use stdout, we should not reconfigure it.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8cf92acf06b7cd2714c22160195614afa1d749a8
---

 modules/control/cli/cli.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index 58773b22de..b71ff46a02 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -904,10 +904,10 @@ static int Activate( vlc_object_t *p_this )
 
 p_sys->pi_socket_listen = pi_socket;
 
+#ifndef _WIN32
 /* Line-buffered stdout */
-setvbuf( stdout, (char *)NULL, _IOLBF, 0 );
+setvbuf(stdout, NULL, _IOLBF, 0);
 
-#ifndef _WIN32
 if (pi_socket != NULL)
 #else
 p_sys->i_socket = -1;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] cli: allow console and Unix socket modes simultaneously

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 29 
12:51:51 2020 +0200| [493568b3e08993407a2510d3b39d2eadbd001c91] | committer: 
Rémi Denis-Courmont

cli: allow console and Unix socket modes simultaneously

This allows the interface to process commands both from the standard
input and from incoming Unix socket clients.

This also fixes a bug where socket mode would only start if the
standard input was a TTY or --rc-fake-tty was passed.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=493568b3e08993407a2510d3b39d2eadbd001c91
---

 modules/control/cli/cli.c | 28 +++-
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index b2f72b3f89..58773b22de 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -799,14 +799,18 @@ static int Activate( vlc_object_t *p_this )
 RegisterPlaylist(p_intf);
 
 #ifndef _WIN32
-#if defined(HAVE_ISATTY)
-/* Check that stdin is a TTY */
-if( !var_InheritBool( p_intf, "rc-fake-tty" ) && !isatty( 0 ) )
+# ifndef HAVE_ISATTY
+#  define isatty(fd) (fd, 0)
+# endif
+/* Start CLI on the standard input if it is an actual console */
+if (isatty(fileno(stdin)) || var_InheritBool(p_intf, "rc-fake-tty"))
 {
-msg_Warn( p_intf, "fd 0 is not a TTY" );
-goto error;
+cl = cli_client_new_std(p_intf);
+if (cl == NULL)
+goto error;
+vlc_list_append(>node, _sys->clients);
 }
-#endif
+
 #ifdef AF_LOCAL
 char *psz_unix_path = var_InheritString(p_intf, "rc-unix");
 if( psz_unix_path )
@@ -904,6 +908,7 @@ static int Activate( vlc_object_t *p_this )
 setvbuf( stdout, (char *)NULL, _IOLBF, 0 );
 
 #ifndef _WIN32
+if (pi_socket != NULL)
 #else
 p_sys->i_socket = -1;
 #if VLC_WINSTORE_APP
@@ -913,17 +918,6 @@ static int Activate( vlc_object_t *p_this )
 if( !p_sys->b_quiet )
 intf_consoleIntroMsg( p_intf );
 #endif
-#endif
-
-#ifndef _WIN32
-if (pi_socket == NULL)
-{
-cl = cli_client_new_std(p_intf);
-if (cl == NULL)
-goto error;
-vlc_list_append(>node, _sys->clients);
-}
-else
 #endif
 if( vlc_clone( _sys->thread, Run, p_intf, VLC_THREAD_PRIORITY_LOW ) )
 goto error;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] cli: simplify deleting the Unix socket

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 29 
13:26:07 2020 +0200| [44bd5fccbc69772f5d856ce31ce5b68e1f631cd1] | committer: 
Rémi Denis-Courmont

cli: simplify deleting the Unix socket

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=44bd5fccbc69772f5d856ce31ce5b68e1f631cd1
---

 modules/control/cli/cli.c | 35 +--
 1 file changed, 9 insertions(+), 26 deletions(-)

diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index 4fd28c2ee8..b2f72b3f89 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #ifdef HAVE_WORDEXP_H
@@ -72,7 +73,6 @@ struct intf_sys_t
 #ifndef _WIN32
 vlc_mutex_t clients_lock;
 struct vlc_list clients;
-char *psz_unix_path;
 #else
 HANDLE hConsoleIn;
 bool b_quiet;
@@ -813,6 +813,7 @@ static int Activate( vlc_object_t *p_this )
 {
 int i_socket;
 struct sockaddr_un addr = { .sun_family = AF_LOCAL };
+struct stat st;
 
 msg_Dbg( p_intf, "trying UNIX socket" );
 
@@ -825,6 +826,7 @@ static int Activate( vlc_object_t *p_this )
 goto error;
 }
 memcpy(addr.sun_path, psz_unix_path, len + 1);
+free(psz_unix_path);
 
 if( (i_socket = vlc_socket( PF_LOCAL, SOCK_STREAM, 0, false ) ) < 0 )
 {
@@ -832,24 +834,14 @@ static int Activate( vlc_object_t *p_this )
 goto error;
 }
 
-if (bind (i_socket, (struct sockaddr *), sizeof (addr))
- && (errno == EADDRINUSE)
- && connect (i_socket, (struct sockaddr *), sizeof (addr))
- && (errno == ECONNREFUSED))
+if (vlc_stat(addr.sun_path, ) == 0 && S_ISSOCK(st.st_mode))
 {
-msg_Info (p_intf, "Removing dead UNIX socket: %s", psz_unix_path);
-unlink (psz_unix_path);
-
-if (bind (i_socket, (struct sockaddr *), sizeof (addr)))
-{
-msg_Err (p_intf, "cannot bind UNIX socket at %s: %s",
- psz_unix_path, vlc_strerror_c(errno));
-net_Close (i_socket);
-goto error;
-}
+msg_Dbg(p_intf, "unlinking old %s socket", addr.sun_path);
+unlink(addr.sun_path);
 }
 
-if( listen( i_socket, 1 ) )
+if (bind(i_socket, (struct sockaddr *), sizeof (addr))
+ || listen(i_socket, 1))
 {
 msg_Warn (p_intf, "can't listen on socket: %s",
   vlc_strerror_c(errno));
@@ -861,13 +853,11 @@ static int Activate( vlc_object_t *p_this )
 pi_socket = calloc( 2, sizeof( int ) );
 if( pi_socket == NULL )
 {
-free( psz_unix_path );
 net_Close( i_socket );
 goto error;
 }
 pi_socket[0] = i_socket;
 pi_socket[1] = -1;
-p_sys->psz_unix_path = psz_unix_path;
 }
 #endif /* AF_LOCAL */
 #endif /* !_WIN32 */
@@ -952,7 +942,6 @@ error:
 #endif
 tdestroy(p_sys->commands, free);
 net_ListenClose( pi_socket );
-free( psz_unix_path );
 return VLC_EGENERIC;
 }
 
@@ -985,13 +974,7 @@ static void Deactivate( vlc_object_t *p_this )
 if (p_sys->pi_socket_listen != NULL)
 {
 net_ListenClose(p_sys->pi_socket_listen);
-#ifndef _WIN32
-if (p_sys->psz_unix_path != NULL)
-{
-unlink(p_sys->psz_unix_path);
-free(p_sys->psz_unix_path);
-}
-#else
+#ifdef _WIN32
 if (p_sys->i_socket != -1)
 net_Close(p_sys->i_socket);
 #endif

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] cli: simplify initialising Unix socket address

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 29 
13:39:36 2020 +0200| [b80e1b77c87f6a1c946db440e72af279011f30c0] | committer: 
Rémi Denis-Courmont

cli: simplify initialising Unix socket address

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b80e1b77c87f6a1c946db440e72af279011f30c0
---

 modules/control/cli/cli.c | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index cc751495dd..4fd28c2ee8 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -812,19 +812,19 @@ static int Activate( vlc_object_t *p_this )
 if( psz_unix_path )
 {
 int i_socket;
-struct sockaddr_un addr;
-
-memset( , 0, sizeof(struct sockaddr_un) );
+struct sockaddr_un addr = { .sun_family = AF_LOCAL };
 
 msg_Dbg( p_intf, "trying UNIX socket" );
 
 /* The given unix path cannot be longer than sun_path - 1 to take into
  * account the terminated null character. */
-if ( strlen(psz_unix_path) + 1 >= sizeof( addr.sun_path ) )
+size_t len = strlen(psz_unix_path);
+if (len >= sizeof (addr.sun_path))
 {
 msg_Err( p_intf, "rc-unix value is longer than expected" );
 goto error;
 }
+memcpy(addr.sun_path, psz_unix_path, len + 1);
 
 if( (i_socket = vlc_socket( PF_LOCAL, SOCK_STREAM, 0, false ) ) < 0 )
 {
@@ -832,10 +832,6 @@ static int Activate( vlc_object_t *p_this )
 goto error;
 }
 
-addr.sun_family = AF_LOCAL;
-strncpy( addr.sun_path, psz_unix_path, sizeof( addr.sun_path ) - 1 );
-addr.sun_path[sizeof( addr.sun_path ) - 1] = '\0';
-
 if (bind (i_socket, (struct sockaddr *), sizeof (addr))
  && (errno == EADDRINUSE)
  && connect (i_socket, (struct sockaddr *), sizeof (addr))

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] cli/player: remove useless initial call

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 29 
13:09:24 2020 +0200| [a494178e7fe824996acb9fc4e547615d8e4d099e] | committer: 
Rémi Denis-Courmont

cli/player: remove useless initial call

There are no clients at the time of registration; this does nothing.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a494178e7fe824996acb9fc4e547615d8e4d099e
---

 modules/control/cli/player.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/modules/control/cli/player.c b/modules/control/cli/player.c
index 177403e7c0..437abb75e3 100644
--- a/modules/control/cli/player.c
+++ b/modules/control/cli/player.c
@@ -1086,7 +1086,6 @@ void *RegisterPlayer(intf_thread_t *intf)
 goto error;
 }
 
-player_on_state_changed(player, vlc_player_GetState(player), pc);
 vlc_player_Unlock(player);
 return pc;
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] cli: register commands before clients

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 29 
13:13:02 2020 +0200| [6daa9c487b98b3ee154cb0da5f384ee5cf0d6e23] | committer: 
Rémi Denis-Courmont

cli: register commands before clients

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6daa9c487b98b3ee154cb0da5f384ee5cf0d6e23
---

 modules/control/cli/cli.c | 63 ++-
 1 file changed, 29 insertions(+), 34 deletions(-)

diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index 0ce26c1a57..cc751495dd 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -777,20 +777,38 @@ static int Activate( vlc_object_t *p_this )
 {
 intf_thread_t *p_intf = (intf_thread_t*)p_this;
 struct cli_client *cl;
-char *psz_host, *psz_unix_path = NULL;
+char *psz_host;
 int  *pi_socket = NULL;
 
+intf_sys_t *p_sys = vlc_obj_malloc(p_this, sizeof (*p_sys));
+if (unlikely(p_sys == NULL))
+return VLC_ENOMEM;
+
+p_intf->p_sys = p_sys;
+p_sys->commands = NULL;
+#ifndef _WIN32
+vlc_mutex_init(_sys->clients_lock);
+vlc_list_init(_sys->clients);
+#endif
+RegisterHandlers(p_intf, cmds, ARRAY_SIZE(cmds), p_intf);
+
+p_sys->player_cli = RegisterPlayer(p_intf);
+if (unlikely(p_sys->player_cli == NULL))
+goto error;
+
+RegisterPlaylist(p_intf);
+
 #ifndef _WIN32
 #if defined(HAVE_ISATTY)
 /* Check that stdin is a TTY */
 if( !var_InheritBool( p_intf, "rc-fake-tty" ) && !isatty( 0 ) )
 {
 msg_Warn( p_intf, "fd 0 is not a TTY" );
-return VLC_EGENERIC;
+goto error;
 }
 #endif
 #ifdef AF_LOCAL
-psz_unix_path = var_InheritString( p_intf, "rc-unix" );
+char *psz_unix_path = var_InheritString(p_intf, "rc-unix");
 if( psz_unix_path )
 {
 int i_socket;
@@ -805,14 +823,13 @@ static int Activate( vlc_object_t *p_this )
 if ( strlen(psz_unix_path) + 1 >= sizeof( addr.sun_path ) )
 {
 msg_Err( p_intf, "rc-unix value is longer than expected" );
-return VLC_EGENERIC;
+goto error;
 }
 
 if( (i_socket = vlc_socket( PF_LOCAL, SOCK_STREAM, 0, false ) ) < 0 )
 {
 msg_Warn( p_intf, "can't open socket: %s", vlc_strerror_c(errno) );
-free( psz_unix_path );
-return VLC_EGENERIC;
+goto error;
 }
 
 addr.sun_family = AF_LOCAL;
@@ -831,9 +848,8 @@ static int Activate( vlc_object_t *p_this )
 {
 msg_Err (p_intf, "cannot bind UNIX socket at %s: %s",
  psz_unix_path, vlc_strerror_c(errno));
-free (psz_unix_path);
 net_Close (i_socket);
-return VLC_EGENERIC;
+goto error;
 }
 }
 
@@ -841,9 +857,8 @@ static int Activate( vlc_object_t *p_this )
 {
 msg_Warn (p_intf, "can't listen on socket: %s",
   vlc_strerror_c(errno));
-free( psz_unix_path );
 net_Close( i_socket );
-return VLC_EGENERIC;
+goto error;
 }
 
 /* FIXME: we need a core function to merge listening sockets sets */
@@ -852,10 +867,11 @@ static int Activate( vlc_object_t *p_this )
 {
 free( psz_unix_path );
 net_Close( i_socket );
-return VLC_ENOMEM;
+goto error;
 }
 pi_socket[0] = i_socket;
 pi_socket[1] = -1;
+p_sys->psz_unix_path = psz_unix_path;
 }
 #endif /* AF_LOCAL */
 #endif /* !_WIN32 */
@@ -873,7 +889,7 @@ static int Activate( vlc_object_t *p_this )
 if( asprintf( _backward_compat_host, "//%s", psz_host ) < 0 )
 {
 free( psz_host );
-return VLC_EGENERIC;
+goto error;
 }
 free( psz_host );
 psz_host = psz_backward_compat_host;
@@ -889,34 +905,19 @@ static int Activate( vlc_object_t *p_this )
   url.psz_host, url.i_port );
 vlc_UrlClean(  );
 free( psz_host );
-return VLC_EGENERIC;
+goto error;
 }
 
 vlc_UrlClean(  );
 free( psz_host );
 }
 
-intf_sys_t *p_sys = vlc_obj_malloc(p_this, sizeof (*p_sys));
-if( unlikely(p_sys == NULL) )
-{
-net_ListenClose( pi_socket );
-free( psz_unix_path );
-return VLC_ENOMEM;
-}
-
-p_intf->p_sys = p_sys;
-p_sys->commands = NULL;
 p_sys->pi_socket_listen = pi_socket;
 
-RegisterHandlers(p_intf, cmds, ARRAY_SIZE(cmds), p_intf);
-
 /* Line-buffered stdout */
 setvbuf( stdout, (char *)NULL, _IOLBF, 0 );
 
 #ifndef _WIN32
-vlc_mutex_init(_sys->clients_lock);
-vlc_list_init(_sys->clients);
-p_sys->psz_unix_path = ps

[vlc-commits] cli: use vlc_obj_malloc()

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 29 
12:56:58 2020 +0200| [f423edd0c73c5b6c23374693c2ebaff2543e6ec4] | committer: 
Rémi Denis-Courmont

cli: use vlc_obj_malloc()

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f423edd0c73c5b6c23374693c2ebaff2543e6ec4
---

 modules/control/cli/cli.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index 0196b26d57..0ce26c1a57 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -896,7 +896,7 @@ static int Activate( vlc_object_t *p_this )
 free( psz_host );
 }
 
-intf_sys_t *p_sys = malloc( sizeof( *p_sys ) );
+intf_sys_t *p_sys = vlc_obj_malloc(p_this, sizeof (*p_sys));
 if( unlikely(p_sys == NULL) )
 {
 net_ListenClose( pi_socket );
@@ -962,7 +962,6 @@ error:
 tdestroy(p_sys->commands, free);
 net_ListenClose( pi_socket );
 free( psz_unix_path );
-free( p_sys );
 return VLC_EGENERIC;
 }
 
@@ -1006,7 +1005,6 @@ static void Deactivate( vlc_object_t *p_this )
 net_Close(p_sys->i_socket);
 #endif
 }
-free( p_sys );
 }
 
 /*

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] cli: run each client in dedicated thread

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 29 
12:26:18 2020 +0200| [2a91ccf4374aa357398d203d03ed1099c6bb3810] | committer: 
Rémi Denis-Courmont

cli: run each client in dedicated thread

This adds support for multiple concurrent client, albeit only on the same
listener.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2a91ccf4374aa357398d203d03ed1099c6bb3810
---

 modules/control/cli/cli.c | 27 ++-
 modules/control/cli/cli.h |  1 +
 2 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index 6ed8df0ce3..e112f68d85 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -456,6 +456,12 @@ static struct cli_client *cli_client_new(intf_thread_t 
*intf, int fd,
 cl->fd = fd;
 cl->intf = intf;
 vlc_mutex_init(>output_lock);
+
+if (vlc_clone(>thread, cli_client_thread, cl, VLC_THREAD_PRIORITY_LOW))
+{
+free(cl);
+cl = NULL;
+}
 return cl;
 }
 
@@ -491,6 +497,9 @@ static struct cli_client *cli_client_new_std(intf_thread_t 
*intf)
 
 static void cli_client_delete(struct cli_client *cl)
 {
+vlc_cancel(cl->thread);
+vlc_join(cl->thread, NULL);
+
 if (cl->stream != stdin)
 fclose(cl->stream);
 free(cl);
@@ -501,10 +510,8 @@ static void *Run(void *data)
 intf_thread_t *intf = data;
 intf_sys_t *sys = intf->p_sys;
 
-for (;;)
+while (sys->pi_socket_listen != NULL)
 {
-while (vlc_list_is_empty(>clients))
-{
 assert(sys->pi_socket_listen != NULL);
 
 int fd = net_Accept(intf, sys->pi_socket_listen);
@@ -521,20 +528,6 @@ static void *Run(void *data)
 vlc_list_append(>node, >clients);
 vlc_mutex_unlock(>clients_lock);
 }
-}
-
-struct cli_client *cl = vlc_list_first_entry_or_null(>clients,
- struct cli_client,
- node);
-
-cli_client_thread(cl);
-vlc_mutex_lock(>clients_lock);
-vlc_list_remove(>node);
-vlc_mutex_unlock(>clients_lock);
-cli_client_delete(cl);
-
-if (sys->pi_socket_listen == NULL)
-break;
 }
 
 return NULL;
diff --git a/modules/control/cli/cli.h b/modules/control/cli/cli.h
index 6b6ae12e7e..162c8c23cd 100644
--- a/modules/control/cli/cli.h
+++ b/modules/control/cli/cli.h
@@ -33,6 +33,7 @@ struct cli_client
 int fd;
 vlc_mutex_t output_lock;
 struct vlc_list node;
+vlc_thread_t thread;
 #endif
 };
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] cli: reindent

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 29 
12:35:12 2020 +0200| [673f99d25c135c68f515a13d605b3c8966e29d10] | committer: 
Rémi Denis-Courmont

cli: reindent

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=673f99d25c135c68f515a13d605b3c8966e29d10
---

 modules/control/cli/cli.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index e112f68d85..5c10cd9ce4 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -512,22 +512,22 @@ static void *Run(void *data)
 
 while (sys->pi_socket_listen != NULL)
 {
-assert(sys->pi_socket_listen != NULL);
+assert(sys->pi_socket_listen != NULL);
 
-int fd = net_Accept(intf, sys->pi_socket_listen);
-if (fd == -1)
-continue;
+int fd = net_Accept(intf, sys->pi_socket_listen);
+if (fd == -1)
+continue;
 
-int canc = vlc_savecancel();
-struct cli_client *cl = cli_client_new_fd(intf, fd);
-vlc_restorecancel(canc);
+int canc = vlc_savecancel();
+struct cli_client *cl = cli_client_new_fd(intf, fd);
+vlc_restorecancel(canc);
 
-if (cl != NULL)
-{
-vlc_mutex_lock(>clients_lock);
-vlc_list_append(>node, >clients);
-vlc_mutex_unlock(>clients_lock);
-}
+if (cl != NULL)
+{
+vlc_mutex_lock(>clients_lock);
+vlc_list_append(>node, >clients);
+vlc_mutex_unlock(>clients_lock);
+}
 }
 
 return NULL;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] cli: (de)allocate client dynamically

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 29 
12:18:27 2020 +0200| [ccf0ba539b3f1ea7e1e2735edd73fe0003abfdff] | committer: 
Rémi Denis-Courmont

cli: (de)allocate client dynamically

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ccf0ba539b3f1ea7e1e2735edd73fe0003abfdff
---

 modules/control/cli/cli.c | 102 +-
 1 file changed, 74 insertions(+), 28 deletions(-)

diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index f2c4a982c3..6ed8df0ce3 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -72,7 +72,6 @@ struct intf_sys_t
 #ifndef _WIN32
 vlc_mutex_t clients_lock;
 struct vlc_list clients;
-struct cli_client client;
 char *psz_unix_path;
 #else
 HANDLE hConsoleIn;
@@ -446,6 +445,57 @@ static void *cli_client_thread(void *data)
 return NULL;
 }
 
+static struct cli_client *cli_client_new(intf_thread_t *intf, int fd,
+ FILE *stream)
+{
+struct cli_client *cl = malloc(sizeof (*cl));
+if (unlikely(cl == NULL))
+return NULL;
+
+cl->stream = stream;
+cl->fd = fd;
+cl->intf = intf;
+vlc_mutex_init(>output_lock);
+return cl;
+}
+
+/**
+ * Creates a client from a file descriptor.
+ *
+ * This works with (pseudo-)terminals, stream sockets, serial ports, etc.
+ */
+static struct cli_client *cli_client_new_fd(intf_thread_t *intf, int fd)
+{
+fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_NONBLOCK);
+
+FILE *stream = fdopen(fd, "r");
+if (stream == NULL)
+{
+vlc_close(fd);
+return NULL;
+}
+
+struct cli_client *cl = cli_client_new(intf, fd, stream);
+if (unlikely(cl == NULL))
+fclose(stream);
+return cl;
+}
+
+/**
+ * Creates a client from the standard input and output.
+ */
+static struct cli_client *cli_client_new_std(intf_thread_t *intf)
+{
+return cli_client_new(intf, 1, stdin);
+}
+
+static void cli_client_delete(struct cli_client *cl)
+{
+if (cl->stream != stdin)
+fclose(cl->stream);
+free(cl);
+}
+
 static void *Run(void *data)
 {
 intf_thread_t *intf = data;
@@ -453,8 +503,6 @@ static void *Run(void *data)
 
 for (;;)
 {
-struct cli_client *cl = >client;
-
 while (vlc_list_is_empty(>clients))
 {
 assert(sys->pi_socket_listen != NULL);
@@ -464,27 +512,26 @@ static void *Run(void *data)
 continue;
 
 int canc = vlc_savecancel();
+struct cli_client *cl = cli_client_new_fd(intf, fd);
+vlc_restorecancel(canc);
 
-fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_NONBLOCK);
-cl->stream = fdopen(fd, "r");
-if (cl->stream != NULL)
+if (cl != NULL)
 {
-cl->fd = fd;
-cl->intf = intf;
-vlc_mutex_init(>output_lock);
 vlc_mutex_lock(>clients_lock);
 vlc_list_append(>node, >clients);
 vlc_mutex_unlock(>clients_lock);
 }
-else
-vlc_close(fd);
-vlc_restorecancel(canc);
 }
 
+struct cli_client *cl = vlc_list_first_entry_or_null(>clients,
+ struct cli_client,
+ node);
+
 cli_client_thread(cl);
 vlc_mutex_lock(>clients_lock);
 vlc_list_remove(>node);
 vlc_mutex_unlock(>clients_lock);
+cli_client_delete(cl);
 
 if (sys->pi_socket_listen == NULL)
 break;
@@ -738,6 +785,7 @@ static void *Run( void *data )
 static int Activate( vlc_object_t *p_this )
 {
 intf_thread_t *p_intf = (intf_thread_t*)p_this;
+struct cli_client *cl;
 char *psz_host, *psz_unix_path = NULL;
 int  *pi_socket = NULL;
 
@@ -896,21 +944,13 @@ static int Activate( vlc_object_t *p_this )
 RegisterPlaylist(p_intf);
 
 #ifndef _WIN32
-struct cli_client *cl = _sys->client;
-
 if (pi_socket == NULL)
 {
-cl->stream = stdin;
-cl->fd = 1;
-cl->intf = p_intf;
-vlc_mutex_init(>output_lock);
+cl = cli_client_new_std(p_intf);
+if (cl == NULL)
+goto error;
 vlc_list_append(>node, _sys->clients);
 }
-else
-{
-cl->stream = NULL;
-cl->fd = -1;
-}
 #endif
 
 if( vlc_clone( _sys->thread, Run, p_intf, VLC_THREAD_PRIORITY_LOW ) )
@@ -924,6 +964,10 @@ static int Activate( vlc_object_t *p_this )
 error:
 if (p_sys->player_cli != NULL)
 DeregisterPlayer(p_intf, p_sys->player_cli);
+#ifndef _WIN32
+vlc_list_foreach (cl, _sys->clients, node)
+cli_client_delete(cl);
+#endif
 tdestroy(p_sys->commands, free);
 net_ListenClose( 

[vlc-commits] cli: share logout() code between socket and console

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 29 
11:46:06 2020 +0200| [46cffefcf270d24c24c832fa70fcb64637f8acbf] | committer: 
Rémi Denis-Courmont

cli: share logout() code between socket and console

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=46cffefcf270d24c24c832fa70fcb64637f8acbf
---

 modules/control/cli/cli.c | 54 ++-
 1 file changed, 25 insertions(+), 29 deletions(-)

diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index b66a860116..f2c4a982c3 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -213,33 +213,33 @@ static int Quit(struct cli_client *cl, const char *const 
*args, size_t count,
 static int LogOut(struct cli_client *cl, const char *const *args, size_t count,
   void *data)
 {
-intf_thread_t *intf = data;
-intf_sys_t *sys = intf->p_sys;
-
 /* Close connection */
 #ifndef _WIN32
-if (sys->pi_socket_listen != NULL)
-{
-vlc_mutex_lock(>output_lock);
-cl->fd = -1;
-vlc_mutex_unlock(>output_lock);
-fclose(cl->stream);
-cl->stream = NULL;
-}
-else
-{   /* Force end-of-file on the standard input. */
-int fd = vlc_open("/dev/null", O_RDONLY);
-if (fd != -1)
-{   /* POSIX requires flushing before, and seeking after, replacing a
- * file descriptor underneath an I/O stream.
- */
-fflush(cl->stream);
-dup2(fd, 0 /* fileno(sys->stream) */);
-fseek(cl->stream, 0, SEEK_SET);
-vlc_close(fd);
-}
+/* Force end-of-file on the file descriptor. */
+int fd = vlc_open("/dev/null", O_RDONLY);
+if (fd != -1)
+{   /* POSIX requires flushing before, and seeking after, replacing a
+ * file descriptor underneath an I/O stream.
+ */
+int fd2 = fileno(cl->stream);
+
+fflush(cl->stream);
+if (fd2 != 1)
+#ifdef HAVE_DUP3
+dup3(fd, fd2, O_CLOEXEC);
+#else
+dup2(fd, fd2), fcntl(fd2, F_SETFD, FD_CLOEXEC);
+#endif
+else
+dup2(fd, fd2);
+fseek(cl->stream, 0, SEEK_SET);
+vlc_close(fd);
 }
+(void) data;
 #else
+intf_thread_t *intf = data;
+intf_sys_t *sys = intf->p_sys;
+
 if (sys->i_socket != -1)
 {
 net_Close(sys->i_socket);
@@ -425,14 +425,10 @@ static void *cli_client_thread(void *data)
 {
 struct cli_client *cl = data;
 intf_thread_t *intf = cl->intf;
+char cmd[MAX_LINE_LENGTH + 1];
 
-while (cl->stream != NULL)
+while (fgets(cmd, sizeof (cmd), cl->stream) != NULL)
 {
-char cmd[MAX_LINE_LENGTH + 1];
-
-if (fgets(cmd, sizeof (cmd), cl->stream) == NULL)
-break;
-
 int canc = vlc_savecancel();
 if (cmd[0] != '\0')
 cmd[strlen(cmd) - 1] = '\0'; /* remove trailing LF */

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] configure: check for dup3()

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 29 
11:31:55 2020 +0200| [375ab38fe00b959274845dc969b9693e4160047a] | committer: 
Rémi Denis-Courmont

configure: check for dup3()

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=375ab38fe00b959274845dc969b9693e4160047a
---

 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index a0b153664c..e67bb7e296 100644
--- a/configure.ac
+++ b/configure.ac
@@ -695,7 +695,7 @@ dnl Check for system libs needed
 need_libc=false
 
 dnl Check for usual libc functions
-AC_CHECK_FUNCS([accept4 fcntl flock fstatat fstatvfs fork getmntent_r getenv 
getpwuid_r isatty memalign mkostemp mmap open_memstream newlocale pipe2 pread 
posix_fadvise posix_madvise setlocale stricmp strnicmp strptime uselocale 
wordexp])
+AC_CHECK_FUNCS([accept4 dup3 fcntl flock fstatat fstatvfs fork getmntent_r 
getenv getpwuid_r isatty memalign mkostemp mmap open_memstream newlocale pipe2 
pread posix_fadvise posix_madvise setlocale stricmp strnicmp strptime uselocale 
wordexp])
 AC_REPLACE_FUNCS([aligned_alloc atof atoll dirfd fdopendir flockfile fsync 
getdelim getpid lfind lldiv memrchr nrand48 poll posix_memalign recvmsg rewind 
sendmsg setenv strcasecmp strcasestr strdup strlcpy strndup strnlen strnstr 
strsep strtof strtok_r strtoll swab tdestroy tfind timegm timespec_get 
strverscmp pathconf])
 AC_REPLACE_FUNCS([gettimeofday])
 AC_CHECK_FUNC(fdatasync,,

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] cli: add a list of clients

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 29 
10:47:12 2020 +0200| [5b663927c28ac5e605836474c002b4e3b913c015] | committer: 
Rémi Denis-Courmont

cli: add a list of clients

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5b663927c28ac5e605836474c002b4e3b913c015
---

 modules/control/cli/cli.c | 56 ++-
 modules/control/cli/cli.h |  2 ++
 2 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index d8237423e3..b66a860116 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -70,6 +70,8 @@ struct intf_sys_t
 void *player_cli;
 
 #ifndef _WIN32
+vlc_mutex_t clients_lock;
+struct vlc_list clients;
 struct cli_client client;
 char *psz_unix_path;
 #else
@@ -399,11 +401,15 @@ int cli_printf(struct cli_client *cl, const char *fmt, 
...)
 return len;
 }
 
-static void msg_vprint(intf_thread_t *p_intf, const char *psz_fmt, va_list 
args)
+static void msg_vprint(intf_thread_t *p_intf, const char *fmt, va_list args)
 {
 intf_sys_t *sys = p_intf->p_sys;
+struct cli_client *cl;
 
-cli_vprintf(>client, psz_fmt, args);
+vlc_mutex_lock(>clients_lock);
+vlc_list_foreach (cl, >clients, node)
+cli_vprintf(cl, fmt, args);
+vlc_mutex_unlock(>clients_lock);
 }
 
 void msg_print(intf_thread_t *intf, const char *fmt, ...)
@@ -453,7 +459,7 @@ static void *Run(void *data)
 {
 struct cli_client *cl = >client;
 
-while (cl->stream == NULL)
+while (vlc_list_is_empty(>clients))
 {
 assert(sys->pi_socket_listen != NULL);
 
@@ -467,10 +473,12 @@ static void *Run(void *data)
 cl->stream = fdopen(fd, "r");
 if (cl->stream != NULL)
 {
-vlc_mutex_lock(>output_lock);
 cl->fd = fd;
-vlc_mutex_unlock(>output_lock);
 cl->intf = intf;
+vlc_mutex_init(>output_lock);
+vlc_mutex_lock(>clients_lock);
+vlc_list_append(>node, >clients);
+vlc_mutex_unlock(>clients_lock);
 }
 else
 vlc_close(fd);
@@ -478,6 +486,9 @@ static void *Run(void *data)
 }
 
 cli_client_thread(cl);
+vlc_mutex_lock(>clients_lock);
+vlc_list_remove(>node);
+vlc_mutex_unlock(>clients_lock);
 
 if (sys->pi_socket_listen == NULL)
 break;
@@ -868,21 +879,8 @@ static int Activate( vlc_object_t *p_this )
 setvbuf( stdout, (char *)NULL, _IOLBF, 0 );
 
 #ifndef _WIN32
-struct cli_client *cl = _sys->client;
-
-vlc_mutex_init(>output_lock);
-
-if (pi_socket == NULL)
-{
-cl->stream = stdin;
-cl->fd = 1;
-cl->intf = p_intf;
-}
-else
-{
-cl->stream = NULL;
-cl->fd = -1;
-}
+vlc_mutex_init(_sys->clients_lock);
+vlc_list_init(_sys->clients);
 p_sys->psz_unix_path = psz_unix_path;
 #else
 p_sys->i_socket = -1;
@@ -901,6 +899,24 @@ static int Activate( vlc_object_t *p_this )
 
 RegisterPlaylist(p_intf);
 
+#ifndef _WIN32
+struct cli_client *cl = _sys->client;
+
+if (pi_socket == NULL)
+{
+cl->stream = stdin;
+cl->fd = 1;
+cl->intf = p_intf;
+vlc_mutex_init(>output_lock);
+vlc_list_append(>node, _sys->clients);
+}
+else
+{
+cl->stream = NULL;
+cl->fd = -1;
+}
+#endif
+
 if( vlc_clone( _sys->thread, Run, p_intf, VLC_THREAD_PRIORITY_LOW ) )
 goto error;
 
diff --git a/modules/control/cli/cli.h b/modules/control/cli/cli.h
index 0f884f645e..6b6ae12e7e 100644
--- a/modules/control/cli/cli.h
+++ b/modules/control/cli/cli.h
@@ -23,6 +23,7 @@
 
 #include 
 #include 
+#include 
 
 struct cli_client
 {
@@ -31,6 +32,7 @@ struct cli_client
 FILE *stream;
 int fd;
 vlc_mutex_t output_lock;
+struct vlc_list node;
 #endif
 };
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] cli: add per-client thread function

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sat Nov 28 
21:09:56 2020 +0200| [aa00154c369853285b7cb878e7c2b119d9998a35] | committer: 
Rémi Denis-Courmont

cli: add per-client thread function

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=aa00154c369853285b7cb878e7c2b119d9998a35
---

 modules/control/cli/cli.c | 48 +++
 1 file changed, 32 insertions(+), 16 deletions(-)

diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index f1cc53a9a1..d8237423e3 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -415,6 +415,35 @@ void msg_print(intf_thread_t *intf, const char *fmt, ...)
 va_end(ap);
 }
 
+static void *cli_client_thread(void *data)
+{
+struct cli_client *cl = data;
+intf_thread_t *intf = cl->intf;
+
+while (cl->stream != NULL)
+{
+char cmd[MAX_LINE_LENGTH + 1];
+
+if (fgets(cmd, sizeof (cmd), cl->stream) == NULL)
+break;
+
+int canc = vlc_savecancel();
+if (cmd[0] != '\0')
+cmd[strlen(cmd) - 1] = '\0'; /* remove trailing LF */
+Process(intf, cl, cmd);
+vlc_restorecancel(canc);
+}
+
+if (cl->stream == stdin)
+{
+int canc = vlc_savecancel();
+libvlc_Quit(vlc_object_instance(intf));
+vlc_restorecancel(canc);
+}
+
+return NULL;
+}
+
 static void *Run(void *data)
 {
 intf_thread_t *intf = data;
@@ -422,7 +451,6 @@ static void *Run(void *data)
 
 for (;;)
 {
-char buf[MAX_LINE_LENGTH + 1];
 struct cli_client *cl = >client;
 
 while (cl->stream == NULL)
@@ -449,24 +477,12 @@ static void *Run(void *data)
 vlc_restorecancel(canc);
 }
 
-char *cmd = fgets(buf, sizeof (buf), cl->stream);
-if (cmd != NULL)
-{
-int canc = vlc_savecancel();
-if (cmd[0] != '\0')
-cmd[strlen(cmd) - 1] = '\0'; /* remove trailing LF */
-Process(intf, cl, cmd);
-vlc_restorecancel(canc);
-}
-else if (sys->pi_socket_listen == NULL)
+cli_client_thread(cl);
+
+if (sys->pi_socket_listen == NULL)
 break;
-else
-LogOut(cl, NULL, 0, intf);
 }
 
-int canc = vlc_savecancel();
-libvlc_Quit(vlc_object_instance(intf));
-vlc_restorecancel(canc);
 return NULL;
 }
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] cli: move I/O properties to client structure

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sun Nov 29 
10:26:57 2020 +0200| [d141d10ab946dee58e8d1887db819619cabd689b] | committer: 
Rémi Denis-Courmont

cli: move I/O properties to client structure

This moves the output lock, output file descriptor and input stream to
the client structure.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d141d10ab946dee58e8d1887db819619cabd689b
---

 modules/control/cli/cli.c | 110 +++---
 modules/control/cli/cli.h |   5 +++
 2 files changed, 70 insertions(+), 45 deletions(-)

diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index 4132af9813..f1cc53a9a1 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -69,10 +69,8 @@ struct intf_sys_t
 void *commands;
 void *player_cli;
 
-vlc_mutex_t output_lock;
 #ifndef _WIN32
-FILE *stream;
-int fd;
+struct cli_client client;
 char *psz_unix_path;
 #else
 HANDLE hConsoleIn;
@@ -220,11 +218,11 @@ static int LogOut(struct cli_client *cl, const char 
*const *args, size_t count,
 #ifndef _WIN32
 if (sys->pi_socket_listen != NULL)
 {
-vlc_mutex_lock(>output_lock);
-sys->fd = -1;
-vlc_mutex_unlock(>output_lock);
-fclose(sys->stream);
-sys->stream = NULL;
+vlc_mutex_lock(>output_lock);
+cl->fd = -1;
+vlc_mutex_unlock(>output_lock);
+fclose(cl->stream);
+cl->stream = NULL;
 }
 else
 {   /* Force end-of-file on the standard input. */
@@ -233,9 +231,9 @@ static int LogOut(struct cli_client *cl, const char *const 
*args, size_t count,
 {   /* POSIX requires flushing before, and seeking after, replacing a
  * file descriptor underneath an I/O stream.
  */
-fflush(sys->stream);
+fflush(cl->stream);
 dup2(fd, 0 /* fileno(sys->stream) */);
-fseek(sys->stream, 0, SEEK_SET);
+fseek(cl->stream, 0, SEEK_SET);
 vlc_close(fd);
 }
 }
@@ -360,46 +358,61 @@ error:  wordfree();
 }
 
 #ifndef _WIN32
-static void msg_vprint(intf_thread_t *p_intf, const char *psz_fmt, va_list 
args)
+static ssize_t cli_writev(struct cli_client *cl,
+  const struct iovec *iov, unsigned iovlen)
 {
-intf_sys_t *sys = p_intf->p_sys;
-int fd;
+ssize_t val;
 
-vlc_mutex_lock(>output_lock);
-fd = sys->fd;
-if (fd != -1)
-{
-char *msg;
-int len = vasprintf(, psz_fmt, args);
+vlc_mutex_lock(>output_lock);
+if (cl->fd != -1)
+val = vlc_writev(cl->fd, iov, iovlen);
+else
+errno = EPIPE, val = -1;
+vlc_mutex_unlock(>output_lock);
+return val;
+}
 
-if (unlikely(len < 0))
-return;
+static int cli_vprintf(struct cli_client *cl, const char *fmt, va_list args)
+{
+char *msg;
+int len = vasprintf(, fmt, args);
 
+if (likely(len >= 0))
+{
 struct iovec iov[2] = { { msg, len }, { (char *)"\n", 1 } };
 
-vlc_writev(sys->fd, iov, ARRAY_SIZE(iov));
+cli_writev(cl, iov, ARRAY_SIZE(iov));
+len++;
 free(msg);
 }
-vlc_mutex_unlock(>output_lock);
+return len;
 }
 
-void msg_print(intf_thread_t *intf, const char *fmt, ...)
+int cli_printf(struct cli_client *cl, const char *fmt, ...)
 {
 va_list ap;
+int len;
 
 va_start(ap, fmt);
-msg_vprint(intf, fmt, ap);
+len = cli_vprintf(cl, fmt, ap);
 va_end(ap);
+return len;
 }
 
-int cli_printf(struct cli_client *cl, const char *fmt, ...)
+static void msg_vprint(intf_thread_t *p_intf, const char *psz_fmt, va_list 
args)
+{
+intf_sys_t *sys = p_intf->p_sys;
+
+cli_vprintf(>client, psz_fmt, args);
+}
+
+void msg_print(intf_thread_t *intf, const char *fmt, ...)
 {
 va_list ap;
 
 va_start(ap, fmt);
-msg_vprint(cl->intf, fmt, ap);
+msg_vprint(intf, fmt, ap);
 va_end(ap);
-return VLC_SUCCESS;
 }
 
 static void *Run(void *data)
@@ -410,9 +423,9 @@ static void *Run(void *data)
 for (;;)
 {
 char buf[MAX_LINE_LENGTH + 1];
-struct cli_client cl = { intf };
+struct cli_client *cl = >client;
 
-while (sys->stream == NULL)
+while (cl->stream == NULL)
 {
 assert(sys->pi_socket_listen != NULL);
 
@@ -423,31 +436,32 @@ static void *Run(void *data)
 int canc = vlc_savecancel();
 
 fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_NONBLOCK);
-sys->stream = fdopen(fd, "r");
-if (sys->stream != NULL)
+cl->stream = fdopen(fd, "r");
+if (cl->stream != NULL)
 {
-vlc_mutex_lock(>output_lock);
-sys->fd = fd;
-vlc_mutex_unlock(>output_lock)

[vlc-commits] cli: move code

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sat Nov 28 
22:01:34 2020 +0200| [d7e55370f8f09a76ace37bb5b098b616b4570d93] | committer: 
Rémi Denis-Courmont

cli: move code

No functional changes.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d7e55370f8f09a76ace37bb5b098b616b4570d93
---

 modules/control/cli/cli.c | 140 ++
 1 file changed, 80 insertions(+), 60 deletions(-)

diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index a5f220697a..4132af9813 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -84,66 +84,6 @@ struct intf_sys_t
 
 #define MAX_LINE_LENGTH 1024
 
-static void msg_vprint(intf_thread_t *p_intf, const char *psz_fmt, va_list 
args)
-{
-#ifndef _WIN32
-intf_sys_t *sys = p_intf->p_sys;
-int fd;
-
-vlc_mutex_lock(>output_lock);
-fd = sys->fd;
-if (fd != -1)
-{
-char *msg;
-int len = vasprintf(, psz_fmt, args);
-
-if (unlikely(len < 0))
-return;
-
-struct iovec iov[2] = { { msg, len }, { (char *)"\n", 1 } };
-
-vlc_writev(sys->fd, iov, ARRAY_SIZE(iov));
-free(msg);
-}
-vlc_mutex_unlock(>output_lock);
-#else
-char fmt_eol[strlen (psz_fmt) + 3], *msg;
-int len;
-
-snprintf (fmt_eol, sizeof (fmt_eol), "%s\r\n", psz_fmt);
-len = vasprintf( , fmt_eol, args );
-
-if( len < 0 )
-return;
-
-if( p_intf->p_sys->i_socket == -1 )
-utf8_fprintf( stdout, "%s", msg );
-else
-net_Write( p_intf, p_intf->p_sys->i_socket, msg, len );
-
-free( msg );
-#endif
-}
-
-void msg_print(intf_thread_t *intf, const char *fmt, ...)
-{
-va_list ap;
-
-va_start(ap, fmt);
-msg_vprint(intf, fmt, ap);
-va_end(ap);
-}
-
-int cli_printf(struct cli_client *cl, const char *fmt, ...)
-{
-va_list ap;
-
-va_start(ap, fmt);
-msg_vprint(cl->intf, fmt, ap);
-va_end(ap);
-return VLC_SUCCESS;
-}
-
 struct command {
 union {
 const char *name;
@@ -420,6 +360,48 @@ error:  wordfree();
 }
 
 #ifndef _WIN32
+static void msg_vprint(intf_thread_t *p_intf, const char *psz_fmt, va_list 
args)
+{
+intf_sys_t *sys = p_intf->p_sys;
+int fd;
+
+vlc_mutex_lock(>output_lock);
+fd = sys->fd;
+if (fd != -1)
+{
+char *msg;
+int len = vasprintf(, psz_fmt, args);
+
+if (unlikely(len < 0))
+return;
+
+struct iovec iov[2] = { { msg, len }, { (char *)"\n", 1 } };
+
+vlc_writev(sys->fd, iov, ARRAY_SIZE(iov));
+free(msg);
+}
+vlc_mutex_unlock(>output_lock);
+}
+
+void msg_print(intf_thread_t *intf, const char *fmt, ...)
+{
+va_list ap;
+
+va_start(ap, fmt);
+msg_vprint(intf, fmt, ap);
+va_end(ap);
+}
+
+int cli_printf(struct cli_client *cl, const char *fmt, ...)
+{
+va_list ap;
+
+va_start(ap, fmt);
+msg_vprint(cl->intf, fmt, ap);
+va_end(ap);
+return VLC_SUCCESS;
+}
+
 static void *Run(void *data)
 {
 intf_thread_t *intf = data;
@@ -475,6 +457,44 @@ static void *Run(void *data)
 }
 
 #else
+static void msg_vprint(intf_thread_t *p_intf, const char *psz_fmt, va_list 
args)
+{
+char fmt_eol[strlen (psz_fmt) + 3], *msg;
+int len;
+
+snprintf (fmt_eol, sizeof (fmt_eol), "%s\r\n", psz_fmt);
+len = vasprintf( , fmt_eol, args );
+
+if( len < 0 )
+return;
+
+if( p_intf->p_sys->i_socket == -1 )
+utf8_fprintf( stdout, "%s", msg );
+else
+net_Write( p_intf, p_intf->p_sys->i_socket, msg, len );
+
+free( msg );
+}
+
+void msg_print(intf_thread_t *intf, const char *fmt, ...)
+{
+va_list ap;
+
+va_start(ap, fmt);
+msg_vprint(intf, fmt, ap);
+va_end(ap);
+}
+
+int cli_printf(struct cli_client *cl, const char *fmt, ...)
+{
+va_list ap;
+
+va_start(ap, fmt);
+msg_vprint(cl->intf, fmt, ap);
+va_end(ap);
+return VLC_SUCCESS;
+}
+
 #if !VLC_WINSTORE_APP
 static bool ReadWin32( intf_thread_t *p_intf, unsigned char *p_buffer, int 
*pi_size )
 {

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] cli: privatise intf_sys_t

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sat Nov 28 
21:50:26 2020 +0200| [8d4f5a11622a302ccde27b81b14ff4bf4aa25816] | committer: 
Rémi Denis-Courmont

cli: privatise intf_sys_t

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8d4f5a11622a302ccde27b81b14ff4bf4aa25816
---

 modules/control/cli/cli.c | 19 +++
 modules/control/cli/cli.h | 19 ---
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index 8bbcc30807..a5f220697a 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -63,6 +63,25 @@
 
 #include "cli.h"
 
+struct intf_sys_t
+{
+vlc_thread_t thread;
+void *commands;
+void *player_cli;
+
+vlc_mutex_t output_lock;
+#ifndef _WIN32
+FILE *stream;
+int fd;
+char *psz_unix_path;
+#else
+HANDLE hConsoleIn;
+bool b_quiet;
+int i_socket;
+#endif
+int *pi_socket_listen;
+};
+
 #define MAX_LINE_LENGTH 1024
 
 static void msg_vprint(intf_thread_t *p_intf, const char *psz_fmt, va_list 
args)
diff --git a/modules/control/cli/cli.h b/modules/control/cli/cli.h
index 69ac092b8f..a553f93abf 100644
--- a/modules/control/cli/cli.h
+++ b/modules/control/cli/cli.h
@@ -29,25 +29,6 @@ struct cli_client
 intf_thread_t *intf;
 };
 
-struct intf_sys_t
-{
-vlc_thread_t thread;
-void *commands;
-void *player_cli;
-
-vlc_mutex_t output_lock;
-#ifndef _WIN32
-FILE *stream;
-int fd;
-char *psz_unix_path;
-#else
-HANDLE hConsoleIn;
-bool b_quiet;
-int i_socket;
-#endif
-int *pi_socket_listen;
-};
-
 VLC_FORMAT(2, 3)
 int cli_printf(struct cli_client *cl, const char *fmt, ...);
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] cli: separate client and interface structures

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sat Nov 28 
20:49:50 2020 +0200| [83bdc9cc1b45fdb7c07ad85ba3cfbdb25224f2ef] | committer: 
Rémi Denis-Courmont

cli: separate client and interface structures

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=83bdc9cc1b45fdb7c07ad85ba3cfbdb25224f2ef
---

 modules/control/cli/cli.c  |  60 +++---
 modules/control/cli/cli.h  |  12 +-
 modules/control/cli/player.c   | 263 -
 modules/control/cli/playlist.c |  92 +++---
 4 files changed, 226 insertions(+), 201 deletions(-)

diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index 5fc50229e6..8bbcc30807 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -115,6 +115,16 @@ void msg_print(intf_thread_t *intf, const char *fmt, ...)
 va_end(ap);
 }
 
+int cli_printf(struct cli_client *cl, const char *fmt, ...)
+{
+va_list ap;
+
+va_start(ap, fmt);
+msg_vprint(cl->intf, fmt, ap);
+va_end(ap);
+return VLC_SUCCESS;
+}
+
 struct command {
 union {
 const char *name;
@@ -156,11 +166,7 @@ void RegisterHandlers(intf_thread_t *intf, const struct 
cli_handler *handlers,
 }
 }
 
-#if defined (_WIN32) && !VLC_WINSTORE_APP
-# include "../intromsg.h"
-#endif
-
-static int Help(intf_thread_t *p_intf, const char *const *args, size_t count,
+static int Help(struct cli_client *cl, const char *const *args, size_t count,
 void *data)
 {
 msg_rc("%s", _("+[ Remote control commands ]"));
@@ -225,23 +231,30 @@ static int Help(intf_thread_t *p_intf, const char *const 
*args, size_t count,
 return 0;
 }
 
-static int Intf(intf_thread_t *intf, const char *const *args, size_t count,
+static int Intf(struct cli_client *cl, const char *const *args, size_t count,
 void *data)
 {
+intf_thread_t *intf = data;
+
+(void) cl;
+
 return intf_Create(vlc_object_instance(intf), count == 1 ? "" : args[1]);
 }
 
-static int Quit(intf_thread_t *intf, const char *const *args, size_t count,
+static int Quit(struct cli_client *cl, const char *const *args, size_t count,
 void *data)
 {
+intf_thread_t *intf = data;
+
 libvlc_Quit(vlc_object_instance(intf));
-(void) args; (void) count;
+(void) cl; (void) args; (void) count;
 return 0;
 }
 
-static int LogOut(intf_thread_t *intf, const char *const *args, size_t count,
+static int LogOut(struct cli_client *cl, const char *const *args, size_t count,
   void *data)
 {
+intf_thread_t *intf = data;
 intf_sys_t *sys = intf->p_sys;
 
 /* Close connection */
@@ -278,15 +291,17 @@ static int LogOut(intf_thread_t *intf, const char *const 
*args, size_t count,
 return 0;
 }
 
-static int KeyAction(intf_thread_t *intf, const char *const *args, size_t n,
+static int KeyAction(struct cli_client *cl, const char *const *args, size_t n,
  void *data)
 {
+intf_thread_t *intf = data;
 vlc_object_t *vlc = VLC_OBJECT(vlc_object_instance(intf));
 
 if (n != 2)
 return VLC_EGENERIC; /* EINVAL */
 
 var_SetInteger(vlc, "key-action", vlc_actions_get_id(args[1]));
+(void) cl;
 return 0;
 }
 
@@ -305,7 +320,7 @@ static const struct cli_handler cmds[] =
 { "hotkey", KeyAction },
 };
 
-static int Process(intf_thread_t *intf, const char *line)
+static int Process(intf_thread_t *intf, struct cli_client *cl, const char 
*line)
 {
 intf_sys_t *sys = intf->p_sys;
 /* Skip heading spaces */
@@ -329,7 +344,7 @@ error:  wordfree();
 else
 ret = VLC_EGENERIC;
 
-msg_print(intf, N_("parse error"));
+cli_printf(cl, N_("parse error"));
 return ret;
 }
 
@@ -368,12 +383,11 @@ error:  wordfree();
 {
 const struct command *c = *pp;;
 
-ret = c->handler.callback(intf, args, count, c->data);
+ret = c->handler.callback(cl, args, count, c->data);
 }
 else
 {
-msg_print(intf,
-  _("Unknown command `%s'. Type `help' for help."),
+cli_printf(cl, _("Unknown command `%s'. Type `help' for help."),
   args[0]);
 ret = VLC_EGENERIC;
 }
@@ -395,6 +409,7 @@ static void *Run(void *data)
 for (;;)
 {
 char buf[MAX_LINE_LENGTH + 1];
+struct cli_client cl = { intf };
 
 while (sys->stream == NULL)
 {
@@ -425,13 +440,13 @@ static void *Run(void *data)
 int canc = vlc_savecancel();
 if (cmd[0] != '\0')
 cmd[strlen(cmd) - 1] = '\0'; /* remove trailing LF */
-Process(intf, cmd);
+Process(intf, , cmd);
 vlc_restorecancel(canc);
 }
 else if (sys->pi_socket_listen == NULL)
 br

[vlc-commits] cli: remove write-only intf_sys_t.playlist

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sat Nov 28 
16:29:30 2020 +0200| [1485f118975d0f156b27b4a04a65b42ee3b1fcbd] | committer: 
Rémi Denis-Courmont

cli: remove write-only intf_sys_t.playlist

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1485f118975d0f156b27b4a04a65b42ee3b1fcbd
---

 modules/control/cli/cli.c| 1 -
 modules/control/cli/cli.h| 4 
 modules/control/cli/player.c | 1 +
 3 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/modules/control/cli/cli.c b/modules/control/cli/cli.c
index dfab8127a7..5fc50229e6 100644
--- a/modules/control/cli/cli.c
+++ b/modules/control/cli/cli.c
@@ -772,7 +772,6 @@ static int Activate( vlc_object_t *p_this )
 p_sys->commands = NULL;
 vlc_mutex_init(_sys->output_lock);
 p_sys->pi_socket_listen = pi_socket;
-p_sys->playlist = vlc_intf_GetMainPlaylist(p_intf);;
 
 RegisterHandlers(p_intf, cmds, ARRAY_SIZE(cmds), p_intf);
 
diff --git a/modules/control/cli/cli.h b/modules/control/cli/cli.h
index 394396cc88..326cb74313 100644
--- a/modules/control/cli/cli.h
+++ b/modules/control/cli/cli.h
@@ -23,7 +23,6 @@
 
 #include 
 #include 
-#include 
 
 struct intf_sys_t
 {
@@ -31,9 +30,6 @@ struct intf_sys_t
 void *commands;
 void *player_cli;
 
-/* playlist */
-vlc_playlist_t  *playlist;
-
 vlc_mutex_t output_lock;
 #ifndef _WIN32
 FILE *stream;
diff --git a/modules/control/cli/player.c b/modules/control/cli/player.c
index e64b505d79..113465fa41 100644
--- a/modules/control/cli/player.c
+++ b/modules/control/cli/player.c
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "cli.h"

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] cli/playlist: use data pointer

2020-11-29 Thread Rémi Denis-Courmont
vlc | branch: master | Rémi Denis-Courmont  | Sat Nov 28 
16:27:50 2020 +0200| [ad51838dca484b55e57f36af4c58875f1e30] | committer: 
Rémi Denis-Courmont

cli/playlist: use data pointer

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ad51838dca484b55e57f36af4c58875f1e30
---

 modules/control/cli/playlist.c | 45 +++---
 1 file changed, 25 insertions(+), 20 deletions(-)

diff --git a/modules/control/cli/playlist.c b/modules/control/cli/playlist.c
index 3740a9798c..7db6b9ac5a 100644
--- a/modules/control/cli/playlist.c
+++ b/modules/control/cli/playlist.c
@@ -162,14 +162,16 @@ static void print_playlist(intf_thread_t *p_intf, 
vlc_playlist_t *playlist)
 }
 }
 
-static int PlaylistDoVoid(intf_thread_t *intf, int (*cb)(vlc_playlist_t *))
+static int PlaylistDoVoid(intf_thread_t *intf, void *data,
+  int (*cb)(vlc_playlist_t *))
 {
-vlc_playlist_t *playlist = intf->p_sys->playlist;
+vlc_playlist_t *playlist = data;
 int ret;
 
 vlc_playlist_Lock(playlist);
 ret = cb(playlist);
 vlc_playlist_Unlock(playlist);
+(void) intf;
 return ret;
 }
 
@@ -177,21 +179,21 @@ static int PlaylistPrev(intf_thread_t *intf, const char 
*const *args,
 size_t count, void *data)
 {
 (void) args; (void) count;
-return PlaylistDoVoid(intf, vlc_playlist_Prev);
+return PlaylistDoVoid(intf, data, vlc_playlist_Prev);
 }
 
 static int PlaylistNext(intf_thread_t *intf, const char *const *args,
 size_t count, void *data)
 {
 (void) args; (void) count;
-return PlaylistDoVoid(intf, vlc_playlist_Next);
+return PlaylistDoVoid(intf, data, vlc_playlist_Next);
 }
 
 static int PlaylistPlay(intf_thread_t *intf, const char *const *args,
 size_t count, void *data)
 {
 (void) args; (void) count;
-return PlaylistDoVoid(intf, vlc_playlist_Start);
+return PlaylistDoVoid(intf, data, vlc_playlist_Start);
 }
 
 static int PlaylistDoStop(vlc_playlist_t *playlist)
@@ -204,7 +206,7 @@ static int PlaylistStop(intf_thread_t *intf, const char 
*const *args,
 size_t count, void *data)
 {
 (void) args; (void) count;
-return PlaylistDoVoid(intf, PlaylistDoStop);
+return PlaylistDoVoid(intf, data, PlaylistDoStop);
 }
 
 static int PlaylistDoClear(vlc_playlist_t *playlist)
@@ -218,7 +220,7 @@ static int PlaylistClear(intf_thread_t *intf, const char 
*const *args,
  size_t count, void *data)
 {
 (void) args; (void) count;
-return PlaylistDoVoid(intf, PlaylistDoClear);
+return PlaylistDoVoid(intf, data, PlaylistDoClear);
 }
 
 static int PlaylistDoSort(vlc_playlist_t *playlist)
@@ -236,13 +238,13 @@ static int PlaylistSort(intf_thread_t *intf, const char 
*const *args,
 size_t count, void *data)
 {
 (void) args; (void) count;
-return PlaylistDoVoid(intf, PlaylistDoSort);
+return PlaylistDoVoid(intf, data, PlaylistDoSort);
 }
 
 static int PlaylistList(intf_thread_t *intf, const char *const *args,
 size_t count, void *data)
 {
-vlc_playlist_t *playlist = intf->p_sys->playlist;
+vlc_playlist_t *playlist = data;
 
 msg_print(intf, "+[ Playlist ]");
 vlc_playlist_Lock(playlist);
@@ -254,11 +256,11 @@ static int PlaylistList(intf_thread_t *intf, const char 
*const *args,
 }
 
 static int PlaylistRepeatCommon(intf_thread_t *intf, const char *const *args,
-size_t count,
+size_t count, void *data,
 enum vlc_playlist_playback_repeat on_mode)
 
 {
-vlc_playlist_t *playlist = intf->p_sys->playlist;
+vlc_playlist_t *playlist = data;
 
 vlc_playlist_Lock(playlist);
 
@@ -283,27 +285,28 @@ static int PlaylistRepeatCommon(intf_thread_t *intf, 
const char *const *args,
 vlc_playlist_SetPlaybackRepeat(playlist, new_mode);
 
 vlc_playlist_Unlock(playlist);
+(void) intf;
 return 0;
 }
 
 static int PlaylistRepeat(intf_thread_t *intf, const char *const *args,
   size_t count, void *data)
 {
-return PlaylistRepeatCommon(intf, args, count,
+return PlaylistRepeatCommon(intf, args, count, data,
 VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT);
 }
 
 static int PlaylistLoop(intf_thread_t *intf, const char *const *args,
 size_t count, void *data)
 {
-return PlaylistRepeatCommon(intf, args, count,
+return PlaylistRepeatCommon(intf, args, count, data,
 VLC_PLAYLIST_PLAYBACK_REPEAT_ALL);
 }
 
 static int PlaylistRandom(intf_thread_t *intf, const char *const *args,
   size_t count, void *data)
 {
-vlc_playlist_t *playlist = intf->p_sys->playlist;
+vlc_playlist_t *playlist = data;
 
 vlc_playlist_Lock(playlist

  1   2   3   4   5   6   7   8   9   10   >