Commit 03cfa9a9 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

es_out_timeshift: use single allocation for the ES output

parent f8d616cf
...@@ -245,6 +245,8 @@ typedef struct ...@@ -245,6 +245,8 @@ typedef struct
/* */ /* */
int i_es; int i_es;
es_out_id_t **pp_es; es_out_id_t **pp_es;
es_out_t out;
} es_out_sys_t; } es_out_sys_t;
static void Del ( es_out_t *, es_out_id_t * ); static void Del ( es_out_t *, es_out_id_t * );
...@@ -299,19 +301,11 @@ static const struct es_out_callbacks es_out_timeshift_cbs; ...@@ -299,19 +301,11 @@ static const struct es_out_callbacks es_out_timeshift_cbs;
*****************************************************************************/ *****************************************************************************/
es_out_t *input_EsOutTimeshiftNew( input_thread_t *p_input, es_out_t *p_next_out, int i_rate ) es_out_t *input_EsOutTimeshiftNew( input_thread_t *p_input, es_out_t *p_next_out, int i_rate )
{ {
es_out_t *p_out = malloc( sizeof(*p_out) );
if( !p_out )
return NULL;
es_out_sys_t *p_sys = malloc( sizeof(*p_sys) ); es_out_sys_t *p_sys = malloc( sizeof(*p_sys) );
if( !p_sys ) if( !p_sys )
{
free( p_out );
return NULL; return NULL;
}
p_out->cbs = &es_out_timeshift_cbs; p_sys->out.cbs = &es_out_timeshift_cbs;
p_out->p_sys = p_sys;
/* */ /* */
p_sys->b_input_paused = false; p_sys->b_input_paused = false;
...@@ -391,7 +385,7 @@ es_out_t *input_EsOutTimeshiftNew( input_thread_t *p_input, es_out_t *p_next_out ...@@ -391,7 +385,7 @@ es_out_t *input_EsOutTimeshiftNew( input_thread_t *p_input, es_out_t *p_next_out
#undef S #undef S
#endif #endif
return p_out; return &p_sys->out;
} }
/***************************************************************************** /*****************************************************************************
...@@ -399,7 +393,7 @@ es_out_t *input_EsOutTimeshiftNew( input_thread_t *p_input, es_out_t *p_next_out ...@@ -399,7 +393,7 @@ es_out_t *input_EsOutTimeshiftNew( input_thread_t *p_input, es_out_t *p_next_out
*****************************************************************************/ *****************************************************************************/
static void Destroy( es_out_t *p_out ) static void Destroy( es_out_t *p_out )
{ {
es_out_sys_t *p_sys = p_out->p_sys; es_out_sys_t *p_sys = container_of(p_out, es_out_sys_t, out);
if( p_sys->b_delayed ) if( p_sys->b_delayed )
{ {
...@@ -414,12 +408,11 @@ static void Destroy( es_out_t *p_out ) ...@@ -414,12 +408,11 @@ static void Destroy( es_out_t *p_out )
free( p_sys->psz_tmp_path ); free( p_sys->psz_tmp_path );
vlc_mutex_destroy( &p_sys->lock ); vlc_mutex_destroy( &p_sys->lock );
free( p_sys ); free( p_sys );
free( p_out );
} }
static es_out_id_t *Add( es_out_t *p_out, const es_format_t *p_fmt ) static es_out_id_t *Add( es_out_t *p_out, const es_format_t *p_fmt )
{ {
es_out_sys_t *p_sys = p_out->p_sys; es_out_sys_t *p_sys = container_of(p_out, es_out_sys_t, out);
ts_cmd_t cmd; ts_cmd_t cmd;
es_out_id_t *p_es = malloc( sizeof( *p_es ) ); es_out_id_t *p_es = malloc( sizeof( *p_es ) );
...@@ -450,7 +443,7 @@ static es_out_id_t *Add( es_out_t *p_out, const es_format_t *p_fmt ) ...@@ -450,7 +443,7 @@ static es_out_id_t *Add( es_out_t *p_out, const es_format_t *p_fmt )
} }
static int Send( es_out_t *p_out, es_out_id_t *p_es, block_t *p_block ) static int Send( es_out_t *p_out, es_out_id_t *p_es, block_t *p_block )
{ {
es_out_sys_t *p_sys = p_out->p_sys; es_out_sys_t *p_sys = container_of(p_out, es_out_sys_t, out);
ts_cmd_t cmd; ts_cmd_t cmd;
int i_ret = VLC_SUCCESS; int i_ret = VLC_SUCCESS;
...@@ -470,7 +463,7 @@ static int Send( es_out_t *p_out, es_out_id_t *p_es, block_t *p_block ) ...@@ -470,7 +463,7 @@ static int Send( es_out_t *p_out, es_out_id_t *p_es, block_t *p_block )
} }
static void Del( es_out_t *p_out, es_out_id_t *p_es ) static void Del( es_out_t *p_out, es_out_id_t *p_es )
{ {
es_out_sys_t *p_sys = p_out->p_sys; es_out_sys_t *p_sys = container_of(p_out, es_out_sys_t, out);
ts_cmd_t cmd; ts_cmd_t cmd;
vlc_mutex_lock( &p_sys->lock ); vlc_mutex_lock( &p_sys->lock );
...@@ -490,7 +483,7 @@ static void Del( es_out_t *p_out, es_out_id_t *p_es ) ...@@ -490,7 +483,7 @@ static void Del( es_out_t *p_out, es_out_id_t *p_es )
static int ControlLockedGetEmpty( es_out_t *p_out, bool *pb_empty ) static int ControlLockedGetEmpty( es_out_t *p_out, bool *pb_empty )
{ {
es_out_sys_t *p_sys = p_out->p_sys; es_out_sys_t *p_sys = container_of(p_out, es_out_sys_t, out);
if( p_sys->b_delayed && TsHasCmd( p_sys->p_ts ) ) if( p_sys->b_delayed && TsHasCmd( p_sys->p_ts ) )
*pb_empty = false; *pb_empty = false;
...@@ -501,7 +494,7 @@ static int ControlLockedGetEmpty( es_out_t *p_out, bool *pb_empty ) ...@@ -501,7 +494,7 @@ static int ControlLockedGetEmpty( es_out_t *p_out, bool *pb_empty )
} }
static int ControlLockedGetWakeup( es_out_t *p_out, mtime_t *pi_wakeup ) static int ControlLockedGetWakeup( es_out_t *p_out, mtime_t *pi_wakeup )
{ {
es_out_sys_t *p_sys = p_out->p_sys; es_out_sys_t *p_sys = container_of(p_out, es_out_sys_t, out);
if( p_sys->b_delayed ) if( p_sys->b_delayed )
{ {
...@@ -517,7 +510,7 @@ static int ControlLockedGetWakeup( es_out_t *p_out, mtime_t *pi_wakeup ) ...@@ -517,7 +510,7 @@ static int ControlLockedGetWakeup( es_out_t *p_out, mtime_t *pi_wakeup )
} }
static int ControlLockedGetBuffering( es_out_t *p_out, bool *pb_buffering ) static int ControlLockedGetBuffering( es_out_t *p_out, bool *pb_buffering )
{ {
es_out_sys_t *p_sys = p_out->p_sys; es_out_sys_t *p_sys = container_of(p_out, es_out_sys_t, out);
if( p_sys->b_delayed ) if( p_sys->b_delayed )
*pb_buffering = true; *pb_buffering = true;
...@@ -528,7 +521,7 @@ static int ControlLockedGetBuffering( es_out_t *p_out, bool *pb_buffering ) ...@@ -528,7 +521,7 @@ static int ControlLockedGetBuffering( es_out_t *p_out, bool *pb_buffering )
} }
static int ControlLockedSetPauseState( es_out_t *p_out, bool b_source_paused, bool b_paused, mtime_t i_date ) static int ControlLockedSetPauseState( es_out_t *p_out, bool b_source_paused, bool b_paused, mtime_t i_date )
{ {
es_out_sys_t *p_sys = p_out->p_sys; es_out_sys_t *p_sys = container_of(p_out, es_out_sys_t, out);
int i_ret; int i_ret;
if( !p_sys->b_delayed && !b_source_paused == !b_paused ) if( !p_sys->b_delayed && !b_source_paused == !b_paused )
...@@ -563,7 +556,7 @@ static int ControlLockedSetPauseState( es_out_t *p_out, bool b_source_paused, bo ...@@ -563,7 +556,7 @@ static int ControlLockedSetPauseState( es_out_t *p_out, bool b_source_paused, bo
} }
static int ControlLockedSetRate( es_out_t *p_out, int i_src_rate, int i_rate ) static int ControlLockedSetRate( es_out_t *p_out, int i_src_rate, int i_rate )
{ {
es_out_sys_t *p_sys = p_out->p_sys; es_out_sys_t *p_sys = container_of(p_out, es_out_sys_t, out);
int i_ret; int i_ret;
if( !p_sys->b_delayed && i_src_rate == i_rate ) if( !p_sys->b_delayed && i_src_rate == i_rate )
...@@ -599,14 +592,14 @@ static int ControlLockedSetRate( es_out_t *p_out, int i_src_rate, int i_rate ) ...@@ -599,14 +592,14 @@ static int ControlLockedSetRate( es_out_t *p_out, int i_src_rate, int i_rate )
} }
static int ControlLockedSetFrameNext( es_out_t *p_out ) static int ControlLockedSetFrameNext( es_out_t *p_out )
{ {
es_out_sys_t *p_sys = p_out->p_sys; es_out_sys_t *p_sys = container_of(p_out, es_out_sys_t, out);
return es_out_SetFrameNext( p_sys->p_out ); return es_out_SetFrameNext( p_sys->p_out );
} }
static int ControlLocked( es_out_t *p_out, int i_query, va_list args ) static int ControlLocked( es_out_t *p_out, int i_query, va_list args )
{ {
es_out_sys_t *p_sys = p_out->p_sys; es_out_sys_t *p_sys = container_of(p_out, es_out_sys_t, out);
switch( i_query ) switch( i_query )
{ {
...@@ -730,7 +723,7 @@ static int ControlLocked( es_out_t *p_out, int i_query, va_list args ) ...@@ -730,7 +723,7 @@ static int ControlLocked( es_out_t *p_out, int i_query, va_list args )
} }
static int Control( es_out_t *p_out, int i_query, va_list args ) static int Control( es_out_t *p_out, int i_query, va_list args )
{ {
es_out_sys_t *p_sys = p_out->p_sys; es_out_sys_t *p_sys = container_of(p_out, es_out_sys_t, out);
int i_ret; int i_ret;
vlc_mutex_lock( &p_sys->lock ); vlc_mutex_lock( &p_sys->lock );
...@@ -764,7 +757,7 @@ static void TsDestroy( ts_thread_t *p_ts ) ...@@ -764,7 +757,7 @@ static void TsDestroy( ts_thread_t *p_ts )
} }
static int TsStart( es_out_t *p_out ) static int TsStart( es_out_t *p_out )
{ {
es_out_sys_t *p_sys = p_out->p_sys; es_out_sys_t *p_sys = container_of(p_out, es_out_sys_t, out);
ts_thread_t *p_ts; ts_thread_t *p_ts;
assert( !p_sys->b_delayed ); assert( !p_sys->b_delayed );
...@@ -805,7 +798,7 @@ static int TsStart( es_out_t *p_out ) ...@@ -805,7 +798,7 @@ static int TsStart( es_out_t *p_out )
} }
static void TsAutoStop( es_out_t *p_out ) static void TsAutoStop( es_out_t *p_out )
{ {
es_out_sys_t *p_sys = p_out->p_sys; es_out_sys_t *p_sys = container_of(p_out, es_out_sys_t, out);
if( !p_sys->b_delayed || !TsIsUnused( p_sys->p_ts ) ) if( !p_sys->b_delayed || !TsIsUnused( p_sys->p_ts ) )
return; return;
......
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