X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faccess%2Fdvdnav.c;h=e808f0e5bec3c686fc2ae055a7a95136a385dd1b;hb=d9e638f1e1cf70d1cdcf8d8d0dd1a5794579298c;hp=17d11288e818d4337c5086410f62fc8f5ec3dd7e;hpb=e5968fa372539b8bb65121faeddc9c0a57c396f1;p=vlc diff --git a/modules/access/dvdnav.c b/modules/access/dvdnav.c index 17d11288e8..e808f0e5be 100644 --- a/modules/access/dvdnav.c +++ b/modules/access/dvdnav.c @@ -30,6 +30,14 @@ #endif #include +#ifdef HAVE_UNISTD_H +# include +#endif +#include +#include +#include +#include + #include #include #include @@ -39,21 +47,7 @@ #include #include #include - #include - -#ifdef HAVE_UNISTD_H -# include -#endif -#include -#ifdef HAVE_SYS_STAT_H -# include -#endif -#ifdef HAVE_FCNTL_H -# include -#endif -#include - #include #include @@ -72,10 +66,6 @@ #define ANGLE_LONGTEXT N_( \ "Default DVD angle." ) -#define CACHING_TEXT N_("Caching value in ms") -#define CACHING_LONGTEXT N_( \ - "Caching value for DVDs. This "\ - "value should be set in milliseconds." ) #define MENU_TEXT N_("Start directly in menu") #define MENU_LONGTEXT N_( \ "Start the DVD directly in the main menu. This "\ @@ -93,8 +83,6 @@ vlc_module_begin () set_subcategory( SUBCAT_INPUT_ACCESS ) add_integer( "dvdnav-angle", 1, ANGLE_TEXT, ANGLE_LONGTEXT, false ) - add_integer( "dvdnav-caching", DEFAULT_PTS_DELAY / 1000, - CACHING_TEXT, CACHING_LONGTEXT, true ) add_bool( "dvdnav-menu", true, MENU_TEXT, MENU_LONGTEXT, false ) set_capability( "access_demux", 5 ) @@ -103,7 +91,11 @@ vlc_module_begin () vlc_module_end () /* Shall we use libdvdnav's read ahead cache? */ +#ifdef __OS2__ +#define DVD_READ_CACHE 0 +#else #define DVD_READ_CACHE 1 +#endif /***************************************************************************** * Local prototypes @@ -355,9 +347,6 @@ static int Open( vlc_object_t *p_this ) i_angle = var_CreateGetInteger( p_demux, "dvdnav-angle" ); if( i_angle <= 0 ) i_angle = 1; - /* Update default_pts to a suitable value for dvdnav access */ - var_Create( p_demux, "dvdnav-caching", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); - /* FIXME hack hack hack hack FIXME */ /* Get p_input and create variable */ p_sys->p_input = demux_GetParentInput( p_demux ); @@ -563,8 +552,8 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) return VLC_SUCCESS; case DEMUX_GET_PTS_DELAY: - *va_arg( args, int64_t * ) - = (int64_t)var_GetInteger( p_demux, "dvdnav-caching" ) *1000; + *va_arg( args, int64_t * ) = + INT64_C(1000) * var_InheritInteger( p_demux, "disc-caching" ); return VLC_SUCCESS; case DEMUX_GET_META: @@ -824,12 +813,17 @@ static int Demux( demux_t *p_demux ) if( dvdnav_current_title_info( p_sys->dvdnav, &i_title, &i_part ) == DVDNAV_STATUS_OK ) { - if( i_title >= 0 && i_title < p_sys->i_title && - i_part >= 1 && i_part <= p_sys->title[i_title]->i_seekpoint && - p_demux->info.i_seekpoint != i_part - 1 ) + if( i_title >= 0 && i_title < p_sys->i_title ) { - p_demux->info.i_update |= INPUT_UPDATE_SEEKPOINT; - p_demux->info.i_seekpoint = i_part - 1; + p_demux->info.i_update |= INPUT_UPDATE_TITLE; + p_demux->info.i_title = i_title; + + if( i_part >= 1 && i_part <= p_sys->title[i_title]->i_seekpoint && + p_demux->info.i_seekpoint != i_part - 1 ) + { + p_demux->info.i_update |= INPUT_UPDATE_SEEKPOINT; + p_demux->info.i_seekpoint = i_part - 1; + } } } break; @@ -946,7 +940,6 @@ static char *DemuxGetLanguageCode( demux_t *p_demux, const char *psz_var ) if( *psz_lang == '\0' ) continue; if( !strcasecmp( pl->psz_eng_name, psz_lang ) || - !strcasecmp( pl->psz_native_name, psz_lang ) || !strcasecmp( pl->psz_iso639_1, psz_lang ) || !strcasecmp( pl->psz_iso639_2T, psz_lang ) || !strcasecmp( pl->psz_iso639_2B, psz_lang ) ) @@ -1010,29 +1003,33 @@ static void DemuxTitles( demux_t *p_demux ) { int32_t i_chapters; uint64_t i_title_length; + uint64_t *p_chapters_time; #if defined(HAVE_DVDNAV_DESCRIBE_TITLE_CHAPTERS) - uint64_t *p_chapters_time; i_chapters = dvdnav_describe_title_chapters( p_sys->dvdnav, i, &p_chapters_time, &i_title_length ); - if( i_chapters > 0 ) - free( p_chapters_time ); - else + if( i_chapters < 1 ) + { i_title_length = 0; + p_chapters_time = NULL; + } #else if( dvdnav_get_number_of_parts( p_sys->dvdnav, i, &i_chapters ) != DVDNAV_STATUS_OK ) i_chapters = 0; i_title_length = 0; + p_chapters_time = NULL; #endif t = vlc_input_title_New(); t->i_length = i_title_length * 1000 / 90; for( int j = 0; j < __MAX( i_chapters, 1 ); j++ ) { s = vlc_seekpoint_New(); + if( p_chapters_time ) + s->i_time_offset = p_chapters_time[j] * 1000 / 90; TAB_APPEND( t->i_seekpoint, t->seekpoint, s ); } - + free( p_chapters_time ); TAB_APPEND( p_sys->i_title, p_sys->title, t ); } } @@ -1457,26 +1454,25 @@ static int ProbeDVD( const char *psz_name ) #endif int ret = VLC_EGENERIC; - -#ifdef HAVE_SYS_STAT_H struct stat stat_info; if( fstat( fd, &stat_info ) == -1 ) goto bailout; - if( !S_ISREG( stat_info.st_mode ) ) { if( S_ISDIR( stat_info.st_mode ) || S_ISBLK( stat_info.st_mode ) ) ret = VLC_SUCCESS; /* Let dvdnav_open() do the probing */ goto bailout; } -#endif + /* Match extension as the anchor exhibits too many false positives */ const char *ext = strrchr( psz_name, '.' ); if( ext == NULL ) goto bailout; ext++; - if( strcasecmp( ext, "iso" ) && strcasecmp( ext, "img" ) ) + if( strcasecmp( ext, "iso" ) && strcasecmp( ext, "img" ) && + strcasecmp( ext, "mdf" ) && strcasecmp( ext, "dvd" ) && + strcasecmp( ext, "bin" ) && strcasecmp( ext, "nrg" ) ) goto bailout; /* Try to find the anchor (2 bytes at LBA 256) */