Fix for vlc3 dvdnav start-time bug backported from vlc-git
Posted: 09 Feb 2020 21:46
Since trac.videolan.org seems to be broken (I'm not the only one who can neither log in nor reset my password) I post this here.
This fix for the vlc3 --start-time failure is backported from vlc-git (commit 59ea3e67fbc7ff5a649cc549ec512ffe55d62a51). It seems to work, but the resume times will be different for dvd:// and dvdread:// (this is also the case with vlc-git - if you created a bookmark with a previous vlc version you have to use dvdread:// to get the same place in the DVD with vlc-git).
This fix for the vlc3 --start-time failure is backported from vlc-git (commit 59ea3e67fbc7ff5a649cc549ec512ffe55d62a51). It seems to work, but the resume times will be different for dvd:// and dvdread:// (this is also the case with vlc-git - if you created a bookmark with a previous vlc version you have to use dvdread:// to get the same place in the DVD with vlc-git).
Code: Select all
diff --git a/modules/access/dvdnav.c b/modules/access/dvdnav.c
index 36638d7680..e8069f3ea4 100644
--- a/modules/access/dvdnav.c
+++ b/modules/access/dvdnav.c
@@ -59,9 +59,12 @@
#include <dvdnav/dvdnav.h>
+/* Expose without patching headers */
+dvdnav_status_t dvdnav_jump_to_sector_by_time(dvdnav_t *, uint64_t, int32_t);
#include "../demux/mpeg/pes.h"
#include "../demux/mpeg/ps.h"
+#include "../demux/timestamps_filter.h"
/*****************************************************************************
* Module descriptor
@@ -586,7 +589,8 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
case DEMUX_GET_TIME:
if( p_sys->i_pgc_length > 0 )
{
- *va_arg( args, int64_t * ) = p_sys->i_pgc_length*pos/len;
+ *va_arg( args, mtime_t * ) =
+ dvdnav_get_current_time( p_sys->dvdnav ) * 100 / 9;
return VLC_SUCCESS;
}
break;
@@ -599,6 +603,16 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
}
break;
}
+
+ case DEMUX_SET_TIME:
+ {
+ mtime_t i_time = va_arg( args, mtime_t );
+ if( dvdnav_jump_to_sector_by_time( p_sys->dvdnav,
+ i_time * 9 / 100,
+ SEEK_SET ) == DVDNAV_STATUS_OK )
+ return VLC_SUCCESS;
+ msg_Err( p_demux, "can't set time to %" PRId64, i_time );
+ }
return VLC_EGENERIC;
}
@@ -1008,7 +1022,7 @@ static int Demux( demux_t *p_demux )
msg_Dbg( p_demux, " - pg_start=%"PRId64, event->pg_start );
/* Store the length in time of the current PGC */
- p_sys->i_pgc_length = event->pgc_length / 90 * 1000;
+ p_sys->i_pgc_length = FROM_SCALE_NZ(event->pgc_length);
p_sys->i_vobu_index = 0;
p_sys->i_vobu_flush = 0;
@@ -1219,14 +1233,14 @@ static void DemuxTitles( demux_t *p_demux )
p_chapters_time = NULL;
}
t = vlc_input_title_New();
- t->i_length = i_title_length * 1000 / 90;
+ t->i_length = FROM_SCALE_NZ(i_title_length);
for( int j = 0; j < __MAX( i_chapters, 1 ); j++ )
{
s = vlc_seekpoint_New();
if( p_chapters_time )
{
if ( j > 0 )
- s->i_time_offset = p_chapters_time[j - 1] * 1000 / 90;
+ s->i_time_offset = FROM_SCALE_NZ(p_chapters_time[j - 1]);
else
s->i_time_offset = 0;
}