mirror of
https://code.videolan.org/videolan/vlc
synced 2024-09-28 23:09:59 +02:00
visual: use vlc_queue_t and simplify
This commit is contained in:
parent
7d86ac9cc5
commit
55ba752621
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user