Commit 0ba0ee33 authored by Thomas Guillem's avatar Thomas Guillem

wip

parent 7358422b
......@@ -281,18 +281,6 @@ static int DecoderWaitGapless(decoder_t *dec)
return ret;
}
void input_DecoderWakeGapless(decoder_t *dec)
{
struct decoder_owner *owner = dec_get_owner(dec);
vlc_mutex_lock(&owner->lock);
assert(owner->gapless_state == GAPLESS_STATE_WAITING);
owner->gapless_state = GAPLESS_STATE_NONE;
vlc_cond_signal(&owner->wait_gapless);
vlc_mutex_unlock(&owner->lock);
}
static void MouseEvent( const vlc_mouse_t *newmouse, void *user_data )
{
decoder_t *dec = user_data;
......@@ -2529,6 +2517,13 @@ void input_DecoderWait( decoder_t *p_dec )
assert( p_owner->b_waiting );
vlc_mutex_lock( &p_owner->lock );
if (p_owner->gapless_state == GAPLESS_STATE_WAITING)
{
p_owner->gapless_state = GAPLESS_STATE_NONE;
vlc_cond_signal(&p_owner->wait_gapless);
}
while( !p_owner->b_has_data )
{
/* Don't need to lock p_owner->paused since it's only modified by the
......
......@@ -138,6 +138,4 @@ void input_DecoderSetVoutMouseEvent( decoder_t *, vlc_mouse_event, void * );
int input_DecoderAddVoutOverlay( decoder_t *, subpicture_t *, size_t * );
int input_DecoderDelVoutOverlay( decoder_t *, size_t );
void input_DecoderWakeGapless(decoder_t *);
#endif
......@@ -165,6 +165,7 @@ typedef struct
/* */
vlc_mutex_t lock;
vlc_cond_t gapless_wait;
/* all programs */
struct vlc_list programs;
......@@ -206,6 +207,7 @@ typedef struct
/* Used for buffering */
bool b_buffering;
bool b_should_stop_buffering;
vlc_tick_t i_buffering_extra_initial;
vlc_tick_t i_buffering_extra_stream;
vlc_tick_t i_buffering_extra_system;
......@@ -481,6 +483,7 @@ es_out_t *input_EsOutNew( input_thread_t *p_input, float rate,
p_sys->out.cbs = &es_out_cbs;
vlc_mutex_init( &p_sys->lock );
vlc_cond_init(&p_sys->gapless_wait);
p_sys->p_input = p_input;
p_sys->b_active = false;
......@@ -522,6 +525,7 @@ es_out_t *input_EsOutNew( input_thread_t *p_input, float rate,
p_sys->rate = rate;
p_sys->b_buffering = true;
p_sys->b_should_stop_buffering = false;
p_sys->i_preroll_end = -1;
p_sys->i_prev_stream_level = -1;
......@@ -602,6 +606,7 @@ static void EsOutDelete( es_out_t *out )
EsOutPropsCleanup( &p_sys->sub );
vlc_mutex_destroy( &p_sys->lock );
vlc_cond_destroy(&p_sys->gapless_wait);
free( p_sys );
}
......@@ -990,6 +995,9 @@ static void EsOutDecodersStopBuffering( es_out_t *out, bool b_forced )
return;
}
while (p_sys->input_type == INPUT_TYPE_GAPLESS)
vlc_cond_wait(&p_sys->gapless_wait, &p_sys->lock);
const vlc_tick_t i_decoder_buffering_start = vlc_tick_now();
foreach_es_then_es_slaves(p_es)
{
......@@ -3463,12 +3471,8 @@ static int EsOutVaControlLocked( es_out_t *out, int i_query, va_list args )
case ES_OUT_WAKE_GAPLESS:
{
assert(p_sys->input_type == INPUT_TYPE_GAPLESS);
es_out_id_t *es;
foreach_es_then_es_slaves(es)
if (es->p_dec != NULL)
input_DecoderWakeGapless(es->p_dec);
p_sys->input_type = INPUT_TYPE_NONE; /* For future decoders */
vlc_cond_signal(&p_sys->gapless_wait);
return VLC_SUCCESS;
}
default:
......
......@@ -190,6 +190,15 @@ void input_SetPosition( input_thread_t *p_input, float f_position, bool b_fast )
input_ControlPush( p_input, INPUT_CONTROL_SET_POSITION, &param );
}
void input_WakeGapless(input_thread_t *input)
{
input_thread_private_t *priv = input_priv(input);
assert(priv->type == INPUT_TYPE_GAPLESS);
input_resource_SetInput(priv->p_resource, input);
es_out_Control(priv->p_es_out_display, ES_OUT_WAKE_GAPLESS);
}
/**
* Get the item from an input thread
* FIXME it does not increase ref count of the item.
......@@ -340,7 +349,6 @@ input_thread_t *input_Create( vlc_object_t *p_parent,
priv->p_resource = input_resource_Hold( p_resource );
else
priv->p_resource = input_resource_New( VLC_OBJECT( p_input ) );
input_resource_SetInput( priv->p_resource, p_input );
/* Init control buffer */
vlc_mutex_init( &priv->lock_control );
......@@ -470,15 +478,6 @@ bool input_Stopped( input_thread_t *input )
return ret;
}
void input_WakeGapless(input_thread_t *input)
{
input_thread_private_t *priv = input_priv(input);
assert(priv->is_running);
assert(priv->type == INPUT_TYPE_GAPLESS);
es_out_Control(priv->p_es_out_display, ES_OUT_WAKE_GAPLESS);
}
/*****************************************************************************
* Main loop: Fill buffers from access, and demux
*****************************************************************************/
......@@ -1223,6 +1222,9 @@ static int Init( input_thread_t * p_input )
goto error;
#endif
if (priv->type != INPUT_TYPE_GAPLESS)
input_resource_SetInput(priv->p_resource, p_input);
/* Create es out */
priv->p_es_out = input_EsOutTimeshiftNew( p_input, priv->p_es_out_display, priv->rate );
if( priv->p_es_out == NULL )
......@@ -1306,7 +1308,8 @@ error:
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_SetInput( input_priv(p_input)->p_resource, NULL );
if (priv->type != INPUT_TYPE_GAPLESS)
input_resource_SetInput( input_priv(p_input)->p_resource, NULL );
if( input_priv(p_input)->p_resource )
{
input_resource_Release( input_priv(p_input)->p_resource );
......@@ -1373,7 +1376,8 @@ static void End( input_thread_t * p_input )
/* */
input_resource_RequestSout( input_priv(p_input)->p_resource,
input_priv(p_input)->p_sout, NULL );
input_resource_SetInput( input_priv(p_input)->p_resource, NULL );
if (priv->type != INPUT_TYPE_GAPLESS)
input_resource_SetInput(input_priv(p_input)->p_resource, NULL);
if( input_priv(p_input)->p_resource )
{
input_resource_Release( input_priv(p_input)->p_resource );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment