comparison dvdread/dvd_reader.c @ 335:0bfe718f75e8 src

#define TITLES_MAX as 9 instead of using an hardcodec value ; patch by Erik Hovland - erik hovland org
author nicodvb
date Sat, 19 Apr 2008 09:34:55 +0000
parents 071927ab5357
children 63aad8298f28
comparison
equal deleted inserted replaced
334:c73a93208d14 335:0bfe718f75e8
86 /* Filesystem cache */ 86 /* Filesystem cache */
87 int udfcache_level; /* 0 - turned off, 1 - on */ 87 int udfcache_level; /* 0 - turned off, 1 - on */
88 void *udfcache; 88 void *udfcache;
89 }; 89 };
90 90
91 #define TITLES_MAX 9
92
91 struct dvd_file_s { 93 struct dvd_file_s {
92 /* Basic information. */ 94 /* Basic information. */
93 dvd_reader_t *dvd; 95 dvd_reader_t *dvd;
94 96
95 /* Hack for selecting the right css title. */ 97 /* Hack for selecting the right css title. */
98 /* Information required for an image file. */ 100 /* Information required for an image file. */
99 uint32_t lb_start; 101 uint32_t lb_start;
100 uint32_t seek_pos; 102 uint32_t seek_pos;
101 103
102 /* Information required for a directory path drive. */ 104 /* Information required for a directory path drive. */
103 size_t title_sizes[ 9 ]; 105 size_t title_sizes[ TITLES_MAX ];
104 dvd_input_t title_devs[ 9 ]; 106 dvd_input_t title_devs[ TITLES_MAX ];
105 107
106 /* Calculated at open-time, size in blocks. */ 108 /* Calculated at open-time, size in blocks. */
107 ssize_t filesize; 109 ssize_t filesize;
108 }; 110 };
109 111
439 if( strlen( path_copy ) > 1 ) { 441 if( strlen( path_copy ) > 1 ) {
440 if( path_copy[ strlen( path_copy ) - 1 ] == '/' ) 442 if( path_copy[ strlen( path_copy ) - 1 ] == '/' )
441 path_copy[ strlen( path_copy ) - 1 ] = '\0'; 443 path_copy[ strlen( path_copy ) - 1 ] = '\0';
442 } 444 }
443 445
444 if( strlen( path_copy ) > 9 ) { 446 if( strlen( path_copy ) > TITLES_MAX ) {
445 if( !strcasecmp( &(path_copy[ strlen( path_copy ) - 9 ]), 447 if( !strcasecmp( &(path_copy[ strlen( path_copy ) - TITLES_MAX ]),
446 "/video_ts" ) ) { 448 "/video_ts" ) ) {
447 path_copy[ strlen( path_copy ) - 9 ] = '\0'; 449 path_copy[ strlen( path_copy ) - TITLES_MAX ] = '\0';
448 } 450 }
449 } 451 }
450 452
451 if(path_copy[0] == '\0') { 453 if(path_copy[0] == '\0') {
452 path_copy[0] = '/'; 454 path_copy[0] = '/';
786 dvd_file->title_devs[ 0 ] = dev; 788 dvd_file->title_devs[ 0 ] = dev;
787 dvdinput_title( dvd_file->title_devs[0], 0); 789 dvdinput_title( dvd_file->title_devs[0], 0);
788 dvd_file->filesize = dvd_file->title_sizes[ 0 ]; 790 dvd_file->filesize = dvd_file->title_sizes[ 0 ];
789 791
790 } else { 792 } else {
791 for( i = 0; i < 9; ++i ) { 793 for( i = 0; i < TITLES_MAX; ++i ) {
792 794
793 sprintf( filename, "VTS_%02i_%i.VOB", title, i + 1 ); 795 sprintf( filename, "VTS_%02i_%i.VOB", title, i + 1 );
794 if( !findDVDFile( dvd, filename, full_path ) ) { 796 if( !findDVDFile( dvd, filename, full_path ) ) {
795 break; 797 break;
796 } 798 }
871 873
872 if( dvd_file ) { 874 if( dvd_file ) {
873 if( dvd_file->dvd->isImageFile ) { 875 if( dvd_file->dvd->isImageFile ) {
874 ; 876 ;
875 } else { 877 } else {
876 for( i = 0; i < 9; ++i ) { 878 for( i = 0; i < TITLES_MAX; ++i ) {
877 if( dvd_file->title_devs[ i ] ) { 879 if( dvd_file->title_devs[ i ] ) {
878 dvdinput_close( dvd_file->title_devs[i] ); 880 dvdinput_close( dvd_file->title_devs[i] );
879 } 881 }
880 } 882 }
881 } 883 }
934 int i; 936 int i;
935 int ret, ret2, off; 937 int ret, ret2, off;
936 938
937 ret = 0; 939 ret = 0;
938 ret2 = 0; 940 ret2 = 0;
939 for( i = 0; i < 9; ++i ) { 941 for( i = 0; i < TITLES_MAX; ++i ) {
940 if( !dvd_file->title_sizes[ i ] ) return 0; /* Past end of file */ 942 if( !dvd_file->title_sizes[ i ] ) return 0; /* Past end of file */
941 943
942 if( offset < dvd_file->title_sizes[ i ] ) { 944 if( offset < dvd_file->title_sizes[ i ] ) {
943 if( ( offset + block_count ) <= dvd_file->title_sizes[ i ] ) { 945 if( ( offset + block_count ) <= dvd_file->title_sizes[ i ] ) {
944 off = dvdinput_seek( dvd_file->title_devs[ i ], (int)offset ); 946 off = dvdinput_seek( dvd_file->title_devs[ i ], (int)offset );