OSDN Git Service

bump ffmpeg to rev 22950
[handbrake-jp/handbrake-jp-git.git] / contrib / libdvdnav / A08-dvdnav-dup.patch
1 Index: src/dvdnav.c
2 ===================================================================
3 --- libdvdnav.orig/src/dvdnav.c (revision 1168)
4 +++ libdvdnav/src/dvdnav.c      (working copy)
5 @@ -71,6 +71,67 @@
6    return DVDNAV_STATUS_OK;
7  }
8  
9 +dvdnav_status_t dvdnav_dup(dvdnav_t **dest, dvdnav_t *src) {
10 +  dvdnav_t *this;
11 +
12 +  (*dest) = NULL;
13 +  this = (dvdnav_t*)malloc(sizeof(dvdnav_t));
14 +  if(!this)
15 +    return DVDNAV_STATUS_ERR;
16 +
17 +  memcpy(this, src, sizeof(dvdnav_t));
18 +  this->file = NULL;
19 +
20 +  pthread_mutex_init(&this->vm_lock, NULL);
21 +
22 +  this->vm = vm_new_copy(src->vm);
23 +  if(!this->vm) {
24 +    printerr("Error initialising the DVD VM.");
25 +    pthread_mutex_destroy(&this->vm_lock);
26 +    free(this);
27 +    return DVDNAV_STATUS_ERR;
28 +  }
29 +
30 +  /* Start the read-ahead cache. */
31 +  this->cache = dvdnav_read_cache_new(this);
32 +
33 +  (*dest) = this;
34 +  return DVDNAV_STATUS_OK;
35 +}
36 +
37 +dvdnav_status_t dvdnav_free_dup(dvdnav_t *this) {
38 +
39 +#ifdef LOG_DEBUG
40 +  fprintf(MSG_OUT, "libdvdnav: free_dup:called\n");
41 +#endif
42 +
43 +  if (this->file) {
44 +    pthread_mutex_lock(&this->vm_lock);
45 +    DVDCloseFile(this->file);
46 +#ifdef LOG_DEBUG
47 +    fprintf(MSG_OUT, "libdvdnav: close:file closing\n");
48 +#endif
49 +    this->file = NULL;
50 +    pthread_mutex_unlock(&this->vm_lock);
51 +  }
52 +
53 +  /* Free the VM */
54 +  if(this->vm)
55 +    vm_free_copy(this->vm);
56 +
57 +  pthread_mutex_destroy(&this->vm_lock);
58 +
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. */
62 +  if(this->cache)
63 +    dvdnav_read_cache_free(this->cache);
64 +  else
65 +    free(this);
66 +
67 +  return DVDNAV_STATUS_OK;
68 +}
69 +
70  dvdnav_status_t dvdnav_open(dvdnav_t** dest, const char *path) {
71    dvdnav_t *this;
72    struct timeval time;
73 Index: src/dvdnav/dvdnav.h
74 ===================================================================
75 --- libdvdnav.orig/src/dvdnav/dvdnav.h  (revision 1168)
76 +++ libdvdnav/src/dvdnav/dvdnav.h       (working copy)
77 @@ -89,6 +89,9 @@
78   */
79  dvdnav_status_t dvdnav_open(dvdnav_t **dest, const char *path);
80  
81 +dvdnav_status_t dvdnav_dup(dvdnav_t **dest, dvdnav_t *src);
82 +dvdnav_status_t dvdnav_free_dup(dvdnav_t *this);
83 +
84  /*
85   * Closes a dvdnav_t previously opened with dvdnav_open(), freeing any
86   * memory associated with it.
87 Index: src/vm/vm.c
88 ===================================================================
89 --- libdvdnav.orig/src/vm/vm.c  (revision 1168)
90 +++ libdvdnav/src/vm/vm.c       (working copy)
91 @@ -96,6 +98,7 @@
92  
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);
96  
97  
98  /* Helper functions */
99 @@ -262,7 +265,7 @@
100  }
101  
102  void vm_free_vm(vm_t *vm) {
103 -  vm_stop(vm);
104 +  vm_close(vm);
105    free(vm);
106  }
107  
108 @@ -289,12 +292,20 @@
109  
110  int vm_start(vm_t *vm) {
111    /* Set pgc to FP (First Play) pgc */
112 +  if (vm->stopped) {
113 +    vm_reset(vm, NULL);
114 +    vm->stopped = 0;
115 +  }
116    set_FP_PGC(vm);
117    process_command(vm, play_PGC(vm));
118    return !vm->stopped;
119  }
120  
121  void vm_stop(vm_t *vm) {
122 +  vm->stopped = 1;
123 +}
124 +
125 +static void vm_close(vm_t *vm) {
126    if(vm->vmgi) {
127      ifoClose(vm->vmgi);
128      vm->vmgi=NULL;
129 @@ -346,7 +357,7 @@
130  
131    if (vm->dvd && dvdroot) {
132      /* a new dvd device has been requested */
133 -    vm_stop(vm);
134 +    vm_close(vm);
135    }
136    if (!vm->dvd) {
137      vm->dvd = DVDOpen(dvdroot);