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

input: switch spu and audio delay variables to integer type

parent 4286e342
......@@ -478,7 +478,7 @@ int64_t libvlc_audio_get_delay( libvlc_media_player_t *p_mi )
int64_t val = 0;
if( p_input_thread != NULL )
{
val = var_GetTime( p_input_thread, "audio-delay" );
val = var_GetInteger( p_input_thread, "audio-delay" );
vlc_object_release( p_input_thread );
}
return val;
......@@ -493,7 +493,7 @@ int libvlc_audio_set_delay( libvlc_media_player_t *p_mi, int64_t i_delay )
int ret = 0;
if( p_input_thread != NULL )
{
var_SetTime( p_input_thread, "audio-delay", i_delay );
var_SetInteger( p_input_thread, "audio-delay", i_delay );
vlc_object_release( p_input_thread );
}
else
......
......@@ -364,7 +364,7 @@ int64_t libvlc_video_get_spu_delay( libvlc_media_player_t *p_mi )
if( p_input_thread )
{
val = var_GetTime( p_input_thread, "spu-delay" );
val = var_GetInteger( p_input_thread, "spu-delay" );
vlc_object_release( p_input_thread );
}
else
......@@ -383,7 +383,7 @@ int libvlc_video_set_spu_delay( libvlc_media_player_t *p_mi,
if( p_input_thread )
{
var_SetTime( p_input_thread, "spu-delay", i_delay );
var_SetInteger( p_input_thread, "spu-delay", i_delay );
vlc_object_release( p_input_thread );
ret = 0;
}
......
......@@ -450,10 +450,10 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
}
else
{
int64_t i_current_subdelay = var_GetTime( p_input, "spu-delay" );
int64_t i_current_subdelay = var_GetInteger( p_input, "spu-delay" );
int64_t i_additional_subdelay = p_sys->subtitle_delaybookmarks.i_time_audio - p_sys->subtitle_delaybookmarks.i_time_subtitle;
int64_t i_total_subdelay = i_current_subdelay + i_additional_subdelay;
var_SetTime( p_input, "spu-delay", i_total_subdelay);
var_SetInteger( p_input, "spu-delay", i_total_subdelay);
ClearChannels( p_intf, p_vout );
DisplayMessage( p_vout, _( "Sub sync: corrected %i ms (total delay = %i ms)" ),
(int)(i_additional_subdelay / 1000),
......@@ -466,7 +466,7 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
}
case ACTIONID_SUBSYNC_RESET:
{
var_SetTime( p_input, "spu-delay", 0);
var_SetInteger( p_input, "spu-delay", 0);
ClearChannels( p_intf, p_vout );
DisplayMessage( p_vout, _( "Sub sync: delay reset" ) );
p_sys->subtitle_delaybookmarks.i_time_audio = 0;
......@@ -493,9 +493,9 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
var_FreeList( &list, &list2 );
break;
}
int64_t i_delay = var_GetTime( p_input, "spu-delay" ) + diff;
int64_t i_delay = var_GetInteger( p_input, "spu-delay" ) + diff;
var_SetTime( p_input, "spu-delay", i_delay );
var_SetInteger( p_input, "spu-delay", i_delay );
ClearChannels( p_intf, p_vout );
DisplayMessage( p_vout, _( "Subtitle delay %i ms" ),
(int)(i_delay/1000) );
......@@ -509,9 +509,10 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
int diff = (i_action == ACTIONID_AUDIODELAY_UP) ? 50000 : -50000;
if( p_input )
{
int64_t i_delay = var_GetTime( p_input, "audio-delay" ) + diff;
int64_t i_delay = var_GetInteger( p_input, "audio-delay" )
+ diff;
var_SetTime( p_input, "audio-delay", i_delay );
var_SetInteger( p_input, "audio-delay", i_delay );
ClearChannels( p_intf, p_vout );
DisplayMessage( p_vout, _( "Audio delay %i ms" ),
(int)(i_delay/1000) );
......
......@@ -695,7 +695,7 @@ static int Demux( demux_t *p_demux )
if( p_sys->i_subtitle >= p_sys->i_subtitles )
return 0;
i_maxdate = p_sys->i_next_demux_date - var_GetTime( p_demux->p_parent, "spu-delay" );;
i_maxdate = p_sys->i_next_demux_date - var_GetInteger( p_demux->p_parent, "spu-delay" );;
if( i_maxdate <= 0 && p_sys->i_subtitle < p_sys->i_subtitles )
{
/* Should not happen */
......
......@@ -128,8 +128,8 @@ static VLCTrackSynchronization *_o_sharedInstance = nil;
input_thread_t * p_input = pl_CurrentInput(p_intf);
if (p_input) {
var_SetTime(p_input, "audio-delay", 0.0);
var_SetTime(p_input, "spu-delay", 0.0);
var_SetInteger(p_input, "audio-delay", 0.0);
var_SetInteger(p_input, "spu-delay", 0.0);
var_SetFloat(p_input, "sub-fps", 1.0);
[self svDurationValueChanged:nil];
vlc_object_release(p_input);
......@@ -141,8 +141,8 @@ static VLCTrackSynchronization *_o_sharedInstance = nil;
input_thread_t * p_input = pl_CurrentInput(p_intf);
if (p_input) {
[o_av_value_fld setDoubleValue: var_GetTime(p_input, "audio-delay") / 1000000.];
[o_sv_advance_value_fld setDoubleValue: var_GetTime(p_input, "spu-delay") / 1000000.];
[o_av_value_fld setDoubleValue: var_GetInteger(p_input, "audio-delay") / 1000000.];
[o_sv_advance_value_fld setDoubleValue: var_GetInteger(p_input, "spu-delay") / 1000000.];
[o_sv_speed_value_fld setFloatValue: var_GetFloat(p_input, "sub-fps")];
vlc_object_release(p_input);
}
......@@ -161,7 +161,7 @@ static VLCTrackSynchronization *_o_sharedInstance = nil;
input_thread_t * p_input = pl_CurrentInput(p_intf);
if (p_input) {
var_SetTime(p_input, "audio-delay", [o_av_value_fld doubleValue] * 1000000.);
var_SetInteger(p_input, "audio-delay", [o_av_value_fld doubleValue] * 1000000.);
vlc_object_release(p_input);
}
......@@ -177,7 +177,7 @@ static VLCTrackSynchronization *_o_sharedInstance = nil;
input_thread_t * p_input = pl_CurrentInput(p_intf);
if (p_input) {
var_SetTime(p_input, "spu-delay", [o_sv_advance_value_fld doubleValue] * 1000000.);
var_SetInteger(p_input, "spu-delay", [o_sv_advance_value_fld doubleValue] * 1000000.);
vlc_object_release(p_input);
}
......
......@@ -215,7 +215,7 @@
if(!p_input)
return i_delay;
i_delay = var_GetTime(p_input, "audio-delay");
i_delay = var_GetInteger(p_input, "audio-delay");
vlc_object_release(p_input);
return (i_delay / 1000);
......@@ -226,7 +226,7 @@
if(!p_input)
return;
var_SetTime(p_input, "audio-delay", i_audioDesync * 1000);
var_SetInteger(p_input, "audio-delay", i_audioDesync * 1000);
vlc_object_release(p_input);
}
......
......@@ -1587,10 +1587,10 @@ void SyncControls::update()
int64_t i_delay;
if( THEMIM->getInput() )
{
i_delay = var_GetTime( THEMIM->getInput(), "audio-delay" );
AVSpin->setValue( ( (double)i_delay ) / 1000000 );
i_delay = var_GetTime( THEMIM->getInput(), "spu-delay" );
subsSpin->setValue( ( (double)i_delay ) / 1000000 );
i_delay = var_GetInteger( THEMIM->getInput(), "audio-delay" );
AVSpin->setValue( ( (double)i_delay ) / CLOCK_FREQ );
i_delay = var_GetInteger( THEMIM->getInput(), "spu-delay" );
subsSpin->setValue( ( (double)i_delay ) / CLOCK_FREQ );
subSpeedSpin->setValue( var_GetFloat( THEMIM->getInput(), "sub-fps" ) );
subDurationSpin->setValue( var_InheritFloat( p_intf, SUBSDELAY_CFG_FACTOR ) );
}
......@@ -1601,8 +1601,8 @@ void SyncControls::advanceAudio( double f_advance )
{
if( THEMIM->getInput() && b_userAction )
{
int64_t i_delay = f_advance * 1000000;
var_SetTime( THEMIM->getInput(), "audio-delay", i_delay );
int64_t i_delay = f_advance * CLOCK_FREQ;
var_SetInteger( THEMIM->getInput(), "audio-delay", i_delay );
}
}
......@@ -1610,8 +1610,8 @@ void SyncControls::advanceSubs( double f_advance )
{
if( THEMIM->getInput() && b_userAction )
{
int64_t i_delay = f_advance * 1000000;
var_SetTime( THEMIM->getInput(), "spu-delay", i_delay );
int64_t i_delay = f_advance * CLOCK_FREQ;
var_SetInteger( THEMIM->getInput(), "spu-delay", i_delay );
}
}
......
......@@ -163,7 +163,7 @@ processcommands = function ()
elseif command == "audiodelay" then
if vlc.object.input() and val then
val = common.us_tonumber(val)
vlc.var.set(vlc.object.input(),"audio-delay",val)
vlc.var.set(vlc.object.input(),"audio-delay",val * 1000000)
end
elseif command == "rate" then
val = common.us_tonumber(val)
......@@ -173,7 +173,7 @@ processcommands = function ()
elseif command == "subdelay" then
if vlc.object.input() then
val = common.us_tonumber(val)
vlc.var.set(vlc.object.input(),"spu-delay",val)
vlc.var.set(vlc.object.input(),"spu-delay",val * 1000000)
end
elseif command == "aspectratio" then
if vlc.object.vout() then
......@@ -460,9 +460,9 @@ getstatus = function (includecategories)
s.time=math.floor(vlc.var.get(input,"time") / 1000000)
s.position=vlc.var.get(input,"position")
s.currentplid=vlc.playlist.current()
s.audiodelay=vlc.var.get(input,"audio-delay")
s.audiodelay=vlc.var.get(input,"audio-delay") / 1000000
s.rate=vlc.var.get(input,"rate")
s.subtitledelay=vlc.var.get(input,"spu-delay")
s.subtitledelay=vlc.var.get(input,"spu-delay") / 1000000
else
s.length=0
s.time=0
......
......@@ -120,21 +120,21 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
case INPUT_GET_AUDIO_DELAY:
pi_64 = (int64_t*)va_arg( args, int64_t * );
*pi_64 = var_GetTime( p_input, "audio-delay" );
*pi_64 = var_GetInteger( p_input, "audio-delay" );
return VLC_SUCCESS;
case INPUT_GET_SPU_DELAY:
pi_64 = (int64_t*)va_arg( args, int64_t * );
*pi_64 = var_GetTime( p_input, "spu-delay" );
*pi_64 = var_GetInteger( p_input, "spu-delay" );
return VLC_SUCCESS;
case INPUT_SET_AUDIO_DELAY:
i_64 = (int64_t)va_arg( args, int64_t );
return var_SetTime( p_input, "audio-delay", i_64 );
return var_SetInteger( p_input, "audio-delay", i_64 );
case INPUT_SET_SPU_DELAY:
i_64 = (int64_t)va_arg( args, int64_t );
return var_SetTime( p_input, "spu-delay", i_64 );
return var_SetInteger( p_input, "spu-delay", i_64 );
case INPUT_NAV_ACTIVATE:
case INPUT_NAV_UP:
......
......@@ -102,7 +102,7 @@ void input_SendEventAudioDelay( input_thread_t *p_input, mtime_t i_delay )
{
vlc_value_t val;
val.i_time = i_delay;
val.i_int = i_delay;
var_Change( p_input, "audio-delay", VLC_VAR_SETVALUE, &val, NULL );
Trigger( p_input, INPUT_EVENT_AUDIO_DELAY );
......@@ -112,7 +112,7 @@ void input_SendEventSubtitleDelay( input_thread_t *p_input, mtime_t i_delay )
{
vlc_value_t val;
val.i_time = i_delay;
val.i_int = i_delay;
var_Change( p_input, "spu-delay", VLC_VAR_SETVALUE, &val, NULL );
Trigger( p_input, INPUT_EVENT_SUBTITLE_DELAY );
......
......@@ -952,7 +952,7 @@ static void LoadSubtitles( input_thread_t *p_input )
const int i_delay = var_CreateGetInteger( p_input, "sub-delay" );
if( i_delay != 0 )
var_SetTime( p_input, "spu-delay", (mtime_t)i_delay * 100000 );
var_SetInteger( p_input, "spu-delay", (mtime_t)i_delay * 100000 );
/* Look for and add subtitle files */
unsigned i_flags = SUB_FORCED;
......@@ -1076,8 +1076,8 @@ static void UpdatePtsDelay( input_thread_t *p_input )
i_pts_delay = 0;
/* Take care of audio/spu delay */
const mtime_t i_audio_delay = var_GetTime( p_input, "audio-delay" );
const mtime_t i_spu_delay = var_GetTime( p_input, "spu-delay" );
const mtime_t i_audio_delay = var_GetInteger( p_input, "audio-delay" );
const mtime_t i_spu_delay = var_GetInteger( p_input, "spu-delay" );
const mtime_t i_extra_delay = __MIN( i_audio_delay, i_spu_delay );
if( i_extra_delay < 0 )
i_pts_delay -= i_extra_delay;
......@@ -1837,12 +1837,12 @@ static bool Control( input_thread_t *p_input,
break;
case INPUT_CONTROL_SET_AUDIO_DELAY:
input_SendEventAudioDelay( p_input, val.i_time );
input_SendEventAudioDelay( p_input, val.i_int );
UpdatePtsDelay( p_input );
break;
case INPUT_CONTROL_SET_SPU_DELAY:
input_SendEventSubtitleDelay( p_input, val.i_time );
input_SendEventSubtitleDelay( p_input, val.i_int );
UpdatePtsDelay( p_input );
break;
......
......@@ -186,10 +186,10 @@ void input_ControlVarInit ( input_thread_t *p_input )
var_Change( p_input, "navigation", VLC_VAR_SETTEXT, &text, NULL );
/* Delay */
var_Create( p_input, "audio-delay", VLC_VAR_TIME );
var_SetTime( p_input, "audio-delay",
var_Create( p_input, "audio-delay", VLC_VAR_INTEGER );
var_SetInteger( p_input, "audio-delay",
1000 * var_GetInteger( p_input, "audio-desync" ) );
var_Create( p_input, "spu-delay", VLC_VAR_TIME );
var_Create( p_input, "spu-delay", VLC_VAR_INTEGER );
/* Video ES */
var_Create( p_input, "video-es", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
......
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