[vlc-commits] visual: use vlc_queue_t and simplify
Rémi Denis-Courmont
git at videolan.org
Mon Apr 13 13:05:26 CEST 2020
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Apr 12 09:14:11 2020 +0300| [55ba7526217653c319da3e0c8f30740f50ffed34] | committer: Rémi Denis-Courmont
visual: use vlc_queue_t and simplify
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=55ba7526217653c319da3e0c8f30740f50ffed34
---
modules/visualization/visual/visual.c | 33 ++++++++++++---------------------
1 file changed, 12 insertions(+), 21 deletions(-)
diff --git a/modules/visualization/visual/visual.c b/modules/visualization/visual/visual.c
index 1378129819..db693dfbcd 100644
--- a/modules/visualization/visual/visual.c
+++ b/modules/visualization/visual/visual.c
@@ -35,6 +35,7 @@
#include <vlc_vout.h>
#include <vlc_aout.h>
#include <vlc_filter.h>
+#include <vlc_queue.h>
#include "visual.h"
@@ -179,10 +180,11 @@ static void *Thread( void *);
typedef struct
{
- block_fifo_t *fifo;
+ vlc_queue_t queue;
vout_thread_t *p_vout;
visual_effect_t **effect;
int i_effect;
+ bool dead;
vlc_thread_t thread;
} filter_sys_t;
@@ -309,17 +311,12 @@ static int Open( vlc_object_t *p_this )
goto error;
}
- p_sys->fifo = block_FifoNew();
- if( unlikely( p_sys->fifo == NULL ) )
- {
- vout_Close( p_sys->p_vout );
- goto error;
- }
+ p_sys->dead = false;
+ vlc_queue_Init(&p_sys->queue, offsetof (block_t, p_next));
if( vlc_clone( &p_sys->thread, Thread, p_filter,
VLC_THREAD_PRIORITY_VIDEO ) )
{
- block_FifoRelease( p_sys->fifo );
vout_Close( p_sys->p_vout );
goto error;
}
@@ -377,24 +374,19 @@ static void *Thread( void *data )
{
filter_t *p_filter = data;
filter_sys_t *sys = p_filter->p_sys;
+ block_t *block;
- for (;;)
- {
- block_t *block = block_FifoGet( sys->fifo );
-
- int canc = vlc_savecancel( );
+ while ((block = vlc_queue_DequeueKillable(&sys->queue, &sys->dead)))
block_Release( DoRealWork( p_filter, block ) );
- vlc_restorecancel( canc );
- }
- vlc_assert_unreachable();
+
+ return NULL;
}
static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
{
- block_t *block = block_Duplicate( p_in_buf );
filter_sys_t *p_sys = p_filter->p_sys;
- if( likely(block != NULL) )
- block_FifoPut( p_sys->fifo, block );
+
+ vlc_queue_Enqueue(&p_sys->queue, block_Duplicate(p_in_buf));
return p_in_buf;
}
@@ -412,9 +404,8 @@ static void Close( vlc_object_t *p_this )
filter_t * p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = p_filter->p_sys;
- vlc_cancel( p_sys->thread );
+ vlc_queue_Kill(&p_sys->queue, &p_sys->dead);
vlc_join( p_sys->thread, NULL );
- block_FifoRelease( p_sys->fifo );
vout_Close( p_sys->p_vout );
/* Free the list */
More information about the vlc-commits
mailing list