2 ===================================================================
3 --- libdvdnav.orig/src/dvdnav.c (revision 1168)
4 +++ libdvdnav/src/dvdnav.c (working copy)
6 return DVDNAV_STATUS_OK;
9 +dvdnav_status_t dvdnav_dup(dvdnav_t **dest, dvdnav_t *src) {
13 + this = (dvdnav_t*)malloc(sizeof(dvdnav_t));
15 + return DVDNAV_STATUS_ERR;
17 + memcpy(this, src, sizeof(dvdnav_t));
20 + pthread_mutex_init(&this->vm_lock, NULL);
22 + this->vm = vm_new_copy(src->vm);
24 + printerr("Error initialising the DVD VM.");
25 + pthread_mutex_destroy(&this->vm_lock);
27 + return DVDNAV_STATUS_ERR;
30 + /* Start the read-ahead cache. */
31 + this->cache = dvdnav_read_cache_new(this);
34 + return DVDNAV_STATUS_OK;
37 +dvdnav_status_t dvdnav_free_dup(dvdnav_t *this) {
40 + fprintf(MSG_OUT, "libdvdnav: free_dup:called\n");
44 + pthread_mutex_lock(&this->vm_lock);
45 + DVDCloseFile(this->file);
47 + fprintf(MSG_OUT, "libdvdnav: close:file closing\n");
50 + pthread_mutex_unlock(&this->vm_lock);
55 + vm_free_copy(this->vm);
57 + pthread_mutex_destroy(&this->vm_lock);
59 + /* We leave the final freeing of the entire structure to the cache,
60 + * because we don't know, if there are still buffers out in the wild,
61 + * that must return first. */
63 + dvdnav_read_cache_free(this->cache);
67 + return DVDNAV_STATUS_OK;
70 dvdnav_status_t dvdnav_open(dvdnav_t** dest, const char *path) {
73 Index: src/dvdnav/dvdnav.h
74 ===================================================================
75 --- libdvdnav.orig/src/dvdnav/dvdnav.h (revision 1168)
76 +++ libdvdnav/src/dvdnav/dvdnav.h (working copy)
79 dvdnav_status_t dvdnav_open(dvdnav_t **dest, const char *path);
81 +dvdnav_status_t dvdnav_dup(dvdnav_t **dest, dvdnav_t *src);
82 +dvdnav_status_t dvdnav_free_dup(dvdnav_t *this);
85 * Closes a dvdnav_t previously opened with dvdnav_open(), freeing any
86 * memory associated with it.
88 ===================================================================
89 --- libdvdnav.orig/src/vm/vm.c (revision 1168)
90 +++ libdvdnav/src/vm/vm.c (working copy)
93 static pgcit_t* get_MENU_PGCIT(vm_t *vm, ifo_handle_t *h, uint16_t lang);
94 static pgcit_t* get_PGCIT(vm_t *vm);
95 +static void vm_close(vm_t *vm);
98 /* Helper functions */
102 void vm_free_vm(vm_t *vm) {
108 @@ -289,12 +292,20 @@
110 int vm_start(vm_t *vm) {
111 /* Set pgc to FP (First Play) pgc */
113 + vm_reset(vm, NULL);
117 process_command(vm, play_PGC(vm));
121 void vm_stop(vm_t *vm) {
125 +static void vm_close(vm_t *vm) {
131 if (vm->dvd && dvdroot) {
132 /* a new dvd device has been requested */
137 vm->dvd = DVDOpen(dvdroot);