#include "clock.h"
#include "decoder.h"
#include "event.h"
+#include "ressource.h"
#include "../video_output/vout_control.h"
i_priority = VLC_THREAD_PRIORITY_VIDEO;
/* Spawn the decoder thread */
- if( vlc_thread_create( p_dec, "decoder", DecoderThread,
- i_priority, false ) )
+ if( vlc_thread_create( p_dec, "decoder", DecoderThread, i_priority ) )
{
msg_Err( p_dec, "cannot spawn decoder thread" );
module_unneed( p_dec, p_dec->p_module );
/* Make sure we aren't paused/buffering/waiting anymore */
vlc_mutex_lock( &p_owner->lock );
+ const b_was_paused = p_owner->b_paused;
p_owner->b_paused = false;
p_owner->b_buffering = false;
p_owner->b_flushing = true;
vlc_mutex_unlock( &p_owner->lock );
vlc_thread_join( p_dec );
+ p_owner->b_paused = b_was_paused;
+
module_unneed( p_dec, p_dec->p_module );
/* */
if( !p_owner->p_clock || !i_ts )
return i_ts;
- return input_clock_GetTS( p_owner->p_clock, NULL, p_owner->p_input->i_pts_delay, i_ts );
+ if( input_clock_ConvertTS( p_owner->p_clock, NULL, &i_ts, NULL, INT64_MAX ) )
+ return 0;
+
+ return i_ts;
}
static int DecoderGetDisplayRate( decoder_t *p_dec )
{
vlc_restorecancel( canc );
}
- /* Ensure fast cancellation in case the fifo is not empty */
- vlc_testcancel();
}
return NULL;
}
*pi_preroll = __MIN( *pi_preroll, p->i_dts );
}
-static mtime_t DecoderTeletextFixTs( mtime_t i_ts, mtime_t i_ts_delay )
+static mtime_t DecoderTeletextFixTs( mtime_t i_ts )
{
mtime_t current_date = mdate();
{
/* ETSI EN 300 472 Annex A : do not take into account the PTS
* for teletext streams. */
- return current_date + 400000 + i_ts_delay;
+ return current_date + 400000;
}
return i_ts;
}
static void DecoderFixTs( decoder_t *p_dec, mtime_t *pi_ts0, mtime_t *pi_ts1,
- mtime_t *pi_duration, int *pi_rate, mtime_t *pi_delay, bool b_telx )
+ mtime_t *pi_duration, int *pi_rate, mtime_t i_ts_bound, bool b_telx )
{
decoder_owner_sys_t *p_owner = p_dec->p_owner;
input_clock_t *p_clock = p_owner->p_clock;
- int i_rate = 0;
vlc_assert_locked( &p_owner->lock );
- const mtime_t i_ts_delay = p_owner->p_input->i_pts_delay;
const mtime_t i_es_delay = p_owner->i_ts_delay;
if( p_clock )
{
const bool b_ephemere = pi_ts1 && *pi_ts0 == *pi_ts1;
+ int i_rate;
if( *pi_ts0 > 0 )
- *pi_ts0 = input_clock_GetTS( p_clock, &i_rate, i_ts_delay,
- *pi_ts0 + i_es_delay );
- if( pi_ts1 && *pi_ts1 > 0 )
- *pi_ts1 = input_clock_GetTS( p_clock, &i_rate, i_ts_delay,
- *pi_ts1 + i_es_delay );
+ {
+ *pi_ts0 += i_es_delay;
+ if( pi_ts1 && *pi_ts1 > 0 )
+ *pi_ts1 += i_es_delay;
+ input_clock_ConvertTS( p_clock, &i_rate, pi_ts0, pi_ts1, i_ts_bound );
+ }
+ else
+ {
+ i_rate = input_clock_GetRate( p_clock );
+ }
/* Do not create ephemere data because of rounding errors */
if( !b_ephemere && pi_ts1 && *pi_ts0 == *pi_ts1 )
*pi_ts1 += 1;
- if( i_rate <= 0 )
- i_rate = input_clock_GetRate( p_clock );
-
if( pi_duration )
*pi_duration = ( *pi_duration * i_rate +
INPUT_RATE_DEFAULT-1 ) / INPUT_RATE_DEFAULT;
if( b_telx )
{
- *pi_ts0 = DecoderTeletextFixTs( *pi_ts0, i_ts_delay );
+ *pi_ts0 = DecoderTeletextFixTs( *pi_ts0 );
if( pi_ts1 && *pi_ts1 <= 0 )
*pi_ts1 = *pi_ts0;
}
}
- if( pi_delay )
- {
- const int r = i_rate > 0 ? i_rate : INPUT_RATE_DEFAULT;
- *pi_delay = i_ts_delay + i_es_delay * r / INPUT_RATE_DEFAULT;
- }
}
static void DecoderPlayAudio( decoder_t *p_dec, aout_buffer_t *p_audio,
}
/* */
+ const bool b_dated = p_audio->start_date > 0;
int i_rate = INPUT_RATE_DEFAULT;
- mtime_t i_delay;
DecoderFixTs( p_dec, &p_audio->start_date, &p_audio->end_date, NULL,
- &i_rate, &i_delay, false );
+ &i_rate, AOUT_MAX_ADVANCE_TIME, false );
vlc_mutex_unlock( &p_owner->lock );
- /* */
- const mtime_t i_max_date = mdate() + i_delay + AOUT_MAX_ADVANCE_TIME;
-
if( !p_aout || !p_aout_input ||
- p_audio->start_date <= 0 || p_audio->start_date > i_max_date ||
+ p_audio->start_date <= 0 ||
i_rate < INPUT_RATE_DEFAULT/AOUT_MAX_INPUT_RATE ||
i_rate > INPUT_RATE_DEFAULT*AOUT_MAX_INPUT_RATE )
b_reject = true;
}
else
{
- if( p_audio->start_date <= 0 )
- {
+ if( b_dated )
+ msg_Warn( p_aout, "received buffer in the future" );
+ else
msg_Warn( p_dec, "non-dated audio buffer received" );
- }
- else if( p_audio->start_date > i_max_date )
- {
- msg_Warn( p_aout, "received buffer in the future (%"PRId64")",
- p_audio->start_date - mdate() );
- }
+
*pi_lost_sum += 1;
aout_BufferFree( p_audio );
}
{
aout_instance_t *p_aout = p_owner->p_aout;
aout_input_t *p_aout_input = p_owner->p_aout_input;
- int i_lost = 0;
- int i_played;
if( p_dec->b_die )
{
p_picture->b_force = true;
}
+ const bool b_dated = p_picture->date > 0;
int i_rate = INPUT_RATE_DEFAULT;
- mtime_t i_delay;
DecoderFixTs( p_dec, &p_picture->date, NULL, NULL,
- &i_rate, &i_delay, false );
+ &i_rate, DECODER_BOGUS_VIDEO_DELAY, false );
vlc_mutex_unlock( &p_owner->lock );
/* */
- const mtime_t i_max_date = mdate() + i_delay + DECODER_BOGUS_VIDEO_DELAY;
-
- if( !p_picture->b_force && ( p_picture->date <= 0 || p_picture->date >= i_max_date ) )
+ if( !p_picture->b_force && p_picture->date <= 0 )
b_reject = true;
if( !b_reject )
}
else
{
- if( p_picture->date <= 0 )
- {
- msg_Warn( p_vout, "non-dated video buffer received" );
- }
+ if( b_dated )
+ msg_Warn( p_vout, "early picture skipped" );
else
- {
- msg_Warn( p_vout, "early picture skipped (%"PRId64")",
- p_picture->date - mdate() );
- }
+ msg_Warn( p_vout, "non-dated video buffer received" );
+
*pi_lost_sum += 1;
vout_DropPicture( p_vout, p_picture );
}
/* */
DecoderFixTs( p_dec, &p_subpic->i_start, &p_subpic->i_stop, NULL,
- NULL, NULL, b_telx );
+ NULL, INT64_MAX, b_telx );
vlc_mutex_unlock( &p_owner->lock );
DecoderFixTs( p_dec, &p_sout_block->i_dts, &p_sout_block->i_pts,
&p_sout_block->i_length,
- &p_sout_block->i_rate, NULL, b_telx );
+ &p_sout_block->i_rate, INT64_MAX, b_telx );
vlc_mutex_unlock( &p_owner->lock );
stats_UpdateInteger( p_dec, p_input->p->counters.p_decoded_sub, 1, NULL );
vlc_mutex_unlock( &p_input->p->counters.counters_lock );
- p_vout = vlc_object_find( p_dec, VLC_OBJECT_VOUT, FIND_ANYWHERE );
+ p_vout = input_ressource_HoldVout( p_input->p->p_ressource );
if( p_vout && p_owner->p_spu_vout == p_vout )
{
/* Preroll does not work very well with subtitle */
if( b_flush && p_owner->p_spu_vout )
{
- p_vout = vlc_object_find( p_dec, VLC_OBJECT_VOUT, FIND_ANYWHERE );
+ p_vout = input_ressource_HoldVout( p_input->p->p_ressource );
if( p_vout && p_owner->p_spu_vout == p_vout )
spu_Control( p_vout->p_spu, SPU_CHANNEL_CLEAR,
}
#ifdef ENABLE_SOUT
- if( p_dec->i_object_type == VLC_OBJECT_PACKETIZER )
+ if( vlc_internals( p_dec )->i_object_type == VLC_OBJECT_PACKETIZER )
{
if( p_block )
p_block->i_flags &= ~BLOCK_FLAG_CORE_PRIVATE_MASK;
aout_DecDelete( p_owner->p_aout, p_owner->p_aout_input );
if( p_owner->p_aout )
{
- vlc_object_release( p_owner->p_aout );
+ input_ressource_RequestAout( p_owner->p_input->p->p_ressource,
+ p_owner->p_aout );
+ input_SendEventAout( p_owner->p_input );
p_owner->p_aout = NULL;
}
if( p_owner->p_vout )
{
- /* Hack to make sure all the the pictures are freed by the decoder */
+ /* Hack to make sure all the the pictures are freed by the decoder
+ * and that the vout is not paused anymore */
vout_FixLeaks( p_owner->p_vout, true );
+ if( p_owner->b_paused )
+ vout_ChangePause( p_owner->p_vout, false, mdate() );
- /* We are about to die. Reattach video output to p_vlc. */
- vout_Request( p_dec, p_owner->p_vout, NULL );
+ /* */
+ input_ressource_RequestVout( p_owner->p_input->p->p_ressource, p_owner->p_vout, NULL );
input_SendEventVout( p_owner->p_input );
}
{
vout_thread_t *p_vout;
- p_vout = vlc_object_find( p_dec, VLC_OBJECT_VOUT, FIND_ANYWHERE );
+ p_vout = input_ressource_HoldVout( p_owner->p_input->p->p_ressource );
if( p_vout )
{
if( p_owner->p_spu_vout == p_vout )
{
decoder_t *p_dec = p_private;
- p_vout = vout_Request( p_dec, p_vout, p_fmt );
+ p_vout = input_ressource_RequestVout( p_dec->p_owner->p_input->p->p_ressource, p_vout, p_fmt );
input_SendEventVout( p_dec->p_owner->p_input );
return p_vout;
request_vout.p_private = p_dec;
p_aout = p_owner->p_aout;
+ if( !p_aout )
+ p_aout = input_ressource_RequestAout( p_owner->p_input->p->p_ressource, NULL );
p_aout_input = aout_DecNew( p_dec, &p_aout,
&format, &p_dec->fmt_out.audio_replay_gain, &request_vout );
vlc_mutex_unlock( &p_owner->lock );
+ input_SendEventAout( p_owner->p_input );
+
if( p_owner->p_aout_input == NULL )
{
msg_Err( p_dec, "failed to create audio output" );
p_owner->p_vout = NULL;
vlc_mutex_unlock( &p_owner->lock );
- p_vout = vout_Request( p_dec, p_vout, &p_dec->fmt_out.video );
+ p_vout = input_ressource_RequestVout( p_owner->p_input->p->p_ressource,
+ p_vout, &p_dec->fmt_out.video );
vlc_mutex_lock( &p_owner->lock );
p_owner->p_vout = p_vout;
if( p_dec->b_die || p_dec->b_error )
break;
- p_vout = vlc_object_find( p_dec, VLC_OBJECT_VOUT, FIND_ANYWHERE );
+ p_vout = input_ressource_HoldVout( p_owner->p_input->p->p_ressource );
if( p_vout )
break;
decoder_owner_sys_t *p_owner = p_dec->p_owner;
vout_thread_t *p_vout = NULL;
- p_vout = vlc_object_find( p_dec, VLC_OBJECT_VOUT, FIND_ANYWHERE );
+ p_vout = input_ressource_HoldVout( p_owner->p_input->p->p_ressource );
if( !p_vout || p_owner->p_spu_vout != p_vout )
{
if( p_vout )