Mercurial > libdvdnav.hg
comparison searching.c @ 102:3e6970dbe8d6 src
- allow seeking to offset 0 (pressing '0' in xine won't work otherwise)
- add a forgotten break
- lock the vm on the program jumps
- jump to the end of the last cell when trying to jump to next program on
last program
- disable stills when doing program jumps
author | mroi |
---|---|
date | Fri, 27 Sep 2002 13:18:02 +0000 |
parents | eeabf5a51b2b |
children | 06cba5cee071 |
comparison
equal
deleted
inserted
replaced
101:f885a4cb7bce | 102:3e6970dbe8d6 |
---|---|
110 int found; | 110 int found; |
111 cell_playback_t *cell, *fnd_cell; | 111 cell_playback_t *cell, *fnd_cell; |
112 dvd_state_t *state; | 112 dvd_state_t *state; |
113 dvdnav_status_t result; | 113 dvdnav_status_t result; |
114 | 114 |
115 if((!this) || (!this->vm) ) | 115 if((!this) || (!this->vm) || (!this->started)) |
116 return -1; | 116 return -1; |
117 | 117 |
118 state = &(this->vm->state); | 118 state = &(this->vm->state); |
119 if((!state) || (!state->pgc) ) | 119 if((!state) || (!state->pgc) ) |
120 return -1; | 120 return -1; |
121 | 121 |
122 if(offset == 0) | |
123 return -1; | |
124 | |
125 if(this->position_current.still != 0) | 122 if(this->position_current.still != 0) |
126 /* Cannot do seeking in a still frame. */ | 123 /* Cannot do seeking in a still frame. */ |
127 return -1; | 124 return -1; |
128 | 125 |
129 pthread_mutex_lock(&this->vm_lock); | 126 pthread_mutex_lock(&this->vm_lock); |
156 if(length - offset < 0) { | 153 if(length - offset < 0) { |
157 pthread_mutex_unlock(&this->vm_lock); | 154 pthread_mutex_unlock(&this->vm_lock); |
158 return -1; | 155 return -1; |
159 } | 156 } |
160 target = length - offset; | 157 target = length - offset; |
158 break; | |
161 default: | 159 default: |
162 /* Error occured */ | 160 /* Error occured */ |
163 pthread_mutex_unlock(&this->vm_lock); | 161 pthread_mutex_unlock(&this->vm_lock); |
164 return -1; | 162 return -1; |
165 } | 163 } |
236 | 234 |
237 state = &(this->vm->state); | 235 state = &(this->vm->state); |
238 if((!state) || (!state->pgc) ) | 236 if((!state) || (!state->pgc) ) |
239 return S_ERR; | 237 return S_ERR; |
240 | 238 |
239 pthread_mutex_lock(&this->vm_lock); | |
241 /* Make sure this is not the first chapter */ | 240 /* Make sure this is not the first chapter */ |
242 if(state->pgN <= 1 ) { | 241 if(state->pgN <= 1 ) { |
243 fprintf(MSG_OUT, "libdvdnav: at first chapter. prev chapter failed.\n"); | 242 fprintf(MSG_OUT, "libdvdnav: at first chapter. prev chapter failed.\n"); |
243 pthread_mutex_unlock(&this->vm_lock); | |
244 return S_ERR; | 244 return S_ERR; |
245 } | 245 } |
246 fprintf(MSG_OUT, "libdvdnav: previous chapter\n"); | 246 fprintf(MSG_OUT, "libdvdnav: previous chapter\n"); |
247 vm_jump_prog(this->vm, state->pgN - 1); | 247 vm_jump_prog(this->vm, state->pgN - 1); |
248 this->position_current.still = 0; | |
248 this->vm->hop_channel++; | 249 this->vm->hop_channel++; |
249 fprintf(MSG_OUT, "libdvdnav: previous chapter done\n"); | 250 fprintf(MSG_OUT, "libdvdnav: previous chapter done\n"); |
251 pthread_mutex_unlock(&this->vm_lock); | |
250 | 252 |
251 return S_OK; | 253 return S_OK; |
252 } | 254 } |
253 | 255 |
254 dvdnav_status_t dvdnav_top_pg_search(dvdnav_t *this) { | 256 dvdnav_status_t dvdnav_top_pg_search(dvdnav_t *this) { |
269 | 271 |
270 state = &(this->vm->state); | 272 state = &(this->vm->state); |
271 if((!state) || (!state->pgc) ) | 273 if((!state) || (!state->pgc) ) |
272 return S_ERR; | 274 return S_ERR; |
273 | 275 |
276 pthread_mutex_lock(&this->vm_lock); | |
274 /* Make sure this is not the last chapter */ | 277 /* Make sure this is not the last chapter */ |
275 if(state->pgN >= state->pgc->nr_of_programs) { | 278 if(state->pgN >= state->pgc->nr_of_programs) { |
276 fprintf(MSG_OUT, "libdvdnav: at last chapter. next chapter failed.\n"); | 279 fprintf(MSG_OUT, "libdvdnav: at last chapter. jumping to end of last cell.\n"); |
277 return S_ERR; | 280 this->vm->state.cellN = this->vm->state.pgc->nr_of_cells; |
278 } | 281 vm_get_next_cell(this->vm); |
279 fprintf(MSG_OUT, "libdvdnav: next chapter\n"); | 282 } else { |
280 vm_jump_prog(this->vm, state->pgN + 1); | 283 fprintf(MSG_OUT, "libdvdnav: next chapter\n"); |
284 vm_jump_prog(this->vm, state->pgN + 1); | |
285 } | |
286 this->position_current.still = 0; | |
281 this->vm->hop_channel++; | 287 this->vm->hop_channel++; |
282 fprintf(MSG_OUT, "libdvdnav: next chapter done\n"); | 288 fprintf(MSG_OUT, "libdvdnav: next chapter done\n"); |
289 pthread_mutex_unlock(&this->vm_lock); | |
283 | 290 |
284 return S_OK; | 291 return S_OK; |
285 } | 292 } |
286 | 293 |
287 dvdnav_status_t dvdnav_menu_call(dvdnav_t *this, DVDMenuID_t menu) { | 294 dvdnav_status_t dvdnav_menu_call(dvdnav_t *this, DVDMenuID_t menu) { |