1 diff -Naur libdvdnav-0.1.10-org/src/dvdnav.c libdvdnav-0.1.10/src/dvdnav.c
2 --- libdvdnav-0.1.10-org/src/dvdnav.c 2004-01-31 18:12:58.000000000 +0100
3 +++ libdvdnav-0.1.10/src/dvdnav.c 2008-03-28 15:24:50.000000000 +0100
5 * You should have received a copy of the GNU General Public License
6 * along with this program; if not, write to the Free Software
7 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
9 - * $Id: dvdnav.c,v 1.63 2004/01/31 17:12:58 jcdutton Exp $
17 /* Create a new structure */
18 - fprintf(MSG_OUT, "libdvdnav: Using dvdnav version %s from http://dvd.sf.net\n", VERSION);
19 + fprintf(MSG_OUT, "libdvdnav: Using dvdnav version %s from http://xine.sf.net\n", VERSION);
22 this = (dvdnav_t*)malloc(sizeof(dvdnav_t));
26 /* converts a dvd_time_t to PTS ticks */
27 -static int64_t dvdnav_convert_time(dvd_time_t *time) {
28 +int64_t dvdnav_convert_time(dvd_time_t *time) {
37 + if (!vm_start(this->vm)) {
38 + printerr("Encrypted or faulty DVD");
39 + return DVDNAV_STATUS_ERR;
45 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE stream_id_wide=%d\n",stream_change->physical_wide);
46 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE stream_id_letterbox=%d\n",stream_change->physical_letterbox);
47 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE stream_id_pan_scan=%d\n",stream_change->physical_pan_scan);
48 + fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE returning DVDNAV_STATUS_OK\n");
50 - if (stream_change->physical_wide != -1 &&
51 - stream_change->physical_letterbox != -1 &&
52 - stream_change->physical_pan_scan != -1) {
54 - fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE returning DVDNAV_STATUS_OK\n");
56 - pthread_mutex_unlock(&this->vm_lock);
57 - return DVDNAV_STATUS_OK;
59 + pthread_mutex_unlock(&this->vm_lock);
60 + return DVDNAV_STATUS_OK;
63 /* has the audio channel changed? */
64 diff -Naur libdvdnav-0.1.10-org/src/dvdnav_events.h libdvdnav-0.1.10/src/dvdnav_events.h
65 --- libdvdnav-0.1.10-org/src/dvdnav_events.h 2003-04-27 03:26:18.000000000 +0200
66 +++ libdvdnav-0.1.10/src/dvdnav_events.h 2008-01-23 06:11:52.000000000 +0100
68 * You should have received a copy of the GNU General Public License
69 * along with this program; if not, write to the Free Software
70 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
72 - * $Id: dvdnav_events.h,v 1.12 2003/04/27 01:26:18 jcdutton Exp $
77 diff -Naur libdvdnav-0.1.10-org/src/dvdnav.h libdvdnav-0.1.10/src/dvdnav.h
78 --- libdvdnav-0.1.10-org/src/dvdnav.h 2003-06-09 17:17:44.000000000 +0200
79 +++ libdvdnav-0.1.10/src/dvdnav.h 2008-01-23 06:11:52.000000000 +0100
81 * You should have received a copy of the GNU General Public License
82 * along with this program; if not, write to the Free Software
83 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
85 - * $Id: dvdnav.h,v 1.31 2003/06/09 15:17:44 mroi Exp $
92 const char* dvdnav_err_to_string(dvdnav_t *self);
94 +/* converts a dvd_time_t to PTS ticks */
95 +int64_t dvdnav_convert_time(dvd_time_t *time);
97 /*********************************************************************
98 * changing and reading DVD player characteristics *
99 diff -Naur libdvdnav-0.1.10-org/src/dvdnav_internal.h libdvdnav-0.1.10/src/dvdnav_internal.h
100 --- libdvdnav-0.1.10-org/src/dvdnav_internal.h 2004-02-13 20:16:17.000000000 +0100
101 +++ libdvdnav-0.1.10/src/dvdnav_internal.h 2008-03-28 15:24:50.000000000 +0100
104 - * Copyright (C) 2001 Rich Wareham <richwareham@users.sourceforge.net>
105 + * Copyright (C) 2001-2004 Rich Wareham <richwareham@users.sourceforge.net>
107 * This file is part of libdvdnav, a DVD navigation library.
110 * You should have received a copy of the GNU General Public License
111 * along with this program; if not, write to the Free Software
112 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
114 - * $Id: dvdnav_internal.h,v 1.12 2004/02/13 19:16:17 mroi Exp $
118 #ifndef DVDNAV_INTERNAL_H_INCLUDED
123 +#ifndef HAVE_GETTIMEOFDAY
125 +# include <winsock.h>
128 +# include <sys/time.h>
130 +/* replacement gettimeofday implementation */
131 +#include <sys/timeb.h>
132 +static inline int dvdnav_private_gettimeofday( struct timeval *tv, void *tz )
136 + tv->tv_sec = t.time;
137 + tv->tv_usec = t.millitm * 1000;
140 +#define gettimeofday(TV, TZ) dvdnav_private_gettimeofday((TV), (TZ))
141 +#define HAVE_GETTIMEOFDAY 1
144 +#ifndef HAVE_SNPRINTF
145 +# ifdef HAVE__SNPRINTF
146 +# define snprintf _snprintf
147 +# define HAVE_SNPRINTF 1
153 /* pthread_mutex_* wrapper for win32 */
155 #define pthread_mutex_unlock(a) LeaveCriticalSection(a)
156 #define pthread_mutex_destroy(a)
158 -/* replacement gettimeofday implementation */
159 -#include <sys/timeb.h>
160 -static inline int gettimeofday( struct timeval *tv, void *tz )
164 - tv->tv_sec = t.time;
165 - tv->tv_usec = t.millitm * 1000;
168 #include <io.h> /* read() */
169 #define lseek64 _lseeki64
171 @@ -184,15 +199,38 @@
173 /** USEFUL MACROS **/
175 +/* printerr*() are often called when this is NULL. Avoid segfaults by replacing these with
176 + * more common prints
179 -#define printerrf(format, args...) snprintf(this->err_str, MAX_ERR_LEN, format, ## args);
180 +#define printerrf(format, args...) \
182 + if ( ! this ) fprintf(stderr, "Missing 'this' pointer while erroring:" format "\n", ## args); \
183 + else snprintf(this->err_str, MAX_ERR_LEN, format, ## args); \
187 #define printerrf(str) snprintf(this->err_str, MAX_ERR_LEN, str);
189 -#define printerrf(...) snprintf(this->err_str, MAX_ERR_LEN, __VA_ARGS__);
190 +#define printerrf(...) \
193 + fprintf(stderr, "Missing 'this' pointer while erroring:"); \
194 + fprintf(stderr, __VA_ARGS__); \
195 + fprintf(stderr, "\n"); \
197 + snprintf(this->err_str, MAX_ERR_LEN, __VA_ARGS__); \
202 -#define printerr(str) strncpy(this->err_str, str, MAX_ERR_LEN);
203 +#define printerr(str) \
206 + fprintf(stderr, "Missing 'this' pointer while erroring: %s\n", str); \
208 + strncpy(this->err_str, str, MAX_ERR_LEN); \
212 #endif /* DVDNAV_INTERNAL_H_INCLUDED */
213 diff -Naur libdvdnav-0.1.10-org/src/dvdread/bswap.h libdvdnav-0.1.10/src/dvdread/bswap.h
214 --- libdvdnav-0.1.10-org/src/dvdread/bswap.h 2004-01-11 22:43:13.000000000 +0100
215 +++ libdvdnav-0.1.10/src/dvdread/bswap.h 2008-01-23 06:11:52.000000000 +0100
219 * Copyright (C) 2000, 2001 Billy Biggs <vektor@dumbterm.net>,
220 - * Håkan Hjort <d95hjort@dtek.chalmers.se>
221 + * Håkan Hjort <d95hjort@dtek.chalmers.se>
223 * This program is free software; you can redistribute it and/or modify
224 * it under the terms of the GNU General Public License as published by
226 #include <sys/param.h>
229 -#if defined(__linux__)
230 +#if defined(__linux__) || defined(__GLIBC__)
231 #include <byteswap.h>
232 #define B2N_16(x) x = bswap_16(x)
233 #define B2N_32(x) x = bswap_32(x)
234 #define B2N_64(x) x = bswap_64(x)
236 +#elif defined(__SVR4) && defined(__sun)
237 +#include <sys/byteorder.h>
238 +#define B2N_16(x) x = BSWAP_16(x)
239 +#define B2N_32(x) x = BSWAP_32(x)
240 +#define B2N_64(x) x = BSWAP_64(x)
242 +#elif defined(__APPLE__)
243 +#include <libkern/OSByteOrder.h>
244 +#define B2N_16(x) x = OSSwapBigToHostInt16(x)
245 +#define B2N_32(x) x = OSSwapBigToHostInt32(x)
246 +#define B2N_64(x) x = OSSwapBigToHostInt64(x)
248 #elif defined(__NetBSD__)
249 #include <sys/endian.h>
250 #define B2N_16(x) BE16TOH(x)
253 /* This is a slow but portable implementation, it has multiple evaluation
254 * problems so beware.
255 - * Old FreeBSD's and Solaris don't have <byteswap.h> or any other such
256 + * Old FreeBSD and Windows don't have <byteswap.h> or any other such
260 -#elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) || defined(WIN32) || defined(__CYGWIN__)
261 +#elif defined(__FreeBSD__) || defined(__bsdi__) || defined(WIN32) || defined(__CYGWIN__)
263 x = ((((x) & 0xff00) >> 8) | \
264 (((x) & 0x00ff) << 8))
265 diff -Naur libdvdnav-0.1.10-org/src/dvdread/dvd_input.c libdvdnav-0.1.10/src/dvdread/dvd_input.c
266 --- libdvdnav-0.1.10-org/src/dvdread/dvd_input.c 2004-04-09 14:15:26.000000000 +0200
267 +++ libdvdnav-0.1.10/src/dvdread/dvd_input.c 2008-01-23 06:11:52.000000000 +0100
270 * Copyright (C) 2002 Samuel Hocevar <sam@zoy.org>,
271 - * Håkan Hjort <d95hjort@dtek.chalmers.se>
272 + * Håkan Hjort <d95hjort@dtek.chalmers.se>
274 * This program is free software; you can redistribute it and/or modify
275 * it under the terms of the GNU General Public License as published by
277 int (*dvdinput_title) (dvd_input_t, int);
278 int (*dvdinput_read) (dvd_input_t, void *, int, int);
279 char * (*dvdinput_error) (dvd_input_t);
280 +int (*dvdinput_is_encrypted) (dvd_input_t);
282 #ifdef HAVE_DVDCSS_DVDCSS_H
283 /* linking to libdvdcss */
285 #include "../../msvc/contrib/dlfcn.c"
288 +/* Copied from css.h */
291 +typedef uint8_t dvd_key_t[KEY_SIZE];
293 +typedef struct dvd_title_s
297 + struct dvd_title_s *p_next;
300 +typedef struct css_s
302 + int i_agid; /* Current Authenication Grant ID. */
303 + dvd_key_t p_bus_key; /* Current session key. */
304 + dvd_key_t p_disc_key; /* This DVD disc's key. */
305 + dvd_key_t p_title_key; /* Current title key. */
308 +/* Copied from libdvdcss.h */
311 +#define PATH_MAX 4096
316 + /* File descriptor */
322 + /* File handling */
327 + /* Decryption stuff */
332 + dvd_title_t *p_titles;
334 + /* Key cache directory and pointer to the filename */
335 + char psz_cachefile[PATH_MAX];
338 + /* Error management */
345 + char * p_readv_buffer;
346 + int i_readv_buf_size;
355 typedef struct dvdcss_s *dvdcss_handle;
356 static dvdcss_handle (*DVDcss_open) (const char *);
357 static int (*DVDcss_close) (dvdcss_handle);
364 +static int css_is_encrypted (dvd_input_t dev)
366 + if (dev->dvdcss == NULL) {
369 + return dev->dvdcss->b_scrambled;
378 +static int file_is_encrypted (dvd_input_t dev)
384 * Setup read functions with either libdvdcss or minimal DVD access.
385 @@ -287,10 +364,12 @@
387 /* dlopening libdvdcss */
390 - dvdcss_library = dlopen("libdvdcss.so.2", RTLD_LAZY);
392 +#ifdef HOST_OS_DARWIN
393 + dvdcss_library = dlopen("libdvdcss.2.dylib", RTLD_LAZY);
394 +#elif defined(WIN32)
395 dvdcss_library = dlopen("libdvdcss.dll", RTLD_LAZY);
397 + dvdcss_library = dlopen("libdvdcss.so.2", RTLD_LAZY);
400 if(dvdcss_library != NULL) {
402 dvdcss_library = NULL;
403 } else if(!DVDcss_open || !DVDcss_close || !DVDcss_title || !DVDcss_seek
404 || !DVDcss_read || !DVDcss_error || !dvdcss_version) {
405 - fprintf(stderr, "libdvdread: Missing symbols in libdvdcss.so.2, "
406 + fprintf(stderr, "libdvdread: Missing symbols in libdvdcss, "
407 "this shouldn't happen !\n");
408 dlclose(dvdcss_library);
411 dvdinput_title = css_title;
412 dvdinput_read = css_read;
413 dvdinput_error = css_error;
414 + dvdinput_is_encrypted = css_is_encrypted;
419 dvdinput_title = file_title;
420 dvdinput_read = file_read;
421 dvdinput_error = file_error;
422 + dvdinput_is_encrypted = file_is_encrypted;
426 diff -Naur libdvdnav-0.1.10-org/src/dvdread/dvd_input.h libdvdnav-0.1.10/src/dvdread/dvd_input.h
427 --- libdvdnav-0.1.10-org/src/dvdread/dvd_input.h 2004-01-11 22:43:13.000000000 +0100
428 +++ libdvdnav-0.1.10/src/dvdread/dvd_input.h 2008-01-23 06:11:52.000000000 +0100
432 * Copyright (C) 2001, 2002 Samuel Hocevar <sam@zoy.org>,
433 - * Håkan Hjort <d95hjort@dtek.chalmers.se>
434 + * Håkan Hjort <d95hjort@dtek.chalmers.se>
436 * This program is free software; you can redistribute it and/or modify
437 * it under the terms of the GNU General Public License as published by
439 extern int (*dvdinput_title) (dvd_input_t, int);
440 extern int (*dvdinput_read) (dvd_input_t, void *, int, int);
441 extern char * (*dvdinput_error) (dvd_input_t);
442 +extern int (*dvdinput_is_encrypted) (dvd_input_t);
445 * Setup function accessed by dvd_reader.c. Returns 1 if there is CSS support.
446 diff -Naur libdvdnav-0.1.10-org/src/dvdread/dvd_reader.c libdvdnav-0.1.10/src/dvdread/dvd_reader.c
447 --- libdvdnav-0.1.10-org/src/dvdread/dvd_reader.c 2004-03-03 17:48:36.000000000 +0100
448 +++ libdvdnav-0.1.10/src/dvdread/dvd_reader.c 2008-03-17 17:18:01.000000000 +0100
451 - * Copyright (C) 2001, 2002, 2003 Billy Biggs <vektor@dumbterm.net>,
452 - * Håkan Hjort <d95hjort@dtek.chalmers.se>,
453 - * Björn Englund <d4bjorn@dtek.chalmers.se>
454 + * Copyright (C) 2001-2004 Billy Biggs <vektor@dumbterm.net>,
455 + * Håkan Hjort <d95hjort@dtek.chalmers.se>,
456 + * Björn Englund <d4bjorn@dtek.chalmers.se>
458 * This program is free software; you can redistribute it and/or modify
459 * it under the terms of the GNU General Public License as published by
464 -/* misc win32 helpers */
466 +#ifndef HAVE_GETTIMEOFDAY
468 +# include <winsock.h>
471 +# include <sys/time.h>
473 /* replacement gettimeofday implementation */
474 #include <sys/timeb.h>
475 -static inline int gettimeofday( struct timeval *tv, void *tz )
476 +static inline int _private_gettimeofday( struct timeval *tv, void *tz )
481 tv->tv_usec = t.millitm * 1000;
484 +#define gettimeofday(TV, TZ) _private_gettimeofday((TV), (TZ))
487 +/* misc win32 helpers */
489 #include <io.h> /* read() */
490 #define lseek64 _lseeki64
493 -#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__bsdi__)|| defined(__DARWIN__)
494 +#if defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__bsdi__)|| defined(__DARWIN__)
501 auth_drive = DVDOpenImageFile( me->mnt_fsname, have_css );
502 + /* If the device is not encrypted, don't access the device
503 + * directly as it would fail for non-UDF DVDs */
504 + if ( auth_drive && dvdinput_is_encrypted( auth_drive->dev ) == 0) {
505 + DVDClose( auth_drive );
509 dev_name = strdup(me->mnt_fsname);
512 @@ -585,10 +603,12 @@
513 sprintf( filename, "%s%s%s", path,
514 ( ( path[ strlen( path ) - 1 ] == '/' ) ? "" : "/" ),
525 @@ -1017,6 +1037,28 @@
529 +int32_t DVDFileSeekForce( dvd_file_t *dvd_file, int offset, int force_size )
531 + /* Check arguments. */
532 + if( dvd_file == NULL || offset < 0 )
535 + if( dvd_file->dvd->isImageFile ) {
536 + if( force_size < 0 )
537 + force_size = (offset - 1) / DVD_VIDEO_LB_LEN + 1;
538 + if( dvd_file->filesize < force_size) {
539 + dvd_file->filesize = force_size;
540 + fprintf(stderr, "libdvdread: Ignored UDF provided size of file.\n");
544 + if( offset > dvd_file->filesize * DVD_VIDEO_LB_LEN ) {
547 + dvd_file->seek_pos = (uint32_t) offset;
551 ssize_t DVDReadBytes( dvd_file_t *dvd_file, void *data, size_t byte_size )
553 unsigned char *secbuf_base, *secbuf;
554 @@ -1057,7 +1099,7 @@
555 memcpy( data, &(secbuf[ seek_byte ]), byte_size );
558 - dvd_file->seek_pos += byte_size;
559 + DVDFileSeekForce(dvd_file, dvd_file->seek_pos + byte_size, -1);
563 diff -Naur libdvdnav-0.1.10-org/src/dvdread/dvd_reader.h libdvdnav-0.1.10/src/dvdread/dvd_reader.h
564 --- libdvdnav-0.1.10-org/src/dvdread/dvd_reader.h 2004-02-01 18:55:19.000000000 +0100
565 +++ libdvdnav-0.1.10/src/dvdread/dvd_reader.h 2008-03-28 15:24:50.000000000 +0100
569 * Copyright (C) 2001, 2002 Billy Biggs <vektor@dumbterm.net>,
570 - * Håkan Hjort <d95hjort@dtek.chalmers.se>,
571 - * Björn Englund <d4bjorn@dtek.chalmers.se>
572 + * Håkan Hjort <d95hjort@dtek.chalmers.se>,
573 + * Björn Englund <d4bjorn@dtek.chalmers.se>
575 * This program is free software; you can redistribute it and/or modify
576 * it under the terms of the GNU General Public License as published by
578 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
582 +#ifdef HAVE_CONFIG_H
592 int32_t DVDFileSeek( dvd_file_t *, int32_t );
594 +int32_t DVDFileSeekForce( dvd_file_t *, int, int );
597 * Reads the given number of bytes from the file. This call can only be used
598 * on the information files, and may not be used for reading from a VOB. This
599 diff -Naur libdvdnav-0.1.10-org/src/dvdread/dvd_udf.c libdvdnav-0.1.10/src/dvdread/dvd_udf.c
600 --- libdvdnav-0.1.10-org/src/dvdread/dvd_udf.c 2004-03-03 17:48:36.000000000 +0100
601 +++ libdvdnav-0.1.10/src/dvdread/dvd_udf.c 2008-03-07 15:19:43.000000000 +0100
605 * Billy Biggs <vektor@dumbterm.net>.
606 - * Björn Englund <d4bjorn@dtek.chalmers.se>.
607 + * Björn Englund <d4bjorn@dtek.chalmers.se>.
609 * dvdudf: parse and read the UDF volume information of a DVD Video
610 * Copyright (C) 1999 Christian Wolff for convergence integrated media
611 diff -Naur libdvdnav-0.1.10-org/src/dvdread/dvd_udf.h libdvdnav-0.1.10/src/dvdread/dvd_udf.h
612 --- libdvdnav-0.1.10-org/src/dvdread/dvd_udf.h 2004-01-11 22:43:13.000000000 +0100
613 +++ libdvdnav-0.1.10/src/dvdread/dvd_udf.h 2008-01-23 06:11:52.000000000 +0100
617 * Billy Biggs <vektor@dumbterm.net>.
618 - * Björn Englund <d4bjorn@dtek.chalmers.se>.
619 + * Björn Englund <d4bjorn@dtek.chalmers.se>.
621 * dvdudf: parse and read the UDF volume information of a DVD Video
622 * Copyright (C) 1999 Christian Wolff for convergence integrated media
623 diff -Naur libdvdnav-0.1.10-org/src/dvdread/ifo_read.c libdvdnav-0.1.10/src/dvdread/ifo_read.c
624 --- libdvdnav-0.1.10-org/src/dvdread/ifo_read.c 2004-02-23 19:14:42.000000000 +0100
625 +++ libdvdnav-0.1.10/src/dvdread/ifo_read.c 2008-03-17 17:18:01.000000000 +0100
628 * Copyright (C) 2000, 2001, 2002, 2003
629 - * Björn Englund <d4bjorn@dtek.chalmers.se>,
630 - * Håkan Hjort <d95hjort@dtek.chalmers.se>
631 + * Björn Englund <d4bjorn@dtek.chalmers.se>,
632 + * Håkan Hjort <d95hjort@dtek.chalmers.se>
634 * This program is free software; you can redistribute it and/or modify
635 * it under the terms of the GNU General Public License as published by
637 return (DVDFileSeek(dvd_file, (int)offset) == (int)offset);
640 +static inline int32_t DVDFileSeekForce_( dvd_file_t *dvd_file, uint32_t offset, int force_size ) {
641 + return (DVDFileSeekForce(dvd_file, (int)offset, force_size) == (int)offset);
645 ifo_handle_t *ifoOpen(dvd_reader_t *dvd, int title) {
646 ifo_handle_t *ifofile;
648 pgc->command_tbl = NULL;
651 - if(pgc->program_map_offset != 0) {
652 + if(pgc->program_map_offset != 0 && pgc->nr_of_programs>0) {
653 pgc->program_map = malloc(pgc->nr_of_programs * sizeof(pgc_program_map_t));
654 if(!pgc->program_map) {
655 ifoFree_PGC_COMMAND_TBL(pgc->command_tbl);
657 pgc->program_map = NULL;
660 - if(pgc->cell_playback_offset != 0) {
661 + if(pgc->cell_playback_offset != 0 && pgc->nr_of_cells>0) {
662 pgc->cell_playback = malloc(pgc->nr_of_cells * sizeof(cell_playback_t));
663 if(!pgc->cell_playback) {
664 ifoFree_PGC_COMMAND_TBL(pgc->command_tbl);
666 pgc->cell_playback = NULL;
669 - if(pgc->cell_position_offset != 0) {
670 + if(pgc->cell_position_offset != 0 && pgc->nr_of_cells>0) {
671 pgc->cell_position = malloc(pgc->nr_of_cells * sizeof(cell_position_t));
672 if(!pgc->cell_position) {
674 @@ -1507,7 +1511,7 @@
678 - if(!DVDFileSeek_(ifofile->file, sector * DVD_BLOCK_LEN))
679 + if(!DVDFileSeekForce_(ifofile->file, sector * DVD_BLOCK_LEN, sector))
682 if(!(DVDReadBytes(ifofile->file, vobu_admap, VOBU_ADMAP_SIZE)))
683 diff -Naur libdvdnav-0.1.10-org/src/dvdread/ifo_read.h libdvdnav-0.1.10/src/dvdread/ifo_read.h
684 --- libdvdnav-0.1.10-org/src/dvdread/ifo_read.h 2004-01-11 22:43:13.000000000 +0100
685 +++ libdvdnav-0.1.10/src/dvdread/ifo_read.h 2008-01-23 06:11:52.000000000 +0100
687 #define IFO_READ_H_INCLUDED
690 - * Copyright (C) 2000, 2001, 2002 Björn Englund <d4bjorn@dtek.chalmers.se>,
691 - * Håkan Hjort <d95hjort@dtek.chalmers.se>
692 + * Copyright (C) 2000, 2001, 2002 Björn Englund <d4bjorn@dtek.chalmers.se>,
693 + * Håkan Hjort <d95hjort@dtek.chalmers.se>
695 * This program is free software; you can redistribute it and/or modify
696 * it under the terms of the GNU General Public License as published by
697 diff -Naur libdvdnav-0.1.10-org/src/dvdread/ifo_types.h libdvdnav-0.1.10/src/dvdread/ifo_types.h
698 --- libdvdnav-0.1.10-org/src/dvdread/ifo_types.h 2004-01-11 22:43:13.000000000 +0100
699 +++ libdvdnav-0.1.10/src/dvdread/ifo_types.h 2008-01-23 06:11:52.000000000 +0100
701 #define IFO_TYPES_H_INCLUDED
704 - * Copyright (C) 2000, 2001 Björn Englund <d4bjorn@dtek.chalmers.se>,
705 - * Håkan Hjort <d95hjort@dtek.chalmers.se>
706 + * Copyright (C) 2000, 2001 Björn Englund <d4bjorn@dtek.chalmers.se>,
707 + * Håkan Hjort <d95hjort@dtek.chalmers.se>
709 * This program is free software; you can redistribute it and/or modify
710 * it under the terms of the GNU General Public License as published by
711 diff -Naur libdvdnav-0.1.10-org/src/dvdread/md5.c libdvdnav-0.1.10/src/dvdread/md5.c
712 --- libdvdnav-0.1.10-org/src/dvdread/md5.c 2004-01-11 22:43:13.000000000 +0100
713 +++ libdvdnav-0.1.10/src/dvdread/md5.c 2008-03-28 15:24:50.000000000 +0100
716 #include <sys/types.h>
718 -#if STDC_HEADERS || defined _LIBC
719 -# include <stdlib.h>
720 -# include <string.h>
722 -# ifndef HAVE_MEMCPY
723 -# define memcpy(d, s, n) bcopy ((s), (d), (n))
730 /* #include "unlocked-io.h" */
731 diff -Naur libdvdnav-0.1.10-org/src/dvdread/nav_print.c libdvdnav-0.1.10/src/dvdread/nav_print.c
732 --- libdvdnav-0.1.10-org/src/dvdread/nav_print.c 2004-01-11 22:43:13.000000000 +0100
733 +++ libdvdnav-0.1.10/src/dvdread/nav_print.c 2008-01-23 06:11:52.000000000 +0100
736 - * Copyright (C) 2000, 2001, 2002, 2003 Håkan Hjort <d95hjort@dtek.chalmers.se>
737 + * Copyright (C) 2000, 2001, 2002, 2003 Håkan Hjort <d95hjort@dtek.chalmers.se>
739 * Much of the contents in this file is based on VOBDUMP.
743 printf("nv_pck_lbn 0x%08x\n", pci_gi->nv_pck_lbn);
744 printf("vobu_cat 0x%04x\n", pci_gi->vobu_cat);
745 - printf("vobu_uop_ctl 0x%08x\n", *(uint32_t*)&pci_gi->vobu_uop_ctl);
746 +/* This will break strict aliasing, better avoid as this seems to be useless
747 + printf("vobu_uop_ctl 0x%08x\n", *(uint32_t*)&pci_gi->vobu_uop_ctl); */
748 printf("vobu_s_ptm 0x%08x\n", pci_gi->vobu_s_ptm);
749 printf("vobu_e_ptm 0x%08x\n", pci_gi->vobu_e_ptm);
750 printf("vobu_se_e_ptm 0x%08x\n", pci_gi->vobu_se_e_ptm);
751 diff -Naur libdvdnav-0.1.10-org/src/dvdread/nav_print.h libdvdnav-0.1.10/src/dvdread/nav_print.h
752 --- libdvdnav-0.1.10-org/src/dvdread/nav_print.h 2004-01-11 22:43:13.000000000 +0100
753 +++ libdvdnav-0.1.10/src/dvdread/nav_print.h 2008-01-23 06:11:52.000000000 +0100
757 * Copyright (C) 2001, 2002 Billy Biggs <vektor@dumbterm.net>,
758 - * Håkan Hjort <d95hjort@dtek.chalmers.se>
759 + * Håkan Hjort <d95hjort@dtek.chalmers.se>
761 * This program is free software; you can redistribute it and/or modify
762 * it under the terms of the GNU General Public License as published by
763 diff -Naur libdvdnav-0.1.10-org/src/dvdread/nav_read.c libdvdnav-0.1.10/src/dvdread/nav_read.c
764 --- libdvdnav-0.1.10-org/src/dvdread/nav_read.c 2004-03-03 17:50:41.000000000 +0100
765 +++ libdvdnav-0.1.10/src/dvdread/nav_read.c 2008-01-23 06:11:52.000000000 +0100
768 - * Copyright (C) 2000, 2001, 2002, 2003 Håkan Hjort <d95hjort@dtek.chalmers.se>
769 + * Copyright (C) 2000, 2001, 2002, 2003 Håkan Hjort <d95hjort@dtek.chalmers.se>
771 * This program is free software; you can redistribute it and/or modify
772 * it under the terms of the GNU General Public License as published by
773 diff -Naur libdvdnav-0.1.10-org/src/dvdread/nav_read.h libdvdnav-0.1.10/src/dvdread/nav_read.h
774 --- libdvdnav-0.1.10-org/src/dvdread/nav_read.h 2004-01-11 22:43:13.000000000 +0100
775 +++ libdvdnav-0.1.10/src/dvdread/nav_read.h 2008-01-23 06:11:52.000000000 +0100
777 #define NAV_READ_H_INCLUDED
780 - * Copyright (C) 2000, 2001, 2002 Håkan Hjort <d95hjort@dtek.chalmers.se>.
781 + * Copyright (C) 2000, 2001, 2002 Håkan Hjort <d95hjort@dtek.chalmers.se>.
783 * This program is free software; you can redistribute it and/or modify
784 * it under the terms of the GNU General Public License as published by
785 diff -Naur libdvdnav-0.1.10-org/src/dvdread/nav_types.h libdvdnav-0.1.10/src/dvdread/nav_types.h
786 --- libdvdnav-0.1.10-org/src/dvdread/nav_types.h 2004-01-11 22:43:13.000000000 +0100
787 +++ libdvdnav-0.1.10/src/dvdread/nav_types.h 2008-01-23 06:11:52.000000000 +0100
789 #define NAV_TYPES_H_INCLUDED
792 - * Copyright (C) 2000, 2001, 2002 Håkan Hjort <d95hjort@dtek.chalmers.se>
793 + * Copyright (C) 2000, 2001, 2002 Håkan Hjort <d95hjort@dtek.chalmers.se>
795 * The data structures in this file should represent the layout of the
796 * pci and dsi packets as they are stored in the stream. Information
797 diff -Naur libdvdnav-0.1.10-org/src/dvd_types.h libdvdnav-0.1.10/src/dvd_types.h
798 --- libdvdnav-0.1.10-org/src/dvd_types.h 2003-04-21 15:18:06.000000000 +0200
799 +++ libdvdnav-0.1.10/src/dvd_types.h 2008-01-23 06:11:52.000000000 +0100
802 - * Copyright (C) 2000, 2001 Björn Englund, Håkan Hjort
803 + * Copyright (C) 2000, 2001 Björn Englund, Håkan Hjort
805 * This file is part of libdvdnav, a DVD navigation library. It is a modified
806 * file originally part of the Ogle DVD player project.
808 * You should have received a copy of the GNU General Public License
809 * along with this program; if not, write to the Free Software
810 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
812 - * $Id: dvd_types.h,v 1.7 2003/04/21 13:18:06 mroi Exp $
817 diff -Naur libdvdnav-0.1.10-org/src/highlight.c libdvdnav-0.1.10/src/highlight.c
818 --- libdvdnav-0.1.10-org/src/highlight.c 2004-01-20 02:22:24.000000000 +0100
819 +++ libdvdnav-0.1.10/src/highlight.c 2008-03-28 15:24:50.000000000 +0100
821 * You should have received a copy of the GNU General Public License
822 * along with this program; if not, write to the Free Software
823 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
825 - * $Id: highlight.c,v 1.32 2004/01/20 01:22:24 jcdutton Exp $
830 diff -Naur libdvdnav-0.1.10-org/src/navigation.c libdvdnav-0.1.10/src/navigation.c
831 --- libdvdnav-0.1.10-org/src/navigation.c 2004-01-07 20:34:28.000000000 +0100
832 +++ libdvdnav-0.1.10/src/navigation.c 2008-03-28 15:24:50.000000000 +0100
834 * You should have received a copy of the GNU General Public License
835 * along with this program; if not, write to the Free Software
836 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
838 - * $Id: navigation.c,v 1.21 2004/01/07 19:34:28 mroi Exp $
844 printerr("Passed a NULL pointer.");
845 return DVDNAV_STATUS_ERR;
847 - if(!this->started) {
848 - printerr("Virtual DVD machine not started.");
849 + if (!this->vm->vmgi) {
850 + printerr("Bad VM state.");
851 return DVDNAV_STATUS_ERR;
855 printerr("Passed a NULL pointer.");
856 return DVDNAV_STATUS_ERR;
858 - if(!this->started) {
859 - printerr("Virtual DVD machine not started.");
860 + if (!this->vm->vmgi) {
861 + printerr("Bad VM state.");
862 return DVDNAV_STATUS_ERR;
864 if ((title < 1) || (title > vm_get_vmgi(this->vm)->tt_srpt->nr_of_srpts) ) {
866 pthread_mutex_unlock(&this->vm_lock);
867 return DVDNAV_STATUS_ERR;
869 + if (!this->started) {
870 + printerr("Virtual DVD machine not started.");
871 + pthread_mutex_unlock(&this->vm_lock);
872 + return DVDNAV_STATUS_ERR;
874 if (!this->vm->state.pgc) {
875 printerr("No current PGC.");
876 pthread_mutex_unlock(&this->vm_lock);
878 pthread_mutex_unlock(&this->vm_lock);
879 return DVDNAV_STATUS_ERR;
881 + if (!this->started) {
882 + /* don't report an error but be nice */
883 + vm_start(this->vm);
886 if (!this->vm->state.pgc) {
887 printerr("No current PGC.");
888 pthread_mutex_unlock(&this->vm_lock);
889 diff -Naur libdvdnav-0.1.10-org/src/read_cache.c libdvdnav-0.1.10/src/read_cache.c
890 --- libdvdnav-0.1.10-org/src/read_cache.c 2004-03-03 17:48:36.000000000 +0100
891 +++ libdvdnav-0.1.10/src/read_cache.c 2008-03-28 15:24:50.000000000 +0100
893 * You should have received a copy of the GNU General Public License
894 * along with this program; if not, write to the Free Software
895 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
897 - * $Id: read_cache.c,v 1.30 2004/03/03 16:48:36 mroi Exp $
901 * There was a multithreaded read ahead cache in here for some time, but
902 diff -Naur libdvdnav-0.1.10-org/src/read_cache.h libdvdnav-0.1.10/src/read_cache.h
903 --- libdvdnav-0.1.10-org/src/read_cache.h 2002-07-12 17:46:44.000000000 +0200
904 +++ libdvdnav-0.1.10/src/read_cache.h 2008-01-23 06:11:52.000000000 +0100
906 * You should have received a copy of the GNU General Public License
907 * along with this program; if not, write to the Free Software
908 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
910 - * $Id: read_cache.h,v 1.4 2002/07/12 15:46:44 mroi Exp $
914 #ifndef __DVDNAV_READ_CACHE_H
915 diff -Naur libdvdnav-0.1.10-org/src/remap.c libdvdnav-0.1.10/src/remap.c
916 --- libdvdnav-0.1.10-org/src/remap.c 2003-08-27 15:54:19.000000000 +0200
917 +++ libdvdnav-0.1.10/src/remap.c 2008-03-07 15:19:43.000000000 +0100
919 * You should have received a copy of the GNU General Public License
920 * along with this program; if not, write to the Free Software
921 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
923 - * $Id: remap.c,v 1.4 2003/08/27 13:54:19 mroi Exp $
931 +#ifdef HAVE_SYS_PARAM_H
932 #include <sys/param.h>
935 +#ifdef HAVE_SYS_FCNTL_H
936 #include <sys/fcntl.h>
939 #define MAXPATHLEN 255
941 -#endif /* _MSC_VER */
942 +#endif /* HAVE fcntl.h */
948 /* Build the map filename */
949 home = getenv("HOME"); assert(home);
950 - strncpy(fname, home, sizeof(fname));
951 - strncat(fname, "/.dvdnav/", sizeof(fname));
952 - strncat(fname, title, sizeof(fname));
953 - strncat(fname, ".map", sizeof(fname));
954 + snprintf (fname, sizeof(fname), "%s/.dvdnav/%s.map", home, title);
956 /* Open the map file */
957 fp = fopen( fname, "r");
958 diff -Naur libdvdnav-0.1.10-org/src/remap.h libdvdnav-0.1.10/src/remap.h
959 --- libdvdnav-0.1.10-org/src/remap.h 2003-02-20 16:32:19.000000000 +0100
960 +++ libdvdnav-0.1.10/src/remap.h 2008-01-23 06:11:52.000000000 +0100
962 * You should have received a copy of the GNU General Public License
963 * along with this program; if not, write to the Free Software
964 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
966 - * $Id: remap.h,v 1.2 2003/02/20 15:32:19 mroi Exp $
970 diff -Naur libdvdnav-0.1.10-org/src/searching.c libdvdnav-0.1.10/src/searching.c
971 --- libdvdnav-0.1.10-org/src/searching.c 2004-01-07 20:35:12.000000000 +0100
972 +++ libdvdnav-0.1.10/src/searching.c 2008-03-28 15:24:50.000000000 +0100
974 * You should have received a copy of the GNU General Public License
975 * along with this program; if not, write to the Free Software
976 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
978 - * $Id: searching.c,v 1.35 2004/01/07 19:35:12 mroi Exp $
986 #include "dvdnav_internal.h"
993 /* Searching API calls */
995 -dvdnav_status_t dvdnav_time_search(dvdnav_t *this,
997 - /* FIXME: Time search the current PGC based on the xxx table */
998 - return DVDNAV_STATUS_OK;
1001 /* Scan the ADMAP for a particular block number. */
1002 /* Return placed in vobu. */
1003 /* Returns error status */
1005 return DVDNAV_STATUS_ERR;
1008 +dvdnav_status_t dvdnav_time_search(dvdnav_t *this,
1011 + uint64_t target = time;
1012 + uint64_t length = 0;
1013 + uint32_t first_cell_nr, last_cell_nr, cell_nr;
1015 + cell_playback_t *cell;
1016 + dvd_state_t *state;
1018 + if(this->position_current.still != 0) {
1019 + printerr("Cannot seek in a still frame.");
1020 + return DVDNAV_STATUS_ERR;
1023 + pthread_mutex_lock(&this->vm_lock);
1024 + state = &(this->vm->state);
1026 + printerr("No current PGC.");
1027 + pthread_mutex_unlock(&this->vm_lock);
1028 + return DVDNAV_STATUS_ERR;
1032 + if (this->pgc_based) {
1033 + first_cell_nr = 1;
1034 + last_cell_nr = state->pgc->nr_of_cells;
1036 + /* Find start cell of program. */
1037 + first_cell_nr = state->pgc->program_map[state->pgN-1];
1038 + /* Find end cell of program */
1039 + if(state->pgN < state->pgc->nr_of_programs)
1040 + last_cell_nr = state->pgc->program_map[state->pgN] - 1;
1042 + last_cell_nr = state->pgc->nr_of_cells;
1046 + for(cell_nr = first_cell_nr; (cell_nr <= last_cell_nr) && !found; cell_nr ++) {
1047 + cell = &(state->pgc->cell_playback[cell_nr-1]);
1048 + length = dvdnav_convert_time(&cell->playback_time);
1049 + if (target >= length) {
1052 + /* FIXME: there must be a better way than interpolation */
1053 + target = target * (cell->last_sector - cell->first_sector + 1) / length;
1054 + target += cell->first_sector;
1064 + fprintf(MSG_OUT, "libdvdnav: Seeking to cell %i from choice of %i to %i\n",
1065 + cell_nr, first_cell_nr, last_cell_nr);
1067 + if (dvdnav_scan_admap(this, state->domain, target, &vobu) == DVDNAV_STATUS_OK) {
1068 + int32_t start = state->pgc->cell_playback[cell_nr-1].first_sector;
1070 + if (vm_jump_cell_block(this->vm, cell_nr, vobu - start)) {
1072 + fprintf(MSG_OUT, "libdvdnav: After cellN=%u blockN=%u target=%x vobu=%x start=%x\n" ,
1073 + state->cellN, state->blockN, target, vobu, start);
1075 + this->vm->hop_channel += HOP_SEEK;
1076 + pthread_mutex_unlock(&this->vm_lock);
1077 + return DVDNAV_STATUS_OK;
1082 + fprintf(MSG_OUT, "libdvdnav: Error when seeking\n");
1083 + printerr("Error when seeking.");
1084 + pthread_mutex_unlock(&this->vm_lock);
1085 + return DVDNAV_STATUS_ERR;
1088 dvdnav_status_t dvdnav_sector_search(dvdnav_t *this,
1089 uint64_t offset, int32_t origin) {
1090 uint32_t target = 0;
1091 diff -Naur libdvdnav-0.1.10-org/src/settings.c libdvdnav-0.1.10/src/settings.c
1092 --- libdvdnav-0.1.10-org/src/settings.c 2003-12-31 22:37:16.000000000 +0100
1093 +++ libdvdnav-0.1.10/src/settings.c 2008-03-28 15:24:50.000000000 +0100
1095 * You should have received a copy of the GNU General Public License
1096 * along with this program; if not, write to the Free Software
1097 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
1099 - * $Id: settings.c,v 1.9 2003/12/31 21:37:16 jcdutton Exp $
1103 #ifdef HAVE_CONFIG_H
1104 diff -Naur libdvdnav-0.1.10-org/src/vm/decoder.c libdvdnav-0.1.10/src/vm/decoder.c
1105 --- libdvdnav-0.1.10-org/src/vm/decoder.c 2004-03-03 17:50:42.000000000 +0100
1106 +++ libdvdnav-0.1.10/src/vm/decoder.c 2008-03-28 15:24:50.000000000 +0100
1109 - * Copyright (C) 2000, 2001 Martin Norbäck, Håkan Hjort
1110 + * Copyright (C) 2000, 2001 Martin Norbäck, Håkan Hjort
1111 * 2002-2004 the dvdnav project
1113 * This file is part of libdvdnav, a DVD navigation library. It is modified
1115 * You should have received a copy of the GNU General Public License
1116 * along with this program; if not, write to the Free Software
1117 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
1119 - * $Id: decoder.c,v 1.2 2004/03/03 16:50:42 mroi Exp $
1123 #ifdef HAVE_CONFIG_H
1124 diff -Naur libdvdnav-0.1.10-org/src/vm/decoder.h libdvdnav-0.1.10/src/vm/decoder.h
1125 --- libdvdnav-0.1.10-org/src/vm/decoder.h 2004-01-11 22:43:13.000000000 +0100
1126 +++ libdvdnav-0.1.10/src/vm/decoder.h 2008-01-23 06:11:52.000000000 +0100
1129 - * Copyright (C) 2000, 2001 Martin Norbäck, Håkan Hjort
1130 + * Copyright (C) 2000, 2001 Martin Norbäck, Håkan Hjort
1132 * This file is part of libdvdnav, a DVD navigation library. It is modified
1133 * from a file originally part of the Ogle DVD player.
1135 * You should have received a copy of the GNU General Public License
1136 * along with this program; if not, write to the Free Software
1137 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
1139 - * $Id: decoder.h,v 1.1 2004/01/11 21:43:13 mroi Exp $
1143 #ifndef DECODER_H_INCLUDED
1144 diff -Naur libdvdnav-0.1.10-org/src/vm/vm.c libdvdnav-0.1.10/src/vm/vm.c
1145 --- libdvdnav-0.1.10-org/src/vm/vm.c 2004-05-21 21:32:25.000000000 +0200
1146 +++ libdvdnav-0.1.10/src/vm/vm.c 2008-03-28 15:24:50.000000000 +0100
1149 - * Copyright (C) 2000, 2001 Håkan Hjort
1150 + * Copyright (C) 2000, 2001 Håkan Hjort
1151 * Copyright (C) 2001 Rich Wareham <richwareham@users.sourceforge.net>
1152 * 2002-2004 the dvdnav project
1155 * You should have received a copy of the GNU General Public License
1156 * along with this program; if not, write to the Free Software
1157 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
1159 - * $Id: vm.c,v 1.6 2004/05/21 19:32:25 mroi Exp $
1163 #ifdef HAVE_CONFIG_H
1168 -static void ifoOpenNewVTSI(vm_t *vm, dvd_reader_t *dvd, int vtsN) {
1169 +static int ifoOpenNewVTSI(vm_t *vm, dvd_reader_t *dvd, int vtsN) {
1170 if((vm->state).vtsN == vtsN) {
1171 - return; /* We alread have it */
1172 + return 1; /* We alread have it */
1175 if(vm->vtsi != NULL)
1176 @@ -194,30 +191,32 @@
1178 vm->vtsi = ifoOpenVTSI(dvd, vtsN);
1179 if(vm->vtsi == NULL) {
1180 - fprintf(MSG_OUT, "libdvdnav: ifoOpenVTSI failed - CRASHING!!!\n");
1182 + fprintf(MSG_OUT, "libdvdnav: ifoOpenVTSI failed\n");
1185 if(!ifoRead_VTS_PTT_SRPT(vm->vtsi)) {
1186 - fprintf(MSG_OUT, "libdvdnav: ifoRead_VTS_PTT_SRPT failed - CRASHING!!!\n");
1188 + fprintf(MSG_OUT, "libdvdnav: ifoRead_VTS_PTT_SRPT failed\n");
1191 if(!ifoRead_PGCIT(vm->vtsi)) {
1192 - fprintf(MSG_OUT, "libdvdnav: ifoRead_PGCIT failed - CRASHING!!!\n");
1194 + fprintf(MSG_OUT, "libdvdnav: ifoRead_PGCIT failed\n");
1197 if(!ifoRead_PGCI_UT(vm->vtsi)) {
1198 - fprintf(MSG_OUT, "libdvdnav: ifoRead_PGCI_UT failed - CRASHING!!!\n");
1200 + fprintf(MSG_OUT, "libdvdnav: ifoRead_PGCI_UT failed\n");
1203 if(!ifoRead_VOBU_ADMAP(vm->vtsi)) {
1204 - fprintf(MSG_OUT, "libdvdnav: ifoRead_VOBU_ADMAP vtsi failed - CRASHING\n");
1206 + fprintf(MSG_OUT, "libdvdnav: ifoRead_VOBU_ADMAP vtsi failed\n");
1209 if(!ifoRead_TITLE_VOBU_ADMAP(vm->vtsi)) {
1210 - fprintf(MSG_OUT, "libdvdnav: ifoRead_TITLE_VOBU_ADMAP vtsi failed - CRASHING\n");
1212 + fprintf(MSG_OUT, "libdvdnav: ifoRead_TITLE_VOBU_ADMAP vtsi failed\n");
1215 (vm->state).vtsN = vtsN;
1221 @@ -253,10 +252,11 @@
1223 /* Basic Handling */
1225 -void vm_start(vm_t *vm) {
1226 +int vm_start(vm_t *vm) {
1227 /* Set pgc to FP (First Play) pgc */
1229 process_command(vm, play_PGC(vm));
1230 + return !vm->stopped;
1233 void vm_stop(vm_t *vm) {
1235 vtsN = (target->state).vtsN;
1237 (target->state).vtsN = 0;
1238 - ifoOpenNewVTSI(target, target->dvd, vtsN);
1239 + if (!ifoOpenNewVTSI(target, target->dvd, vtsN))
1242 /* restore pgc pointer into the new vtsi */
1243 if (!set_PGCN(target, pgcN))
1248 - if((vm->state).domain != VTS_DOMAIN && streamN == -1)
1250 + if((vm->state).domain != VTS_DOMAIN && streamN == -1)
1253 /* FIXME: Should also check in vtsi/vmgi status what kind of stream it is. */
1255 @@ -1280,9 +1281,10 @@
1256 if(link_values.data1 != 0)
1257 (vm->state).HL_BTNN_REG = link_values.data1 << 10;
1258 assert((vm->state).pgc->next_pgc_nr != 0);
1259 - if(!set_PGCN(vm, (vm->state).pgc->next_pgc_nr))
1261 - link_values = play_PGC(vm);
1262 + if(set_PGCN(vm, (vm->state).pgc->next_pgc_nr))
1263 + link_values = play_PGC(vm);
1265 + link_values.command = Exit;
1268 /* Link to Previous Program Chain */
1269 @@ -1290,9 +1292,10 @@
1270 if(link_values.data1 != 0)
1271 (vm->state).HL_BTNN_REG = link_values.data1 << 10;
1272 assert((vm->state).pgc->prev_pgc_nr != 0);
1273 - if(!set_PGCN(vm, (vm->state).pgc->prev_pgc_nr))
1275 - link_values = play_PGC(vm);
1276 + if(set_PGCN(vm, (vm->state).pgc->prev_pgc_nr))
1277 + link_values = play_PGC(vm);
1279 + link_values.command = Exit;
1282 /* Link to GoUp Program Chain */
1283 @@ -1300,9 +1303,10 @@
1284 if(link_values.data1 != 0)
1285 (vm->state).HL_BTNN_REG = link_values.data1 << 10;
1286 assert((vm->state).pgc->goup_pgc_nr != 0);
1287 - if(!set_PGCN(vm, (vm->state).pgc->goup_pgc_nr))
1289 - link_values = play_PGC(vm);
1290 + if(set_PGCN(vm, (vm->state).pgc->goup_pgc_nr))
1291 + link_values = play_PGC(vm);
1293 + link_values.command = Exit;
1296 /* Link to Tail of Program Chain */
1297 @@ -1325,7 +1329,8 @@
1300 (vm->state).domain = VTS_DOMAIN;
1301 - ifoOpenNewVTSI(vm, vm->dvd, (vm->state).rsm_vtsN);
1302 + if (!ifoOpenNewVTSI(vm, vm->dvd, (vm->state).rsm_vtsN))
1304 set_PGCN(vm, (vm->state).rsm_pgcN);
1306 /* These should never be set in SystemSpace and/or MenuSpace */
1307 @@ -1343,10 +1348,11 @@
1308 (vm->state).pgN = 1;
1309 link_values = play_PG(vm);
1311 - /* (vm->state).pgN = ?? this gets the righ value in set_PGN() below */
1312 + /* (vm->state).pgN = ?? this gets the right value in set_PGN() below */
1313 (vm->state).cellN = (vm->state).rsm_cellN;
1314 link_values.command = PlayThis;
1315 - link_values.data1 = (vm->state).rsm_blockN;
1316 + link_values.data1 = (vm->state).rsm_blockN & 0xffff;
1317 + link_values.data2 = (vm->state).rsm_blockN >> 16;
1319 /* Were at the end of the PGC, should not happen for a RSM */
1321 @@ -1403,9 +1409,10 @@
1322 /* Stop SPRM9 Timer */
1323 /* Set SPRM1 and SPRM2 */
1324 assert((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN); /* ?? */
1325 - if(!set_TT(vm, link_values.data1))
1327 - link_values = play_PGC(vm);
1328 + if(set_TT(vm, link_values.data1))
1329 + link_values = play_PGC(vm);
1331 + link_values.command = Exit;
1334 /* Jump to Title:data1 in same VTS Title Domain */
1335 @@ -1462,7 +1469,8 @@
1336 /* the normal case */
1337 assert((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN); /* ?? */
1338 (vm->state).domain = VTSM_DOMAIN;
1339 - ifoOpenNewVTSI(vm, vm->dvd, link_values.data1); /* Also sets (vm->state).vtsN */
1340 + if (!ifoOpenNewVTSI(vm, vm->dvd, link_values.data1)) /* Also sets (vm->state).vtsN */
1343 /* This happens on some discs like "Captain Scarlet & the Mysterons" or
1344 * the German RC2 of "Anatomie" in VTSM. */
1345 @@ -1549,7 +1557,7 @@
1349 - (vm->state).blockN = link_values.data1;
1350 + (vm->state).blockN = link_values.data1 | (link_values.data2 << 16);
1354 @@ -1575,8 +1583,9 @@
1356 (vm->state).domain = VTS_DOMAIN;
1358 - if(vtsN != (vm->state).vtsN)
1359 - ifoOpenNewVTSI(vm, vm->dvd, vtsN); /* Also sets (vm->state).vtsN */
1360 + if (vtsN != (vm->state).vtsN)
1361 + if (!ifoOpenNewVTSI(vm, vm->dvd, vtsN)) /* Also sets (vm->state).vtsN */
1364 if ((vts_ttn < 1) || (vts_ttn > vm->vtsi->vts_ptt_srpt->nr_of_srpts) ||
1365 (part < 1) || (part > vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].nr_of_ptts) ) {
1366 @@ -1601,6 +1610,9 @@
1368 static int set_FP_PGC(vm_t *vm) {
1369 (vm->state).domain = FP_DOMAIN;
1370 + if (!vm->vmgi->first_play_pgc) {
1371 + return set_PGCN(vm, 1);
1373 (vm->state).pgc = vm->vmgi->first_play_pgc;
1374 (vm->state).pgcN = vm->vmgi->vmgi_mat->first_play_pgc;
1376 diff -Naur libdvdnav-0.1.10-org/src/vm/vmcmd.c libdvdnav-0.1.10/src/vm/vmcmd.c
1377 --- libdvdnav-0.1.10-org/src/vm/vmcmd.c 2004-03-03 17:50:42.000000000 +0100
1378 +++ libdvdnav-0.1.10/src/vm/vmcmd.c 2008-03-28 15:24:50.000000000 +0100
1381 - * Copyright (C) 2000, 2001 Martin Norbäck, Håkan Hjort
1382 + * Copyright (C) 2000, 2001 Martin Norbäck, Håkan Hjort
1383 * 2002-2004 the dvdnav project
1385 * This file is part of libdvdnav, a DVD navigation library. It is modified
1387 * You should have received a copy of the GNU General Public License
1388 * along with this program; if not, write to the Free Software
1389 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
1391 - * $Id: vmcmd.c,v 1.2 2004/03/03 16:50:42 mroi Exp $
1395 #ifdef HAVE_CONFIG_H
1396 diff -Naur libdvdnav-0.1.10-org/src/vm/vmcmd.h libdvdnav-0.1.10/src/vm/vmcmd.h
1397 --- libdvdnav-0.1.10-org/src/vm/vmcmd.h 2004-01-11 22:43:13.000000000 +0100
1398 +++ libdvdnav-0.1.10/src/vm/vmcmd.h 2008-01-23 06:11:52.000000000 +0100
1401 - * Copyright (C) 2000, 2001 Martin Norbäck, Håkan Hjort
1402 + * Copyright (C) 2000, 2001 Martin Norbäck, Håkan Hjort
1404 * This file is part of libdvdnav, a DVD navigation library. It is modified
1405 * from a file originally part of the Ogle DVD player.
1407 * You should have received a copy of the GNU General Public License
1408 * along with this program; if not, write to the Free Software
1409 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
1411 - * $Id: vmcmd.h,v 1.1 2004/01/11 21:43:13 mroi Exp $
1415 #ifndef VMCMD_H_INCLUDED
1416 diff -Naur libdvdnav-0.1.10-org/src/vm/vm.h libdvdnav-0.1.10/src/vm/vm.h
1417 --- libdvdnav-0.1.10-org/src/vm/vm.h 2004-01-11 22:43:13.000000000 +0100
1418 +++ libdvdnav-0.1.10/src/vm/vm.h 2008-01-23 06:11:52.000000000 +0100
1421 - * Copyright (C) 2000, 2001 Håkan Hjort
1422 + * Copyright (C) 2000, 2001 Håkan Hjort
1423 * Copyright (C) 2001 Rich Wareham <richwareham@users.sourceforge.net>
1425 * This file is part of libdvdnav, a DVD navigation library. It is modified
1427 * You should have received a copy of the GNU General Public License
1428 * along with this program; if not, write to the Free Software
1429 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
1431 - * $Id: vm.h,v 1.1 2004/01/11 21:43:13 mroi Exp $
1435 #ifndef VM_H_INCLUDED
1437 dvd_reader_t *vm_get_dvd_reader(vm_t *vm);
1439 /* Basic Handling */
1440 -void vm_start(vm_t *vm);
1441 +int vm_start(vm_t *vm);
1442 void vm_stop(vm_t *vm);
1443 int vm_reset(vm_t *vm, const char *dvdroot);
1445 diff -Naur libdvdnav-0.1.10-org/configure.ac libdvdnav-0.1.10/configure.ac
1446 --- libdvdnav-0.1.10-org/configure.ac 2004-06-10 23:13:02.000000000 +0200
1447 +++ libdvdnav-0.1.10/configure.ac 2008-04-19 21:29:04.000000000 +0200
1449 dnl --------------------------------------------------------------
1450 dnl Making releases: DVDNAV_SUB += 1; change LT_* accordingly
1451 dnl --------------------------------------------------------------
1459 AC_SUBST(DVDNAV_MAJOR)