[vlc-devel] [RFC PATCH 2/6] vout: fix vout_IsEmpty
Thomas Guillem
thomas at gllm.fr
Thu Mar 16 16:43:21 CET 2017
This function now returns true when the last picture is displayed.
---
src/video_output/video_output.c | 26 +++++++++++++++++++++-----
src/video_output/vout_internal.h | 2 ++
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 155d6a9e30..3d47b3827e 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -143,6 +143,7 @@ static vout_thread_t *VoutCreate(vlc_object_t *object,
/* Initialize locks */
vlc_mutex_init(&vout->p->filter.lock);
vlc_mutex_init(&vout->p->spu_lock);
+ atomic_init(&vout->p->empty, false);
/* Take care of some "interface/control" related initialisations */
vout_IntfInit(vout);
@@ -334,11 +335,7 @@ void vout_Flush(vout_thread_t *vout, mtime_t date)
bool vout_IsEmpty(vout_thread_t *vout)
{
- picture_t *picture = picture_fifo_Peek(vout->p->decoder_fifo);
- if (picture)
- picture_Release(picture);
-
- return !picture;
+ return atomic_load(&vout->p->empty);
}
void vout_NextPicture(vout_thread_t *vout, mtime_t *duration)
@@ -1067,9 +1064,28 @@ static int ThreadDisplayPicture(vout_thread_t *vout, mtime_t *deadline)
const mtime_t date = mdate();
const mtime_t render_delay = vout_chrono_GetHigh(&vout->p->render) + VOUT_MWAIT_TOLERANCE;
+ if (!paused && vout->p->displayed.next == NULL)
+ {
+ /* We reached the last picture to display */
+ if (vout->p->displayed.date <= VLC_TS_INVALID
+ || vout->p->displayed.date + render_delay <= date)
+ {
+ /* Notify the inputthat the vout is empty */
+ atomic_store_explicit(&vout->p->empty, true, memory_order_relaxed);
+ }
+ else
+ {
+ /* Wait a little more before notifying the input, this function
+ * will be called again after the deadline. */
+ *deadline = vout->p->displayed.date + render_delay;
+ }
+ return VLC_EGENERIC;
+ }
+
bool drop_next_frame = frame_by_frame;
mtime_t date_next = VLC_TS_INVALID;
if (!paused && vout->p->displayed.next) {
+ atomic_store_explicit(&vout->p->empty, false, memory_order_relaxed);
date_next = vout->p->displayed.next->date - render_delay;
if (date_next /* + 0 FIXME */ <= date)
drop_next_frame = true;
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index fec54f38eb..b854efc6ac 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -25,6 +25,7 @@
#ifndef LIBVLC_VOUT_INTERNAL_H
#define LIBVLC_VOUT_INTERNAL_H 1
+#include <vlc_atomic.h>
#include <vlc_picture_fifo.h>
#include <vlc_picture_pool.h>
#include <vlc_vout_display.h>
@@ -75,6 +76,7 @@ struct vout_thread_sys_t
vlc_thread_t thread;
bool dead;
vout_control_t control;
+ atomic_bool empty;
/* */
struct {
--
2.11.0
More information about the vlc-devel
mailing list