#include <limits.h>
#include <assert.h>
#include <errno.h>
+#include <math.h>
#include <sys/stat.h>
#include "input_internal.h"
static void SlaveSeek( input_thread_t *p_input );
static void InputMetaUser( input_thread_t *p_input, vlc_meta_t *p_meta );
-static void InputUpdateMeta( input_thread_t *p_input, vlc_meta_t *p_meta );
+static void InputUpdateMeta( input_thread_t *p_input, demux_t *p_demux );
static void InputGetExtraFiles( input_thread_t *p_input,
int *pi_list, char ***pppsz_list,
const char *psz_access, const char *psz_path );
}
else
{
- val.f_float = 0.0;
+ val.f_float = 0.f;
input_ControlPush( p_input, INPUT_CONTROL_SET_POSITION, &val );
}
{
bool b_force_update;
vlc_value_t val;
- mtime_t i_current;
- mtime_t i_wakeup;
+ mtime_t i_wakeup, i_current;
bool b_paused;
bool b_demux_polled;
if( b_buffering )
{
/* When postpone is in order, check the ES level every 20ms */
- mtime_t i_current = mdate();
- if( i_last_seek_mdate + INT64_C(125000) >= i_current )
- i_limit = __MIN( i_deadline, i_current + INT64_C(20000) );
+ mtime_t now = mdate();
+ if( i_last_seek_mdate + INT64_C(125000) >= now )
+ i_limit = __MIN( i_deadline, now + INT64_C(20000) );
}
int i_type;
input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT, &val );
/* Start/stop/run time */
- p_input->p->i_start = (int64_t)(1000000.0
+ p_input->p->i_start = llroundf(1000000.f
* var_GetFloat( p_input, "start-time" ));
- p_input->p->i_stop = (int64_t)(1000000.0
+ p_input->p->i_stop = llroundf(1000000.f
* var_GetFloat( p_input, "stop-time" ));
- p_input->p->i_run = (int64_t)(1000000.0
+ p_input->p->i_run = llroundf(1000000.f
* var_GetFloat( p_input, "run-time" ));
if( p_input->p->i_run < 0 )
{
{
/* Load subtitles */
/* Get fps and set it if not already set */
- const double f_fps = p_input->p->f_fps;
- if( f_fps > 1.0 )
+ const float f_fps = p_input->p->f_fps;
+ if( f_fps > 1.f )
{
- float f_requested_fps;
-
var_Create( p_input, "sub-original-fps", VLC_VAR_FLOAT );
var_SetFloat( p_input, "sub-original-fps", f_fps );
- f_requested_fps = var_CreateGetFloat( p_input, "sub-fps" );
+ float f_requested_fps = var_CreateGetFloat( p_input, "sub-fps" );
if( f_requested_fps != f_fps )
{
var_Create( p_input, "sub-fps", VLC_VAR_FLOAT|
{
char *prgms;
- if( var_GetBool( p_input, "sout-all" ) )
- {
- i_es_out_mode = ES_OUT_MODE_ALL;
- }
- else
if( (prgms = var_GetNonEmptyString( p_input, "programs" )) != NULL )
{
char *buf;
free( prgms );
}
+ else if( var_GetBool( p_input, "sout-all" ) )
+ {
+ i_es_out_mode = ES_OUT_MODE_ALL;
+ }
}
es_out_SetMode( p_input->p->p_es_out, i_es_out_mode );
static int Init( input_thread_t * p_input )
{
- vlc_meta_t *p_meta;
- int i;
-
- for( i = 0; i < p_input->p->p_item->i_options; i++ )
+ for( int i = 0; i < p_input->p->p_item->i_options; i++ )
{
if( !strncmp( p_input->p->p_item->ppsz_options[i], "meta-file", 9 ) )
{
p_input->p->b_out_pace_control ? "async" : "sync" );
}
- p_meta = vlc_meta_New();
- if( p_meta )
+ vlc_meta_t *p_meta = vlc_meta_New();
+ if( p_meta != NULL )
{
/* Get meta data from users */
InputMetaUser( p_input, p_meta );
for( int i = 0; i < p_input->p->i_slave; i++ )
InputSourceMeta( p_input, p_input->p->slave[i], p_meta );
- /* */
- InputUpdateMeta( p_input, p_meta );
+ es_out_ControlSetMeta( p_input->p->p_es_out, p_meta );
+ vlc_meta_Delete( p_meta );
}
msg_Dbg( p_input, "`%s' successfully opened",
case INPUT_CONTROL_SET_POSITION:
{
- double f_pos;
-
if( p_input->p->b_recording )
{
msg_Err( p_input, "INPUT_CONTROL_SET_POSITION(_OFFSET) ignored while recording" );
break;
}
- f_pos = val.f_float;
+
+ float f_pos = val.f_float;
if( i_type != INPUT_CONTROL_SET_POSITION )
f_pos += var_GetFloat( p_input, "position" );
- if( f_pos < 0.0 )
- f_pos = 0.0;
- else if( f_pos > 1.0 )
- f_pos = 1.0;
+ if( f_pos < 0.f )
+ f_pos = 0.f;
+ else if( f_pos > 1.f )
+ f_pos = 1.f;
/* Reset the decoders states and clock sync (before calling the demuxer */
es_out_SetTime( p_input->p->p_es_out, -1 );
if( demux_Control( p_input->p->input.p_demux, DEMUX_SET_POSITION,
- f_pos, !p_input->p->b_fast_seek ) )
+ (double) f_pos, !p_input->p->b_fast_seek ) )
{
msg_Err( p_input, "INPUT_CONTROL_SET_POSITION(_OFFSET) "
- "%2.1f%% failed", f_pos * 100 );
+ "%2.1f%% failed", (double)(f_pos * 100.f) );
}
else
{
if( slave && !InputSourceInit( p_input, slave, uri, NULL, false ) )
{
- vlc_meta_t *p_meta;
int64_t i_time;
/* Add the slave */
}
/* Get meta (access and demux) */
- p_meta = vlc_meta_New();
- if( p_meta )
- {
- demux_Control( slave->p_demux, DEMUX_GET_META, p_meta );
- InputUpdateMeta( p_input, p_meta );
- }
+ InputUpdateMeta( p_input, slave->p_demux );
TAB_APPEND( p_input->p->i_slave, p_input->p->slave, slave );
}
if( p_demux->info.i_update & INPUT_UPDATE_META )
{
- vlc_meta_t *p_meta = vlc_meta_New();
- if( p_meta )
- {
- demux_Control( p_input->p->input.p_demux, DEMUX_GET_META, p_meta );
- InputUpdateMeta( p_input, p_meta );
- }
+ InputUpdateMeta( p_input, p_demux );
p_demux->info.i_update &= ~INPUT_UPDATE_META;
}
{
if( in->p_demux == NULL )
{
- stream_Delete( p_stream );
if( vlc_object_alive( p_input ) )
{
msg_Err( p_input, "no suitable demux module for `%s/%s://%s'",
_("The format of '%s' cannot be detected. "
"Have a look at the log for details."), psz_mrl );
}
+ stream_Delete( p_stream );
goto error;
}
assert( in->p_demux->pf_demux != NULL );
* InputUpdateMeta: merge p_item meta data with p_meta taking care of
* arturl and locking issue.
*****************************************************************************/
-static void InputUpdateMeta( input_thread_t *p_input, vlc_meta_t *p_meta )
+static void InputUpdateMeta( input_thread_t *p_input, demux_t *p_demux )
{
+ vlc_meta_t *p_meta = vlc_meta_New();
+ if( unlikely(p_meta == NULL) )
+ return;
+
+ demux_Control( p_demux, DEMUX_GET_META, p_meta );
+
/* If metadata changed, then the attachments might have changed.
We need to update them in case they contain album art. */
- input_source_t *in = &p_input->p->input;
- int i_attachment;
input_attachment_t **attachment;
- if( !demux_Control( in->p_demux, DEMUX_GET_ATTACHMENTS,
- &attachment, &i_attachment ) )
+ int i_attachment;
+
+ if( !demux_Control( p_demux, DEMUX_GET_ATTACHMENTS,
+ &attachment, &i_attachment ) )
{
vlc_mutex_lock( &p_input->p->p_item->lock );
if( p_input->p->i_attachment > 0 )
i_attachment, attachment );
vlc_mutex_unlock( &p_input->p->p_item->lock );
}
+
es_out_ControlSetMeta( p_input->p->p_es_out, p_meta );
vlc_meta_Delete( p_meta );
}