summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Roitzsch <mroi@users.sourceforge.net>2004-03-16 11:43:38 +0000
committerMichael Roitzsch <mroi@users.sourceforge.net>2004-03-16 11:43:38 +0000
commit50a26e7dabcb36c002f8527c8364c67439adbb11 (patch)
treed79ee798b6681d0fc8e8a3c93c845d34cfdb92e4 /src
parentb323267b7a8f5592c66158376a1ce25e2bdfefd5 (diff)
downloadxine-lib-50a26e7dabcb36c002f8527c8364c67439adbb11.tar.gz
xine-lib-50a26e7dabcb36c002f8527c8364c67439adbb11.tar.bz2
sync to latest libdvdnav
* fixes a menu problem (German RC2 of "Anatomie", chapter menu) * addresses some compilation problems on Windows (Could someone try cygwin, mingw builds, please? It should work with the standalone libdvdnav, but who knows if the integration breaks anything...) * turns some abort()s into assert(0)s, where we really can try to continue CVS patchset: 6269 CVS date: 2004/03/16 11:43:38
Diffstat (limited to 'src')
-rw-r--r--src/input/libdvdnav/decoder.c4
-rw-r--r--src/input/libdvdnav/decoder.h4
-rw-r--r--src/input/libdvdnav/diff_against_cvs.patch12
-rw-r--r--src/input/libdvdnav/dvd_input.c19
-rw-r--r--src/input/libdvdnav/dvd_reader.c25
-rw-r--r--src/input/libdvdnav/dvd_reader.h3
-rw-r--r--src/input/libdvdnav/dvd_udf.c4
-rw-r--r--src/input/libdvdnav/dvdnav.c12
-rw-r--r--src/input/libdvdnav/dvdnav_internal.h35
-rw-r--r--src/input/libdvdnav/highlight.c6
-rw-r--r--src/input/libdvdnav/nav_read.c18
-rw-r--r--src/input/libdvdnav/navigation.c8
-rw-r--r--src/input/libdvdnav/read_cache.c328
-rw-r--r--src/input/libdvdnav/searching.c4
-rw-r--r--src/input/libdvdnav/settings.c14
-rw-r--r--src/input/libdvdnav/vm.c157
-rw-r--r--src/input/libdvdnav/vmcmd.c16
17 files changed, 211 insertions, 458 deletions
diff --git a/src/input/libdvdnav/decoder.c b/src/input/libdvdnav/decoder.c
index 187ee5f65..270a565ac 100644
--- a/src/input/libdvdnav/decoder.c
+++ b/src/input/libdvdnav/decoder.c
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2000, 2001 Martin Norbäck, Håkan Hjort
+ * 2002-2004 the dvdnav project
*
* This file is part of libdvdnav, a DVD navigation library. It is modified
* from a file originally part of the Ogle DVD player.
@@ -18,7 +19,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: decoder.c,v 1.13 2003/12/07 15:34:30 f1rmb Exp $
+ * $Id: decoder.c,v 1.14 2004/03/16 11:43:38 mroi Exp $
*
*/
@@ -31,7 +32,6 @@
#include <inttypes.h>
#include <string.h> /* For memset */
#include "ifo_types.h" /* vm_cmd_t */
-#include <assert.h>
#include "dvdnav_internal.h"
diff --git a/src/input/libdvdnav/decoder.h b/src/input/libdvdnav/decoder.h
index 293f0b53d..2a9e455c8 100644
--- a/src/input/libdvdnav/decoder.h
+++ b/src/input/libdvdnav/decoder.h
@@ -18,7 +18,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: decoder.h,v 1.8 2003/05/11 13:44:05 jcdutton Exp $
+ * $Id: decoder.h,v 1.9 2004/03/16 11:43:38 mroi Exp $
*
*/
@@ -101,7 +101,7 @@ typedef struct {
/* the big VM function, executing the given commands and writing
* the link where to continue, the return value indicates if a jump
* has been performed */
-int vmEval_CMD(vm_cmd_t commands[], int32_t num_commands,
+int32_t vmEval_CMD(vm_cmd_t commands[], int32_t num_commands,
registers_t *registers, link_t *return_values);
/* extracts some bits from the command */
diff --git a/src/input/libdvdnav/diff_against_cvs.patch b/src/input/libdvdnav/diff_against_cvs.patch
index 607923d4d..137c14478 100644
--- a/src/input/libdvdnav/diff_against_cvs.patch
+++ b/src/input/libdvdnav/diff_against_cvs.patch
@@ -1,6 +1,6 @@
--- src/input/libdvdnav/dvdnav.c
+++ src/input/libdvdnav/dvdnav.c
-@@ -71,7 +71,7 @@
+@@ -67,7 +67,7 @@
struct timeval time;
/* Create a new structure */
@@ -11,7 +11,7 @@
this = (dvdnav_t*)malloc(sizeof(dvdnav_t));
--- src/input/libdvdnav/dvd_reader.c
+++ src/input/libdvdnav/dvd_reader.c
-@@ -44,6 +44,7 @@
+@@ -60,6 +60,7 @@
#include <mntent.h>
#endif
@@ -19,7 +19,7 @@
#include "dvd_udf.h"
#include "dvd_input.h"
#include "dvd_reader.h"
-@@ -393,7 +394,7 @@
+@@ -408,7 +409,7 @@
if( cdir >= 0 ) {
chdir( path_copy );
@@ -28,7 +28,7 @@
fchdir( cdir );
close( cdir );
if( new_path ) {
-@@ -573,7 +574,7 @@
+@@ -594,7 +595,7 @@
static int findDVDFile( dvd_reader_t *dvd, const char *file, char *filename )
{
@@ -37,7 +37,7 @@
const char *nodirfile;
int ret;
-@@ -607,7 +608,7 @@
+@@ -628,7 +629,7 @@
*/
static dvd_file_t *DVDOpenFilePath( dvd_reader_t *dvd, char *filename )
{
@@ -46,7 +46,7 @@
dvd_file_t *dvd_file;
struct stat fileinfo;
dvd_input_t dev;
-@@ -691,7 +692,7 @@
+@@ -721,7 +722,7 @@
static dvd_file_t *DVDOpenVOBPath( dvd_reader_t *dvd, int title, int menu )
{
char filename[ MAX_UDF_FILE_NAME_LEN ];
diff --git a/src/input/libdvdnav/dvd_input.c b/src/input/libdvdnav/dvd_input.c
index ae332257e..47084016c 100644
--- a/src/input/libdvdnav/dvd_input.c
+++ b/src/input/libdvdnav/dvd_input.c
@@ -24,18 +24,10 @@
#include <fcntl.h>
#include <unistd.h>
-#include <dlfcn.h>
-
#include "dvd_reader.h"
#include "dvd_input.h"
-#ifndef _MSC_VER
-#define LIBDVDCSS_NAME = "libdvdcss.so.2"
-#else
-#define LIBDVDCSS_NAME = "libdvdcss.dll"
-#endif
-
/* The function pointers that is the exported interface of this file. */
dvd_input_t (*dvdinput_open) (const char *);
int (*dvdinput_close) (dvd_input_t);
@@ -56,7 +48,12 @@ char * (*dvdinput_error) (dvd_input_t);
#else
/* dlopening libdvdcss */
+#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
+#else
+/* Only needed on MINGW at the moment */
+#include "../../msvc/contrib/dlfcn.c"
+#endif
typedef struct dvdcss_s *dvdcss_handle;
static dvdcss_handle (*DVDcss_open) (const char *);
@@ -172,8 +169,8 @@ static dvd_input_t file_open(const char *target)
}
/* Open the device */
-#ifndef _MSC_VER
- dev->fd = open(target, O_RDONLY|O_EXCL);
+#ifndef WIN32
+ dev->fd = open(target, O_RDONLY | O_EXCL);
#else
dev->fd = open(target, O_RDONLY | O_BINARY);
#endif
@@ -290,7 +287,7 @@ int dvdinput_setup(void)
#else
/* dlopening libdvdcss */
-#ifndef _MSC_VER
+#ifndef WIN32
dvdcss_library = dlopen("libdvdcss.so.2", RTLD_LAZY);
#else
dvdcss_library = dlopen("libdvdcss.dll", RTLD_LAZY);
diff --git a/src/input/libdvdnav/dvd_reader.c b/src/input/libdvdnav/dvd_reader.c
index b173a130e..185143604 100644
--- a/src/input/libdvdnav/dvd_reader.c
+++ b/src/input/libdvdnav/dvd_reader.c
@@ -31,6 +31,22 @@
#include <unistd.h>
#include <limits.h>
#include <dirent.h>
+
+/* misc win32 helpers */
+#ifdef WIN32
+/* replacement gettimeofday implementation */
+#include <sys/timeb.h>
+static inline int gettimeofday( struct timeval *tv, void *tz )
+{
+ struct timeb t;
+ ftime( &t );
+ tv->tv_sec = t.time;
+ tv->tv_usec = t.millitm * 1000;
+ return 0;
+}
+#include <io.h> /* read() */
+#define lseek64 _lseeki64
+#endif
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__bsdi__)|| defined(__DARWIN__)
#define SYS_BSD 1
@@ -52,10 +68,6 @@
#define DEFAULT_UDF_CACHE_LEVEL 1
-#ifdef _MSC_VER
-#define fchdir chdir
-#endif
-
struct dvd_reader_s {
/* Basic information. */
int isImageFile;
@@ -387,6 +399,9 @@ dvd_reader_t *DVDOpen( const char *ppath )
return 0;
}
+#ifndef WIN32 /* don't have fchdir, and getcwd( NULL, ... ) is strange */
+ /* Also WIN32 does not have symlinks, so we don't need this bit of code. */
+
/* Resolve any symlinks and get the absolut dir name. */
{
char *new_path;
@@ -403,7 +418,7 @@ dvd_reader_t *DVDOpen( const char *ppath )
}
}
}
-
+#endif
/**
* If we're being asked to open a directory, check if that directory
* is the mountpoint for a DVD-ROM which we can use instead.
diff --git a/src/input/libdvdnav/dvd_reader.h b/src/input/libdvdnav/dvd_reader.h
index edd18da77..9bfba3ee1 100644
--- a/src/input/libdvdnav/dvd_reader.h
+++ b/src/input/libdvdnav/dvd_reader.h
@@ -29,6 +29,7 @@
#endif
#include <sys/types.h>
+#include <inttypes.h>
/**
* The DVD access interface.
@@ -166,7 +167,7 @@ ssize_t DVDReadBlocks( dvd_file_t *, int, size_t, unsigned char * );
*
* offset_set = DVDFileSeek(dvd_file, seek_offset);
*/
-int DVDFileSeek( dvd_file_t *, int );
+int32_t DVDFileSeek( dvd_file_t *, int32_t );
/**
* Reads the given number of bytes from the file. This call can only be used
diff --git a/src/input/libdvdnav/dvd_udf.c b/src/input/libdvdnav/dvd_udf.c
index 8932bfcb9..88045b8f3 100644
--- a/src/input/libdvdnav/dvd_udf.c
+++ b/src/input/libdvdnav/dvd_udf.c
@@ -34,10 +34,6 @@
#include <stdlib.h>
#include <string.h>
-#ifndef _MSC_VER
-#include <sys/ioctl.h>
-#endif /* _MSC_VER */
-
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
diff --git a/src/input/libdvdnav/dvdnav.c b/src/input/libdvdnav/dvdnav.c
index 2c01fd625..452278b98 100644
--- a/src/input/libdvdnav/dvdnav.c
+++ b/src/input/libdvdnav/dvdnav.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: dvdnav.c,v 1.29 2003/05/16 09:56:50 mroi Exp $
+ * $Id: dvdnav.c,v 1.30 2004/03/16 11:43:38 mroi Exp $
*
*/
@@ -29,10 +29,8 @@
#define LOG_DEBUG
*/
-#include <pthread.h>
#include "dvdnav_internal.h"
#include "read_cache.h"
-
#include "nav_read.h"
#include <stdlib.h>
@@ -46,8 +44,6 @@ static dvdnav_status_t dvdnav_clear(dvdnav_t * this) {
if (this->file) DVDCloseFile(this->file);
this->file = NULL;
- this->open_vtsN = -1;
- this->open_domain = -1;
memset(&this->pci,0,sizeof(this->pci));
memset(&this->dsi,0,sizeof(this->dsi));
@@ -231,7 +227,7 @@ static int64_t dvdnav_convert_time(dvd_time_t *time) {
/*
* Returns 1 if block contains NAV packet, 0 otherwise.
- * Precesses said NAV packet if present.
+ * Processes said NAV packet if present.
*
* Most of the code in here is copied from xine's MPEG demuxer
* so any bugs which are found in that should be corrected here also.
@@ -522,8 +518,8 @@ dvdnav_status_t dvdnav_get_next_cache_block(dvdnav_t *this, uint8_t **buf,
this->file = NULL;
}
- vts_event->old_vtsN = this->open_vtsN;
- vts_event->old_domain = this->open_domain;
+ vts_event->old_vtsN = this->position_current.vts;
+ vts_event->old_domain = this->position_current.domain;
/* Use the DOMAIN to find whether to open menu or title VOBs */
switch(this->position_next.domain) {
diff --git a/src/input/libdvdnav/dvdnav_internal.h b/src/input/libdvdnav/dvdnav_internal.h
index 65a4e0e58..29733ed54 100644
--- a/src/input/libdvdnav/dvdnav_internal.h
+++ b/src/input/libdvdnav/dvdnav_internal.h
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: dvdnav_internal.h,v 1.13 2003/05/16 10:22:51 mroi Exp $
+ * $Id: dvdnav_internal.h,v 1.14 2004/03/16 11:43:38 mroi Exp $
*
*/
@@ -33,11 +33,36 @@
#include <unistd.h>
#include <limits.h>
#include <string.h>
+
+#ifdef WIN32
+
+/* pthread_mutex_* wrapper for win32 */
+#include <windows.h>
+#include <process.h>
+typedef CRITICAL_SECTION pthread_mutex_t;
+#define pthread_mutex_init(a, b) InitializeCriticalSection(a)
+#define pthread_mutex_lock(a) EnterCriticalSection(a)
+#define pthread_mutex_unlock(a) LeaveCriticalSection(a)
+#define pthread_mutex_destroy(a)
+
+/* replacement gettimeofday implementation */
+#include <sys/timeb.h>
+static inline int gettimeofday( struct timeval *tv, void *tz )
+{
+ struct timeb t;
+ ftime( &t );
+ tv->tv_sec = t.time;
+ tv->tv_usec = t.millitm * 1000;
+ return 0;
+}
+#include <io.h> /* read() */
+#define lseek64 _lseeki64
+
+#else
+
#include <pthread.h>
-#include "dvd_reader.h"
-#include "ifo_read.h"
-#include "ifo_types.h"
+#endif /* WIN32 */
/* Uncomment for VM command tracing */
/* #define TRACE */
@@ -126,8 +151,6 @@ struct dvdnav_s {
/* General data */
char path[MAX_PATH_LEN]; /* Path to DVD device/dir */
dvd_file_t *file; /* Currently opened file */
- int open_vtsN; /* The domain and number of the... */
- int open_domain; /* ..currently opened VOB */
/* Position data */
vm_position_t position_next;
diff --git a/src/input/libdvdnav/highlight.c b/src/input/libdvdnav/highlight.c
index f8dc4aaba..ac417f155 100644
--- a/src/input/libdvdnav/highlight.c
+++ b/src/input/libdvdnav/highlight.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: highlight.c,v 1.16 2003/06/02 06:36:33 f1rmb Exp $
+ * $Id: highlight.c,v 1.17 2004/03/16 11:43:38 mroi Exp $
*
*/
@@ -479,8 +479,8 @@ dvdnav_status_t dvdnav_mouse_select(dvdnav_t *this, pci_t *pci, int32_t x, int32
/* Loop through all buttons */
for(button = 1; button <= pci->hli.hl_gi.btn_ns; button++) {
- btni_t *button_ptr = &(this->pci.hli.btnit[button-1]);
-
+ btni_t *button_ptr = &(pci->hli.btnit[button-1]);
+
if((x >= button_ptr->x_start) && (x <= button_ptr->x_end) &&
(y >= button_ptr->y_start) && (y <= button_ptr->y_end)) {
mx = (button_ptr->x_start + button_ptr->x_end)/2;
diff --git a/src/input/libdvdnav/nav_read.c b/src/input/libdvdnav/nav_read.c
index c76aa55a8..421678c78 100644
--- a/src/input/libdvdnav/nav_read.c
+++ b/src/input/libdvdnav/nav_read.c
@@ -22,7 +22,6 @@
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
-#include <assert.h>
#include "bswap.h"
#include "nav_types.h"
@@ -36,13 +35,13 @@ typedef struct {
uint8_t byte;
} getbits_state_t;
-static int32_t getbits_init(getbits_state_t *state, uint8_t *start) {
- if ((state == NULL) || (start == NULL)) return -1;
+static int getbits_init(getbits_state_t *state, uint8_t *start) {
+ if ((state == NULL) || (start == NULL)) return 0;
state->start = start;
state->bit_position = 0;
state->byte_position = 0;
state->byte = start[0];
- return 0;
+ return 1;
}
/* Non-optimized getbits. */
@@ -78,7 +77,7 @@ static uint32_t getbits(getbits_state_t *state, uint32_t number_of_bits) {
number_of_bits = 0;
}
}
- if ((state->bit_position) == 0)
+ if ((state->bit_position) == 0) {
while (number_of_bits > 7) {
result = (result << 8) + state->byte;
state->byte_position++;
@@ -93,10 +92,13 @@ static uint32_t getbits(getbits_state_t *state, uint32_t number_of_bits) {
result = (result << number_of_bits) + byte;
number_of_bits = 0;
}
+ }
return result;
}
+#if 0 /* TODO: optimized versions not yet used */
+
/* WARNING: This function can only be used on a byte boundary.
No checks are made that we are in fact on a byte boundary.
*/
@@ -121,10 +123,12 @@ static uint32_t get32bits(getbits_state_t *state) {
return result;
}
+#endif
+
void navRead_PCI(pci_t *pci, unsigned char *buffer) {
int32_t i, j;
getbits_state_t state;
- if (getbits_init(&state, buffer)) abort(); /* Passed NULL pointers */
+ if (!getbits_init(&state, buffer)) abort(); /* Passed NULL pointers */
/* pci pci_gi */
pci->pci_gi.nv_pck_lbn = getbits(&state, 32 );
@@ -292,7 +296,7 @@ void navRead_PCI(pci_t *pci, unsigned char *buffer) {
void navRead_DSI(dsi_t *dsi, unsigned char *buffer) {
int i;
getbits_state_t state;
- if (getbits_init(&state, buffer)) abort(); /* Passed NULL pointers */
+ if (!getbits_init(&state, buffer)) abort(); /* Passed NULL pointers */
/* dsi dsi gi */
dsi->dsi_gi.nv_pck_scr = getbits(&state, 32 );
diff --git a/src/input/libdvdnav/navigation.c b/src/input/libdvdnav/navigation.c
index ee79f1d45..3832ab382 100644
--- a/src/input/libdvdnav/navigation.c
+++ b/src/input/libdvdnav/navigation.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: navigation.c,v 1.9 2003/05/11 13:44:05 jcdutton Exp $
+ * $Id: navigation.c,v 1.10 2004/03/16 11:43:38 mroi Exp $
*
*/
@@ -60,11 +60,9 @@ dvdnav_status_t dvdnav_get_number_of_titles(dvdnav_t *this, int32_t *titles) {
printerr("Passed a NULL pointer.");
return DVDNAV_STATUS_ERR;
}
-
if(!this->started) {
- /* Start the VM */
- vm_start(this->vm);
- this->started = 1;
+ printerr("Virtual DVD machine not started.");
+ return DVDNAV_STATUS_ERR;
}
(*titles) = vm_get_vmgi(this->vm)->tt_srpt->nr_of_srpts;
diff --git a/src/input/libdvdnav/read_cache.c b/src/input/libdvdnav/read_cache.c
index c17e38634..5d0515260 100644
--- a/src/input/libdvdnav/read_cache.c
+++ b/src/input/libdvdnav/read_cache.c
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2000 Rich Wareham <richwareham@users.sourceforge.net>
+ * 2001-2004 the dvdnav project
*
* This file is part of libdvdnav, a DVD navigation library.
*
@@ -17,56 +18,25 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: read_cache.c,v 1.11 2004/02/19 02:50:25 rockyb Exp $
+ * $Id: read_cache.c,v 1.12 2004/03/16 11:43:38 mroi Exp $
*
*/
+/*
+ * There was a multithreaded read ahead cache in here for some time, but
+ * it had only been used for a short time. If you want to have a look at it,
+ * search the CVS attic.
+ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "dvdnav.h"
+#include "dvdnav_internal.h"
#include "read_cache.h"
-#include <pthread.h>
#include <sys/time.h>
#include <time.h>
-
-#define DVDNAV_PROFILE
-
-
-/* Read-ahead cache structure. */
-#if _MULTITHREAD_
-
-/* For the multithreaded cache, the cache is a ring buffer + writing
- * thread that continuously reads data into the buffer until it is
- * full or the 'upper-bound' has been reached.
- */
-
-#define CACHE_BUFFER_SIZE 2048 /* Cache this number of blocks at a time */
-
-struct read_cache_s {
- pthread_mutex_t cache_lock;
- pthread_t read_thread;
-
- /* Buffer */
- uint8_t *buffer;
-
- /* Size of buffer */
- int32_t size;
- /* block offset from sector start of buffer 'head' */
- uint32_t pos;
- /* block offset from sector start of read point */
- uint32_t read_point;
- /* block offset from buffer start to ring-boundary */
- uint32_t start;
-
- /* Bit of strange cross-linking going on here :) -- Gotta love C :) */
- dvdnav_t *dvd_self;
-};
-
-#else
-
#define READ_CACHE_CHUNKS 10
/* all cache chunks must be memory aligned to allow use of raw devices */
@@ -98,7 +68,6 @@ struct read_cache_s {
/* Bit of strange cross-linking going on here :) -- Gotta love C :) */
dvdnav_t *dvd_self;
};
-#endif
/*
#define READ_CACHE_TRACE 0
@@ -122,241 +91,6 @@ struct read_cache_s {
# endif
#endif
-#if _MULTITHREAD_
-
-void * read_cache_read_thread (void * this_gen) {
- int cont = 1;
- int32_t diff, start;
- uint32_t pos, size, startp, endp;
- uint32_t s,c;
- uint8_t *at;
- read_cache_t *self = (read_cache_t*)this_gen;
-
- while(cont) {
-
- pthread_mutex_lock(&self->cache_lock);
-
- if(self->size >= 0) {
- diff = self->read_point - self->pos;
- if(diff >= self->size/2) {
- dprintf("(II) Read thread -- ");
-
- startp = (self->start) % CACHE_BUFFER_SIZE;
- endp = abs((self->start + diff - 1) % CACHE_BUFFER_SIZE);
- dprintf("startp = %i, endp = %i -- ",startp, endp);
-
- pos = self->pos + diff;
- size = self->size - diff;
- start = (self->start + diff) % CACHE_BUFFER_SIZE;
-
- /* Fill remainder of buffer */
-
- if(startp > endp) {
- s = pos + size; c = CACHE_BUFFER_SIZE - startp;
- at = self->buffer + (startp * DVD_VIDEO_LB_LEN);
- if(c > 0) {
- dprintf("(1) Reading from %i to %i to %i ", s, s+c-1, startp);
- pthread_mutex_unlock(&self->cache_lock);
- DVDReadBlocks(self->dvd_self->file, s,c, at);
- pthread_mutex_lock(&self->cache_lock);
- }
-
- s = pos + size + c; c = CACHE_BUFFER_SIZE - size - c;
- at = self->buffer;
- if(c > 0) {
- dprintf("(2) Reading from %i to %i to %i ", s, s+c-1, 0);
- pthread_mutex_unlock(&self->cache_lock);
- DVDReadBlocks(self->dvd_self->file, s,c, at);
- pthread_mutex_lock(&self->cache_lock);
- }
- } else {
- s = pos + size; c = CACHE_BUFFER_SIZE - size;
- at = self->buffer + (startp * DVD_VIDEO_LB_LEN);
- if(c > 0) {
- dprintf("(3) Reading from %i to %i to %i ", s, s+c-1, startp);
- pthread_mutex_unlock(&self->cache_lock);
- DVDReadBlocks(self->dvd_self->file, s,c, at);
- pthread_mutex_lock(&self->cache_lock);
- }
- }
-
- dprintf("\n");
-
- self->pos = pos;
- self->start = start; self->size = CACHE_BUFFER_SIZE;
- }
- }
-
- pthread_mutex_unlock(&self->cache_lock);
- cont = (self->buffer != NULL);
- usleep(100);
- }
-
- return NULL;
-}
-
-read_cache_t *dvdnav_read_cache_new(dvdnav_t* dvd_self) {
- read_cache_t *me;
-
- me = (read_cache_t*)malloc(sizeof(struct read_cache_s));
-
- if(me) {
- int err;
-
- me->dvd_self = dvd_self;
- me->buffer = (uint8_t*)malloc(CACHE_BUFFER_SIZE * DVD_VIDEO_LB_LEN);
- me->start = 0;
- me->pos = 0;
- me->read_point = 0;
- me->size = -1;
-
- /* Initialise the mutex */
- pthread_mutex_init(&me->cache_lock, NULL);
-
- if ((err = pthread_create (&me->read_thread,
- NULL, read_cache_read_thread, me)) != 0) {
- dprintf("read_cache: can't create new thread (%s)\n",strerror(err));
- }
- }
-
- return me;
-}
-
-void dvdnav_read_cache_free(read_cache_t* self) {
- dvdnav_t *tmp;
-
- pthread_mutex_lock(&self->cache_lock);
-
- if(self->buffer) {
- free(self->buffer);
- self->buffer = NULL;
- self->size = -2;
- }
-
- pthread_mutex_unlock(&self->cache_lock);
-
- pthread_join(self->read_thread, NULL);
-
- pthread_mutex_destroy(&self->cache_lock);
-
- tmp = self->dvd_self;
- free(self);
-
- /* We free the main structure, too, because we have no buffers out there. */
- free(tmp);
-}
-
-/* This function MUST be called whenever self->file changes. */
-void dvdnav_read_cache_clear(read_cache_t *self) {
- if(!self)
- return;
-
- pthread_mutex_lock(&self->cache_lock);
- self->size = -1;
- self->start = 0;
- self->pos = 0;
- self->read_point = 0;
- pthread_mutex_unlock(&self->cache_lock);
-}
-
-/* This function is called just after reading the NAV packet. */
-void dvdnav_pre_cache_blocks(read_cache_t *self, int sector, size_t block_count) {
- if(!self)
- return;
-
- if(!self->dvd_self->use_read_ahead) {
- return;
- }
-
- pthread_mutex_lock(&self->cache_lock);
- dprintf("Requested pre-cache (%i -> +%i) : current state pos=%i, size=%i.\n",
- sector, block_count, self->pos, self->size);
-
- /* Are the contents of the buffer in any way relevant? */
- if((self->size > 0) && (sector >= self->pos) && (sector <= self->pos+self->size)) {
- dprintf("Contents relevant ... adjusting\n");
- self->read_point = sector;
- } else {
- /* Flush the cache as its not much use */
- dprintf("Contents irrelevent... flushing\n");
- self->size = 0;
- self->start = 0;
- self->pos = sector;
- self->read_point = sector;
- }
-
- pthread_mutex_unlock(&self->cache_lock);
-}
-
-/* This function will do the cache read */
-int dvdnav_read_cache_block( read_cache_t *self, int sector, size_t block_count, uint8_t **buf) {
- int result, diff;
-
- if(!self)
- return 0;
-
- pthread_mutex_lock(&self->cache_lock);
- dprintf("Read from %i -> +%i (buffer pos=%i, read_point=%i, size=%i)... ", sector, block_count,
- self->pos, self->read_point, self->size);
- if((self->size > 0) && (sector >= self->read_point) &&
- (sector + block_count <= self->pos + self->size)) {
- /* Hit */
-
- /* Drop any skipped blocks */
- diff = sector - self->read_point;
- if(diff > 0)
- self->read_point += diff;
-
- diff = self->read_point - self->pos;
-
- if(((self->start + diff) % CACHE_BUFFER_SIZE) + block_count <= CACHE_BUFFER_SIZE) {
- dprintf("************** Single read\n");
- memcpy(*buf, self->buffer + (((self->start + diff) % CACHE_BUFFER_SIZE) * DVD_VIDEO_LB_LEN),
- block_count * DVD_VIDEO_LB_LEN);
- self->read_point += block_count;
- pthread_mutex_unlock(&self->cache_lock);
-
- return (int)block_count;
- } else {
- int32_t boundary = CACHE_BUFFER_SIZE - self->start;
-
- dprintf("************** Multiple read\n");
- memcpy(*buf, self->buffer + (((self->start + diff) % CACHE_BUFFER_SIZE) * DVD_VIDEO_LB_LEN),
- boundary * DVD_VIDEO_LB_LEN);
- memcpy(*buf + (boundary * DVD_VIDEO_LB_LEN), self->buffer,
- (block_count-boundary) * DVD_VIDEO_LB_LEN);
- self->read_point += block_count;
- pthread_mutex_unlock(&self->cache_lock);
-
- return (int)block_count;
- }
- } else {
- /* Miss */
-
- fprintf(MSG_OUT, "libdvdnav: DVD read cache miss! (not bad but a performance hit) sector=%d\n", sector);
- result = DVDReadBlocks( self->dvd_self->file, sector, block_count, *buf);
- self->read_point = sector+block_count;
- if(self->read_point > self->pos + self->size) {
- /* Flush the cache as its not much use */
- dprintf("Contents irrelevent... flushing\n");
- self->size = 0;
- self->start = 0;
- self->pos = sector+block_count;
- }
- pthread_mutex_unlock(&self->cache_lock);
- usleep(300);
- return result;
- }
-
- /* Should never get here */
- return 0;
-}
-
-dvdnav_status_t dvdnav_free_cache_block(dvdnav_t *self, unsigned char *buf) {
- return DVDNAV_STATUS_OK;
-}
-
-#else
read_cache_t *dvdnav_read_cache_new(dvdnav_t* dvd_self) {
read_cache_t *self;
@@ -520,7 +254,8 @@ int dvdnav_read_cache_block(read_cache_t *self, int sector, size_t block_count,
/* Increment read-ahead size if sector follows the last sector */
if (sector == (self->last_sector + 1)) {
- self->read_ahead_incr++;
+ if (self->read_ahead_incr < READ_AHEAD_SIZE_MAX)
+ self->read_ahead_incr++;
} else {
self->read_ahead_size = READ_AHEAD_SIZE_MIN;
self->read_ahead_incr = 0;
@@ -539,34 +274,33 @@ int dvdnav_read_cache_block(read_cache_t *self, int sector, size_t block_count,
chunk->usage_count++;
pthread_mutex_unlock(&self->lock);
- /* Read blocks if needed */
- if (sector >= (chunk->cache_start_sector + chunk->cache_read_count)) {
+ dprintf("libdvdnav: sector=%d, start_sector=%d, last_sector=%d\n", sector, chunk->cache_start_sector, chunk->cache_start_sector + chunk->cache_block_count);
- dprintf("libdvdnav: sector=%d, start_sector=%d, last_sector=%d\n", sector, chunk->cache_start_sector, chunk->cache_start_sector + chunk->cache_block_count);
-
- /* read_ahead_size */
- incr = self->read_ahead_incr >> 1;
- if ((self->read_ahead_size + incr) > READ_AHEAD_SIZE_MAX) {
- self->read_ahead_size = READ_AHEAD_SIZE_MAX;
- } else {
- self->read_ahead_size = self->read_ahead_size + incr;
- }
- self->read_ahead_incr = 0;
+ /* read_ahead_size */
+ incr = self->read_ahead_incr >> 1;
+ if ((self->read_ahead_size + incr) > READ_AHEAD_SIZE_MAX) {
+ self->read_ahead_size = READ_AHEAD_SIZE_MAX;
+ } else {
+ self->read_ahead_size += incr;
+ }
- /* real read size */
- start = chunk->cache_start_sector + chunk->cache_read_count;
- if (chunk->cache_read_count + self->read_ahead_size > chunk->cache_block_count) {
- size = chunk->cache_block_count - chunk->cache_read_count;
- } else {
- size = self->read_ahead_size;
- }
- dprintf("libdvdnav: read_ahead_size=%d, size=%d\n", self->read_ahead_size, size);
+ /* real read size */
+ start = chunk->cache_start_sector + chunk->cache_read_count;
+ if (chunk->cache_read_count + self->read_ahead_size > chunk->cache_block_count) {
+ size = chunk->cache_block_count - chunk->cache_read_count;
+ } else {
+ size = self->read_ahead_size;
+ /* ensure that the sector we want will be read */
+ if (sector >= chunk->cache_start_sector + chunk->cache_read_count + size)
+ size = sector - chunk->cache_start_sector - chunk->cache_read_count;
+ }
+ dprintf("libdvdnav: read_ahead_size=%d, size=%d\n", self->read_ahead_size, size);
+ if (size)
chunk->cache_read_count += DVDReadBlocks(self->dvd_self->file,
start,
size,
read_ahead_buf);
- }
res = DVD_VIDEO_LB_LEN * block_count;
@@ -611,5 +345,3 @@ dvdnav_status_t dvdnav_free_cache_block(dvdnav_t *self, unsigned char *buf) {
return DVDNAV_STATUS_OK;
}
-
-#endif
diff --git a/src/input/libdvdnav/searching.c b/src/input/libdvdnav/searching.c
index 4ccf239d9..2b4c534cc 100644
--- a/src/input/libdvdnav/searching.c
+++ b/src/input/libdvdnav/searching.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: searching.c,v 1.17 2003/05/11 13:44:05 jcdutton Exp $
+ * $Id: searching.c,v 1.18 2004/03/16 11:43:38 mroi Exp $
*
*/
@@ -405,7 +405,7 @@ dvdnav_status_t dvdnav_get_position(dvdnav_t *this, uint32_t *pos,
pthread_mutex_lock(&this->vm_lock);
state = &(this->vm->state);
- if(!state->pgc) {
+ if(!state->pgc || this->vm->stopped) {
printerr("No current PGC.");
pthread_mutex_unlock(&this->vm_lock);
return DVDNAV_STATUS_ERR;
diff --git a/src/input/libdvdnav/settings.c b/src/input/libdvdnav/settings.c
index d8901821e..62fcc7933 100644
--- a/src/input/libdvdnav/settings.c
+++ b/src/input/libdvdnav/settings.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: settings.c,v 1.6 2003/05/11 13:44:05 jcdutton Exp $
+ * $Id: settings.c,v 1.7 2004/03/16 11:43:38 mroi Exp $
*
*/
@@ -29,7 +29,7 @@
/* Characteristics/setting API calls */
-dvdnav_status_t dvdnav_get_region_mask(dvdnav_t *this, int *region) {
+dvdnav_status_t dvdnav_get_region_mask(dvdnav_t *this, int32_t *region) {
if(!this || !region) {
printerr("Passed a NULL this pointer.");
return DVDNAV_STATUS_ERR;
@@ -39,7 +39,7 @@ dvdnav_status_t dvdnav_get_region_mask(dvdnav_t *this, int *region) {
return DVDNAV_STATUS_OK;
}
-dvdnav_status_t dvdnav_set_region_mask(dvdnav_t *this, int mask) {
+dvdnav_status_t dvdnav_set_region_mask(dvdnav_t *this, int32_t mask) {
if(!this) {
printerr("Passed a NULL this pointer.");
return DVDNAV_STATUS_ERR;
@@ -51,7 +51,7 @@ dvdnav_status_t dvdnav_set_region_mask(dvdnav_t *this, int mask) {
return DVDNAV_STATUS_OK;
}
-dvdnav_status_t dvdnav_set_readahead_flag(dvdnav_t *this, int use_readahead) {
+dvdnav_status_t dvdnav_set_readahead_flag(dvdnav_t *this, int32_t use_readahead) {
if(!this) {
printerr("Passed a NULL this pointer.");
return DVDNAV_STATUS_ERR;
@@ -61,7 +61,7 @@ dvdnav_status_t dvdnav_set_readahead_flag(dvdnav_t *this, int use_readahead) {
return DVDNAV_STATUS_OK;
}
-dvdnav_status_t dvdnav_get_readahead_flag(dvdnav_t *this, int *flag) {
+dvdnav_status_t dvdnav_get_readahead_flag(dvdnav_t *this, int32_t *flag) {
if(!this || !flag) {
printerr("Passed a NULL this pointer.");
return DVDNAV_STATUS_ERR;
@@ -100,7 +100,7 @@ dvdnav_status_t dvdnav_spu_language_select(dvdnav_t *this, char *code) {
return set_language_register(this, code, 18);
}
-dvdnav_status_t dvdnav_set_PGC_positioning_flag(dvdnav_t *this, int pgc) {
+dvdnav_status_t dvdnav_set_PGC_positioning_flag(dvdnav_t *this, int32_t pgc) {
if(!this) {
printerr("Passed a NULL this pointer.");
return DVDNAV_STATUS_ERR;
@@ -110,7 +110,7 @@ dvdnav_status_t dvdnav_set_PGC_positioning_flag(dvdnav_t *this, int pgc) {
return DVDNAV_STATUS_OK;
}
-dvdnav_status_t dvdnav_get_PGC_positioning_flag(dvdnav_t *this, int *flag) {
+dvdnav_status_t dvdnav_get_PGC_positioning_flag(dvdnav_t *this, int32_t *flag) {
if(!this || !flag) {
printerr("Passed a NULL this pointer.");
return DVDNAV_STATUS_ERR;
diff --git a/src/input/libdvdnav/vm.c b/src/input/libdvdnav/vm.c
index fc8d9f570..223b8e85b 100644
--- a/src/input/libdvdnav/vm.c
+++ b/src/input/libdvdnav/vm.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2000, 2001 Håkan Hjort
* Copyright (C) 2001 Rich Wareham <richwareham@users.sourceforge.net>
+ * 2002-2004 the dvdnav project
*
* This file is part of libdvdnav, a DVD navigation library. It is modified
* from a file originally part of the Ogle DVD player.
@@ -19,7 +20,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: vm.c,v 1.26 2004/01/07 22:21:40 hadess Exp $
+ * $Id: vm.c,v 1.27 2004/03/16 11:43:38 mroi Exp $
*
*/
@@ -44,14 +45,8 @@
#ifdef _MSC_VER
#include <io.h> /* read() */
-#define lseek64 lseek
#endif /* _MSC_VER */
-#ifdef __CYGWIN__
-# define off64_t off_t
-# define lseek64 lseek
-#endif
-
/*
#define STRICT
*/
@@ -132,22 +127,21 @@ static void vm_print_current_domain_state(vm_t *vm) {
#endif
static void dvd_read_name(char *name, const char *device) {
- int fd, i;
-#if !defined(__FreeBSD__) && !defined(WIN32)
- off64_t off;
-#else
+ /* Because we are compiling with _FILE_OFFSET_BITS=64
+ * all off_t are 64bit.
+ */
off_t off;
-#endif
+ int fd, i;
uint8_t data[DVD_VIDEO_LB_LEN];
/* Read DVD name */
- fd=open(device, O_RDONLY|O_EXCL);
+ fd = open(device, O_RDONLY | O_EXCL);
if (fd > 0) {
- off = lseek64( fd, 32 * (int64_t) DVD_VIDEO_LB_LEN, SEEK_SET );
- if( off == ( 32 * (int64_t) DVD_VIDEO_LB_LEN ) ) {
+ off = lseek( fd, 32 * (off_t) DVD_VIDEO_LB_LEN, SEEK_SET );
+ if( off == ( 32 * (off_t) DVD_VIDEO_LB_LEN ) ) {
off = read( fd, data, DVD_VIDEO_LB_LEN );
close(fd);
- if (off == ( (int64_t) DVD_VIDEO_LB_LEN )) {
+ if (off == ( (off_t) DVD_VIDEO_LB_LEN )) {
fprintf(MSG_OUT, "libdvdnav: DVD Title: ");
for(i=25; i < 73; i++ ) {
if((data[i] == 0)) break;
@@ -201,27 +195,27 @@ static void ifoOpenNewVTSI(vm_t *vm, dvd_reader_t *dvd, int vtsN) {
vm->vtsi = ifoOpenVTSI(dvd, vtsN);
if(vm->vtsi == NULL) {
fprintf(MSG_OUT, "libdvdnav: ifoOpenVTSI failed - CRASHING!!!\n");
- abort();
+ assert(0);
}
if(!ifoRead_VTS_PTT_SRPT(vm->vtsi)) {
fprintf(MSG_OUT, "libdvdnav: ifoRead_VTS_PTT_SRPT failed - CRASHING!!!\n");
- abort();
+ assert(0);
}
if(!ifoRead_PGCIT(vm->vtsi)) {
fprintf(MSG_OUT, "libdvdnav: ifoRead_PGCIT failed - CRASHING!!!\n");
- abort();
+ assert(0);
}
if(!ifoRead_PGCI_UT(vm->vtsi)) {
fprintf(MSG_OUT, "libdvdnav: ifoRead_PGCI_UT failed - CRASHING!!!\n");
- abort();
+ assert(0);
}
if(!ifoRead_VOBU_ADMAP(vm->vtsi)) {
fprintf(MSG_OUT, "libdvdnav: ifoRead_VOBU_ADMAP vtsi failed - CRASHING\n");
- abort();
+ assert(0);
}
if(!ifoRead_TITLE_VOBU_ADMAP(vm->vtsi)) {
fprintf(MSG_OUT, "libdvdnav: ifoRead_TITLE_VOBU_ADMAP vtsi failed - CRASHING\n");
- abort();
+ assert(0);
}
(vm->state).vtsN = vtsN;
}
@@ -392,7 +386,7 @@ vm_t *vm_new_copy(vm_t *source) {
/* restore pgc pointer into the new vtsi */
if (!set_PGCN(target, pgcN))
- abort();
+ assert(0);
(target->state).pgN = pgN;
}
@@ -430,7 +424,7 @@ void vm_position_get(vm_t *vm, vm_position_t *position) {
position->block = (vm->state).blockN;
/* handle PGC stills at PGC end */
- if ((vm->state).cellN == (vm->state).pgc->nr_of_cells && (vm->state).pgc->still_time)
+ if ((vm->state).cellN == (vm->state).pgc->nr_of_cells)
position->still += (vm->state).pgc->still_time;
/* still already determined */
if (position->still)
@@ -487,13 +481,20 @@ int vm_jump_cell_block(vm_t *vm, int cell, int block) {
}
int vm_jump_title_part(vm_t *vm, int title, int part) {
+ link_t link;
+
if(!set_PTT(vm, title, part))
return 0;
/* Some DVDs do not want us to jump directly into a title and have
* PGC pre commands taking us back to some menu. Since we do not like that,
- * we do not execute PGC pre commands but directly play the PG. */
+ * we do not execute PGC pre commands that would do a jump. */
/* process_command(vm, play_PGC_PG(vm, (vm->state).pgN)); */
- process_command(vm, play_PG(vm));
+ link = play_PGC_PG(vm, (vm->state).pgN);
+ if (link.command != PlayThis)
+ /* jump occured -> ignore it and play the PG anyway */
+ process_command(vm, play_PG(vm));
+ else
+ process_command(vm, link);
return 1;
}
@@ -665,7 +666,7 @@ int vm_get_audio_stream(vm_t *vm, int audioN) {
audioN = 0;
if(audioN < 8) {
- /* Is there any contol info for this logical stream */
+ /* Is there any control info for this logical stream */
if((vm->state).pgc->audio_control[audioN] & (1<<15)) {
streamN = ((vm->state).pgc->audio_control[audioN] >> 8) & 0x07;
}
@@ -866,8 +867,9 @@ video_attr_t vm_get_video_attr(vm_t *vm) {
case VMGM_DOMAIN:
case FP_DOMAIN:
return vm->vmgi->vmgi_mat->vmgm_video_attr;
+ default:
+ abort();
}
- abort();
}
audio_attr_t vm_get_audio_attr(vm_t *vm, int streamN) {
@@ -879,8 +881,9 @@ audio_attr_t vm_get_audio_attr(vm_t *vm, int streamN) {
case VMGM_DOMAIN:
case FP_DOMAIN:
return vm->vmgi->vmgi_mat->vmgm_audio_attr;
+ default:
+ abort();
}
- abort();
}
subp_attr_t vm_get_subp_attr(vm_t *vm, int streamN) {
@@ -892,8 +895,9 @@ subp_attr_t vm_get_subp_attr(vm_t *vm, int streamN) {
case VMGM_DOMAIN:
case FP_DOMAIN:
return vm->vmgi->vmgi_mat->vmgm_subp_attr;
+ default:
+ abort();
}
- abort();
}
@@ -986,9 +990,6 @@ static link_t play_PGC_post(vm_t *vm) {
fprintf(MSG_OUT, "libdvdnav: play_PGC_post:\n");
#endif
- /* FIXME: Implement PGC Stills. Currently only Cell stills work */
- assert((vm->state).pgc->still_time == 0);
-
/* eval -> updates the state and returns either
- some kind of jump (Jump(TT/SS/VTS_TTN/CallSS/link C/PG/PGC/PTTN)
- just go to next PGC
@@ -1057,7 +1058,8 @@ static link_t play_Cell(vm_t *vm) {
case 1: /* The first cell in the block */
switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type) {
case 0: /* Not part of a block */
- abort();
+ assert(0);
+ break;
case 1: /* Angle block */
/* Loop and check each cell instead? So we don't get outside the block? */
(vm->state).cellN += (vm->state).AGL_REG - 1;
@@ -1080,7 +1082,7 @@ static link_t play_Cell(vm_t *vm) {
fprintf(MSG_OUT, "libdvdnav: Invalid? Cell block_mode (%d), block_type (%d)\n",
(vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode,
(vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type);
- abort();
+ assert(0);
}
break;
case 2: /* Cell in the block */
@@ -1093,7 +1095,7 @@ static link_t play_Cell(vm_t *vm) {
/* Updates (vm->state).pgN and PTTN_REG */
if(!set_PGN(vm)) {
/* Should not happen */
- abort();
+ assert(0);
return play_PGC_post(vm);
}
(vm->state).cell_restart++;
@@ -1161,7 +1163,8 @@ static link_t play_Cell_post(vm_t *vm) {
default:
switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type) {
case 0: /* Not part of a block */
- abort();
+ assert(0);
+ break;
case 1: /* Angle block */
/* Skip the 'other' angles */
(vm->state).cellN++;
@@ -1176,7 +1179,7 @@ static link_t play_Cell_post(vm_t *vm) {
fprintf(MSG_OUT, "libdvdnav: Invalid? Cell block_mode (%d), block_type (%d)\n",
(vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode,
(vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type);
- abort();
+ assert(0);
}
break;
}
@@ -1278,7 +1281,7 @@ static int process_command(vm_t *vm, link_t link_values) {
(vm->state).HL_BTNN_REG = link_values.data1 << 10;
assert((vm->state).pgc->next_pgc_nr != 0);
if(!set_PGCN(vm, (vm->state).pgc->next_pgc_nr))
- abort();
+ assert(0);
link_values = play_PGC(vm);
break;
case LinkPrevPGC:
@@ -1288,7 +1291,7 @@ static int process_command(vm_t *vm, link_t link_values) {
(vm->state).HL_BTNN_REG = link_values.data1 << 10;
assert((vm->state).pgc->prev_pgc_nr != 0);
if(!set_PGCN(vm, (vm->state).pgc->prev_pgc_nr))
- abort();
+ assert(0);
link_values = play_PGC(vm);
break;
case LinkGoUpPGC:
@@ -1298,7 +1301,7 @@ static int process_command(vm_t *vm, link_t link_values) {
(vm->state).HL_BTNN_REG = link_values.data1 << 10;
assert((vm->state).pgc->goup_pgc_nr != 0);
if(!set_PGCN(vm, (vm->state).pgc->goup_pgc_nr))
- abort();
+ assert(0);
link_values = play_PGC(vm);
break;
case LinkTailPGC:
@@ -1346,7 +1349,7 @@ static int process_command(vm_t *vm, link_t link_values) {
link_values.data1 = (vm->state).rsm_blockN;
if(!set_PGN(vm)) {
/* Were at the end of the PGC, should not happen for a RSM */
- abort();
+ assert(0);
link_values.command = LinkTailPGC;
link_values.data1 = 0; /* No button */
}
@@ -1356,7 +1359,7 @@ static int process_command(vm_t *vm, link_t link_values) {
case LinkPGCN:
/* Link to Program Chain Number:data1 */
if(!set_PGCN(vm, link_values.data1))
- abort();
+ assert(0);
link_values = play_PGC(vm);
break;
case LinkPTTN:
@@ -1367,7 +1370,7 @@ static int process_command(vm_t *vm, link_t link_values) {
if(link_values.data2 != 0)
(vm->state).HL_BTNN_REG = link_values.data2 << 10;
if(!set_VTS_PTT(vm, (vm->state).vtsN, (vm->state).VTS_TTN_REG, link_values.data1))
- abort();
+ assert(0);
link_values = play_PG(vm);
break;
case LinkPGN:
@@ -1401,7 +1404,7 @@ static int process_command(vm_t *vm, link_t link_values) {
/* Set SPRM1 and SPRM2 */
assert((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN); /* ?? */
if(!set_TT(vm, link_values.data1))
- abort();
+ assert(0);
link_values = play_PGC(vm);
break;
case JumpVTS_TT:
@@ -1412,7 +1415,7 @@ static int process_command(vm_t *vm, link_t link_values) {
/* Set SPRM1 and SPRM2 */
assert((vm->state).domain == VTSM_DOMAIN || (vm->state).domain == VTS_DOMAIN); /* ?? */
if(!set_VTS_TT(vm, (vm->state).vtsN, link_values.data1))
- abort();
+ assert(0);
link_values = play_PGC(vm);
break;
case JumpVTS_PTT:
@@ -1423,7 +1426,7 @@ static int process_command(vm_t *vm, link_t link_values) {
/* Set SPRM1 and SPRM2 */
assert((vm->state).domain == VTSM_DOMAIN || (vm->state).domain == VTS_DOMAIN); /* ?? */
if(!set_VTS_PTT(vm, (vm->state).vtsN, link_values.data1, link_values.data2))
- abort();
+ assert(0);
link_values = play_PGC_PG(vm, (vm->state).pgN);
break;
@@ -1434,7 +1437,7 @@ static int process_command(vm_t *vm, link_t link_values) {
/* Stop SPRM9 Timer and any GPRM counters */
assert((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == VTSM_DOMAIN); /* ?? */
if (!set_FP_PGC(vm))
- abort();
+ assert(0);
link_values = play_PGC(vm);
break;
case JumpSS_VMGM_MENU:
@@ -1444,31 +1447,29 @@ static int process_command(vm_t *vm, link_t link_values) {
assert((vm->state).domain != VTS_DOMAIN); /* ?? */
(vm->state).domain = VMGM_DOMAIN;
if(!set_MENU(vm, link_values.data1))
- abort();
+ assert(0);
link_values = play_PGC(vm);
break;
case JumpSS_VTSM:
/* Jump to a menu in Video Title domain, */
/* or to a Menu is the current VTS */
/* Stop SPRM9 Timer and any GPRM counters */
- /* FIXME: This goes badly wrong for some DVDs. */
- /* FIXME: Keep in touch with ogle people regarding what to do here */
/* ifoOpenNewVTSI:data1 */
/* VTS_TTN_REG:data2 */
/* get_MENU:data3 */
-#ifdef TRACE
- fprintf(MSG_OUT, "libdvdnav: BUG TRACKING *******************************************************************\n");
- fprintf(MSG_OUT, "libdvdnav: data1=%u data2=%u data3=%u\n",
- link_values.data1,
- link_values.data2,
- link_values.data3);
- fprintf(MSG_OUT, "libdvdnav: *******************************************************************\n");
-#endif
-
if(link_values.data1 != 0) {
- assert((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN); /* ?? */
- (vm->state).domain = VTSM_DOMAIN;
- ifoOpenNewVTSI(vm, vm->dvd, link_values.data1); /* Also sets (vm->state).vtsN */
+ if (link_values.data1 != (vm->state).vtsN) {
+ /* the normal case */
+ assert((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN); /* ?? */
+ (vm->state).domain = VTSM_DOMAIN;
+ ifoOpenNewVTSI(vm, vm->dvd, link_values.data1); /* Also sets (vm->state).vtsN */
+ } else {
+ /* This happens on some discs like "Captain Scarlet & the Mysterons" or
+ * the German RC2 of "Anatomie" in VTSM. */
+ assert((vm->state).domain == VTSM_DOMAIN ||
+ (vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN); /* ?? */
+ (vm->state).domain = VTSM_DOMAIN;
+ }
} else {
/* This happens on 'The Fifth Element' region 2. */
assert((vm->state).domain == VTSM_DOMAIN);
@@ -1477,8 +1478,11 @@ static int process_command(vm_t *vm, link_t link_values) {
/* Alien or Aliens has this != 1, I think. */
/* assert(link_values.data2 == 1); */
(vm->state).VTS_TTN_REG = link_values.data2;
+ /* TTN_REG (SPRM4), VTS_TTN_REG (SPRM5), TT_PGCN_REG (SPRM6) are linked, */
+ /* so if one changes, the others must change to match it. */
+ (vm->state).TTN_REG = get_TT(vm, (vm->state).vtsN, (vm->state).VTS_TTN_REG);
if(!set_MENU(vm, link_values.data3))
- abort();
+ assert(0);
link_values = play_PGC(vm);
break;
case JumpSS_VMGM_PGC:
@@ -1487,7 +1491,7 @@ static int process_command(vm_t *vm, link_t link_values) {
assert((vm->state).domain != VTS_DOMAIN); /* ?? */
(vm->state).domain = VMGM_DOMAIN;
if(!set_PGCN(vm, link_values.data1))
- abort();
+ assert(0);
link_values = play_PGC(vm);
break;
@@ -1507,7 +1511,7 @@ static int process_command(vm_t *vm, link_t link_values) {
set_RSMinfo(vm, link_values.data2, /* We dont have block info */ 0);
(vm->state).domain = VMGM_DOMAIN;
if(!set_MENU(vm, link_values.data1))
- abort();
+ assert(0);
link_values = play_PGC(vm);
break;
case CallSS_VTSM:
@@ -1518,7 +1522,7 @@ static int process_command(vm_t *vm, link_t link_values) {
set_RSMinfo(vm, link_values.data2, /* We dont have block info */ 0);
(vm->state).domain = VTSM_DOMAIN;
if(!set_MENU(vm, link_values.data1))
- abort();
+ assert(0);
link_values = play_PGC(vm);
break;
case CallSS_VMGM_PGC:
@@ -1529,12 +1533,12 @@ static int process_command(vm_t *vm, link_t link_values) {
set_RSMinfo(vm, link_values.data2, /* We dont have block info */ 0);
(vm->state).domain = VMGM_DOMAIN;
if(!set_PGCN(vm, link_values.data1))
- abort();
+ assert(0);
link_values = play_PGC(vm);
break;
case PlayThis:
/* Should never happen. */
- abort();
+ assert(0);
break;
}
@@ -1652,13 +1656,6 @@ static int set_PGN(vm_t *vm) {
pb_ty = &vm->vmgi->tt_srpt->title[(vm->state).TTN_REG - 1].pb_ty;
if(pb_ty->multi_or_random_pgc_title == /* One_Sequential_PGC_Title */ 0) {
int dummy, part;
-#if 0
- /* TTN_REG can't be trusted to have a correct value here... */
- vts_ptt_srpt_t *ptt_srpt = vtsi->vts_ptt_srpt;
- assert((vm->state).VTS_TTN_REG <= ptt_srpt->nr_of_srpts);
- assert(get_PGCN() == ptt_srpt->title[(vm->state).VTS_TTN_REG - 1].ptt[0].pgcn);
- assert(1 == ptt_srpt->title[(vm->state).VTS_TTN_REG - 1].ptt[0].pgn);
-#endif
vm_get_current_title_part(vm, &dummy, &part);
(vm->state).PTTN_REG = part;
} else {
@@ -1759,8 +1756,10 @@ static int get_PGCN(vm_t *vm) {
if (pgcit) {
while(pgcN <= pgcit->nr_of_pgci_srp) {
- if(pgcit->pgci_srp[pgcN - 1].pgc == (vm->state).pgc)
+ if(pgcit->pgci_srp[pgcN - 1].pgc == (vm->state).pgc) {
+ assert((vm->state).pgcN == pgcN);
return pgcN;
+ }
pgcN++;
}
}
@@ -1815,11 +1814,7 @@ static pgcit_t* get_PGCIT(vm_t *vm) {
pgcit = get_MENU_PGCIT(vm, vm->vmgi, (vm->state).registers.SPRM[0]);
break;
default:
- pgcit = NULL; /* Should never hapen */
- fprintf(MSG_OUT, "libdvdnav: get_PGCIT: Unknown domain:%d\n",
- (vm->state).domain);
abort();
- break;
}
return pgcit;
diff --git a/src/input/libdvdnav/vmcmd.c b/src/input/libdvdnav/vmcmd.c
index 55c8e4a22..30f32576f 100644
--- a/src/input/libdvdnav/vmcmd.c
+++ b/src/input/libdvdnav/vmcmd.c
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2000, 2001 Martin Norbäck, Håkan Hjort
+ * 2002-2004 the dvdnav project
*
* This file is part of libdvdnav, a DVD navigation library. It is modified
* from a file originally part of the Ogle DVD player.
@@ -18,7 +19,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: vmcmd.c,v 1.5 2003/04/07 18:10:52 mroi Exp $
+ * $Id: vmcmd.c,v 1.6 2004/03/16 11:43:38 mroi Exp $
*
*/
@@ -29,13 +30,9 @@
#include <stdio.h>
#include <ctype.h>
#include <inttypes.h>
-#include <assert.h>
#include "dvdnav_internal.h"
-
-#ifdef TRACE
-
/* freebsd compatibility */
#ifndef PRIu8
#define PRIu8 "d"
@@ -152,7 +149,7 @@ static void print_set_op(uint8_t op) {
static void print_reg_or_data(command_t* command, int immediate, int start) {
if(immediate) {
- int i = vm_getbits(command, start, 16);
+ uint32_t i = vm_getbits(command, start, 16);
fprintf(MSG_OUT, "0x%x", i);
if(isprint(i & 0xff) && isprint((i>>8) & 0xff))
@@ -171,7 +168,7 @@ static void print_reg_or_data_2(command_t* command, int immediate, int start) {
static void print_reg_or_data_3(command_t* command, int immediate, int start) {
if(immediate) {
- int i = vm_getbits(command, start, 16);
+ uint32_t i = vm_getbits(command, start, 16);
fprintf(MSG_OUT, "0x%x", i);
if(isprint(i & 0xff) && isprint((i>>8) & 0xff))
@@ -275,8 +272,8 @@ static void print_special_instruction(command_t* command) {
}
static void print_linksub_instruction(command_t* command) {
- int linkop = vm_getbits(command, 7, 8);
- int button = vm_getbits(command, 15, 6);
+ uint32_t linkop = vm_getbits(command, 7, 8);
+ uint32_t button = vm_getbits(command, 15, 6);
if(linkop < sizeof(link_table)/sizeof(char *) && link_table[linkop] != NULL)
fprintf(MSG_OUT, "%s (button %" PRIu8 ")", link_table[linkop], button);
@@ -540,4 +537,3 @@ void vm_print_cmd(int row, vm_cmd_t *vm_command) {
fprintf(MSG_OUT, "\n");
}
-#endif