[vlc-commits] vout: put subpictures on calling thread
Rémi Denis-Courmont
git at videolan.org
Mon Jan 28 21:38:01 CET 2019
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jan 27 16:26:20 2019 +0200| [ad7ab29f04edd63cb7ce08631d6afb83e24c2cf6] | committer: Rémi Denis-Courmont
vout: put subpictures on calling thread
There is a mixture of subpicture-related calls, with some running on
the calling thread, and others running on the video output thread
control loop.
The later may be delayed, depending on other video output thread
processing, sleeping and pending control requests. This leads to a
race condition, and potentially inconsistent ordering of calls on the
SPU instance.
This patch runs vout_SubPicture() directly on the calling thread and
adds a missing check for nonexistent/destroyed SPU.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ad7ab29f04edd63cb7ce08631d6afb83e24c2cf6
---
src/video_output/control.c | 4 ----
src/video_output/control.h | 2 --
src/video_output/video_output.c | 22 ++++++++--------------
3 files changed, 8 insertions(+), 20 deletions(-)
diff --git a/src/video_output/control.c b/src/video_output/control.c
index d93a4b0b17..cdc9529676 100644
--- a/src/video_output/control.c
+++ b/src/video_output/control.c
@@ -38,10 +38,6 @@ void vout_control_cmd_Init(vout_control_cmd_t *cmd, int type)
void vout_control_cmd_Clean(vout_control_cmd_t *cmd)
{
switch (cmd->type) {
- case VOUT_CONTROL_SUBPICTURE:
- if (cmd->subpicture)
- subpicture_Delete(cmd->subpicture);
- break;
case VOUT_CONTROL_CHANGE_FILTERS:
free(cmd->string);
break;
diff --git a/src/video_output/control.h b/src/video_output/control.h
index 8c05a43b1a..0bb2c2397b 100644
--- a/src/video_output/control.h
+++ b/src/video_output/control.h
@@ -34,7 +34,6 @@ enum {
VOUT_CONTROL_START,
VOUT_CONTROL_STOP,
#endif
- VOUT_CONTROL_SUBPICTURE, /* subpicture */
VOUT_CONTROL_FLUSH_SUBPICTURE, /* integer */
VOUT_CONTROL_CHANGE_FILTERS, /* string */
VOUT_CONTROL_CHANGE_INTERLACE, /* boolean */
@@ -75,7 +74,6 @@ typedef struct {
unsigned height;
} window;
vlc_mouse_t mouse;
- subpicture_t *subpicture;
vlc_viewpoint_t viewpoint;
};
} vout_control_cmd_t;
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index d154b53a95..2e3fad4559 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -246,12 +246,16 @@ void vout_MouseState(vout_thread_t *vout, const vlc_mouse_t *mouse)
void vout_PutSubpicture( vout_thread_t *vout, subpicture_t *subpic )
{
- vout_control_cmd_t cmd;
- vout_control_cmd_Init(&cmd, VOUT_CONTROL_SUBPICTURE);
- cmd.subpicture = subpic;
+ vout_thread_sys_t *sys = vout->p;
- vout_control_Push(&vout->p->control, &cmd);
+ vlc_mutex_lock(&sys->spu_lock);
+ if (sys->spu != NULL)
+ spu_PutSubpicture(sys->spu, subpic);
+ else
+ subpicture_Delete(subpic);
+ vlc_mutex_unlock(&sys->spu_lock);
}
+
int vout_RegisterSubpictureChannel( vout_thread_t *vout )
{
int channel = VOUT_SPU_CHANNEL_AVAIL_FIRST;
@@ -1181,12 +1185,6 @@ static int ThreadDisplayPicture(vout_thread_t *vout, vlc_tick_t *deadline)
return force_refresh ? VLC_EGENERIC : ret;
}
-static void ThreadDisplaySubpicture(vout_thread_t *vout,
- subpicture_t *subpicture)
-{
- spu_PutSubpicture(vout->p->spu, subpicture);
-}
-
static void ThreadFlushSubpicture(vout_thread_t *vout, int channel)
{
spu_ClearChannel(vout->p->spu, channel);
@@ -1480,10 +1478,6 @@ static int ThreadControl(vout_thread_t *vout, vout_control_cmd_t cmd)
case VOUT_CONTROL_CLEAN:
ThreadStop(vout);
return 1;
- case VOUT_CONTROL_SUBPICTURE:
- ThreadDisplaySubpicture(vout, cmd.subpicture);
- cmd.subpicture = NULL;
- break;
case VOUT_CONTROL_FLUSH_SUBPICTURE:
ThreadFlushSubpicture(vout, cmd.integer);
break;
More information about the vlc-commits
mailing list