comparison navigation.c @ 114:b6834e6359cf src

big libdvdnav cleanup, quoting the ChangeLog: * some bugfixes * code cleanup * build process polishing * more sensible event order in get_next_block to ensure useful event delivery * VOBU level resume * fixed: seeking in a multiangle feature briefly showed the wrong angle
author mroi
date Thu, 20 Feb 2003 15:32:21 +0000
parents e7ebabe059b9
children 4d711d0518e9
comparison
equal deleted inserted replaced
113:ec2df154be56 114:b6834e6359cf
23 23
24 #ifdef HAVE_CONFIG_H 24 #ifdef HAVE_CONFIG_H
25 #include "config.h" 25 #include "config.h"
26 #endif 26 #endif
27 27
28 #include <dvdnav.h>
29 #include "dvdnav_internal.h" 28 #include "dvdnav_internal.h"
30 29
31 #include "vm.h" 30 #include "vm.h"
32 31
33 /* Navigation API calls */ 32 /* Navigation API calls */
34 33
35 dvdnav_status_t dvdnav_still_skip(dvdnav_t *this) { 34 dvdnav_status_t dvdnav_still_skip(dvdnav_t *this) {
36 if(!this) 35 if(!this) {
37 return S_ERR; 36 printerr("Passed a NULL pointer.");
37 return S_ERR;
38 }
38 39
39 this->position_current.still = 0; 40 this->position_current.still = 0;
40 this->skip_still = 1; 41 this->skip_still = 1;
41 42
42 return S_OK; 43 return S_OK;
43 } 44 }
44 45
45 dvdnav_status_t dvdnav_get_number_of_titles(dvdnav_t *this, int *titles) { 46 dvdnav_status_t dvdnav_get_number_of_titles(dvdnav_t *this, int *titles) {
46 if(!this) 47 if(!this || !titles) {
47 return S_ERR; 48 printerr("Passed a NULL pointer.");
48
49 if(!titles) {
50 printerr("Passed a NULL pointer");
51 return S_ERR; 49 return S_ERR;
52 } 50 }
53 51
54 if(!this->started) { 52 if(!this->started) {
55 /* Start the VM */ 53 /* Start the VM */
61 59
62 return S_OK; 60 return S_OK;
63 } 61 }
64 62
65 dvdnav_status_t dvdnav_get_number_of_parts(dvdnav_t *this, int title, int *parts) { 63 dvdnav_status_t dvdnav_get_number_of_parts(dvdnav_t *this, int title, int *parts) {
66 if(!this) 64 if(!this || !parts) {
67 return S_ERR; 65 printerr("Passed a NULL pointer.");
68
69 if(!parts) {
70 printerr("Passed a NULL pointer");
71 return S_ERR; 66 return S_ERR;
72 } 67 }
73 if(!this->started) { 68 if(!this->started) {
74 printerr("Virtual DVD machine not started."); 69 printerr("Virtual DVD machine not started.");
75 return S_ERR; 70 return S_ERR;
76 } 71 }
77 if ((title < 1) || (title > vm_get_vmgi(this->vm)->tt_srpt->nr_of_srpts) ) { 72 if ((title < 1) || (title > vm_get_vmgi(this->vm)->tt_srpt->nr_of_srpts) ) {
78 printerr("Passed a title number out of range"); 73 printerr("Passed a title number out of range.");
79 return S_ERR; 74 return S_ERR;
80 } 75 }
76
81 (*parts) = vm_get_vmgi(this->vm)->tt_srpt->title[title-1].nr_of_ptts; 77 (*parts) = vm_get_vmgi(this->vm)->tt_srpt->title[title-1].nr_of_ptts;
78
82 return S_OK; 79 return S_OK;
83 } 80 }
84 81
85 dvdnav_status_t dvdnav_current_title_info(dvdnav_t *this, int *title, int *part) { 82 dvdnav_status_t dvdnav_current_title_info(dvdnav_t *this, int *title, int *part) {
86 if(!this || !this->vm) 83 int retval;
87 return S_ERR; 84
88 85 if(!this || !title || !part) {
89 if(!title || !part) { 86 printerr("Passed a NULL pointer.");
90 printerr("Passed a NULL pointer");
91 return S_ERR; 87 return S_ERR;
92 } 88 }
93 89
94 return vm_get_current_title_part(this->vm, title, part); 90 pthread_mutex_lock(&this->vm_lock);
91 if (!this->vm->vtsi || !this->vm->vmgi) {
92 printerr("Bad VM state.");
93 pthread_mutex_unlock(&this->vm_lock);
94 return S_ERR;
95 }
96 if (!this->vm->state.pgc) {
97 printerr("No current PGC.");
98 pthread_mutex_unlock(&this->vm_lock);
99 return S_ERR;
100 }
101 if (this->vm->state.domain != VTS_DOMAIN) {
102 printerr("Not in VTS domain.");
103 pthread_mutex_unlock(&this->vm_lock);
104 return S_ERR;
105 }
106 retval = vm_get_current_title_part(this->vm, title, part);
107 pthread_mutex_unlock(&this->vm_lock);
108
109 return retval ? S_OK : S_ERR;
95 } 110 }
96 111
97 dvdnav_status_t dvdnav_title_play(dvdnav_t *this, int title) { 112 dvdnav_status_t dvdnav_title_play(dvdnav_t *this, int title) {
98
99 if(!this) { 113 if(!this) {
114 printerr("Passed a NULL pointer.");
100 return S_ERR; 115 return S_ERR;
101 } 116 }
102
103 return dvdnav_part_play(this, title, 1); 117 return dvdnav_part_play(this, title, 1);
104 } 118 }
105 119
106 dvdnav_status_t dvdnav_part_play(dvdnav_t *this, int title, int part) { 120 dvdnav_status_t dvdnav_part_play(dvdnav_t *this, int title, int part) {
121 int retval;
107 122
108 if(!this) { 123 if(!this) {
124 printerr("Passed a NULL pointer.");
109 return S_ERR; 125 return S_ERR;
110 } 126 }
127
128 pthread_mutex_lock(&this->vm_lock);
129 if (!this->vm->vtsi || !this->vm->vmgi) {
130 printerr("Bad VM state.");
131 pthread_mutex_unlock(&this->vm_lock);
132 return S_ERR;
133 }
134 if (!this->vm->state.pgc) {
135 printerr("No current PGC.");
136 pthread_mutex_unlock(&this->vm_lock);
137 return S_ERR;
138 }
139 if((title < 1) || (title > this->vm->vmgi->tt_srpt->nr_of_srpts)) {
140 printerr("Title out of range.");
141 pthread_mutex_unlock(&this->vm_lock);
142 return S_ERR;
143 }
144 retval = vm_jump_title_part(this->vm, title, part);
145 pthread_mutex_unlock(&this->vm_lock);
111 146
112 return vm_jump_title_part(this->vm, title, part); 147 return retval ? S_OK : S_ERR;
113 } 148 }
114 149
115 dvdnav_status_t dvdnav_part_play_auto_stop(dvdnav_t *this, int title, 150 dvdnav_status_t dvdnav_part_play_auto_stop(dvdnav_t *this, int title,
116 int part, int parts_to_play) { 151 int part, int parts_to_play) {
117 /* Perform jump as per usual */ 152 /* FIXME: Implement auto-stop */
118 153 if (dvdnav_part_play(this, title, part) == S_OK)
119 return dvdnav_part_play(this, title, part); 154 printerr("Not implemented yet.");
120 155 return S_ERR;
121 /* FIXME: Impement auto-stop */
122
123 /* return S_OK;*/
124 } 156 }
125 157
126 dvdnav_status_t dvdnav_time_play(dvdnav_t *this, int title, 158 dvdnav_status_t dvdnav_time_play(dvdnav_t *this, int title,
127 unsigned long int time) { 159 unsigned long int time) {
160 if(!this) {
161 printerr("Passed a NULL pointer.");
162 return S_ERR;
163 }
164
128 /* FIXME: Implement */ 165 /* FIXME: Implement */
129 166 printerr("Not implemented yet.");
130 return S_OK; 167 return S_ERR;
131 } 168 }
132 169
133 dvdnav_status_t dvdnav_stop(dvdnav_t *this) { 170 dvdnav_status_t dvdnav_stop(dvdnav_t *this) {
134 if(!this) 171 if(!this) {
135 return S_ERR; 172 printerr("Passed a NULL pointer.");
136 173 return S_ERR;
137 /* Set the STOP flag */ 174 }
138 175
139 this->stop = 1; 176 pthread_mutex_lock(&this->vm_lock);
140 177 vm_stop(this->vm);
178 pthread_mutex_unlock(&this->vm_lock);
141 return S_OK; 179 return S_OK;
142 } 180 }
143 181
144 dvdnav_status_t dvdnav_go_up(dvdnav_t *this) { 182 dvdnav_status_t dvdnav_go_up(dvdnav_t *this) {
145 if(!this) 183 if(!this) {
146 return S_ERR; 184 printerr("Passed a NULL pointer.");
185 return S_ERR;
186 }
147 187
148 /* A nice easy function... delegate to the VM */ 188 /* A nice easy function... delegate to the VM */
149 vm_go_up(this->vm); 189 pthread_mutex_lock(&this->vm_lock);
190 vm_jump_up(this->vm);
191 pthread_mutex_unlock(&this->vm_lock);
150 192
151 return S_OK; 193 return S_OK;
152 } 194 }
153
154
155