comparison searching.c @ 113:ec2df154be56 src

slightly improved logic of program skipping: previous program: -> if PG > 1, jump to PG - 1 -> otherwise, if prev_PGC is set, jump to last PG of prev_PGC -> otherwise fail next program: -> if PG < last_PG, jump to PG + 1 -> otherwise, if next_PGC is set, jump to first PG of next_PGC -> otherwise, move to last Cell of current PG and ask the VM for the next Cell
author mroi
date Mon, 13 Jan 2003 13:33:45 +0000
parents 06cba5cee071
children b6834e6359cf
comparison
equal deleted inserted replaced
112:50ee8763a312 113:ec2df154be56
236 state = &(this->vm->state); 236 state = &(this->vm->state);
237 if((!state) || (!state->pgc) ) 237 if((!state) || (!state->pgc) )
238 return S_ERR; 238 return S_ERR;
239 239
240 pthread_mutex_lock(&this->vm_lock); 240 pthread_mutex_lock(&this->vm_lock);
241 /* Make sure this is not the first chapter */
242 if(state->pgN <= 1 ) {
243 fprintf(MSG_OUT, "libdvdnav: at first chapter. prev chapter failed.\n");
244 pthread_mutex_unlock(&this->vm_lock);
245 return S_ERR;
246 }
247 fprintf(MSG_OUT, "libdvdnav: previous chapter\n"); 241 fprintf(MSG_OUT, "libdvdnav: previous chapter\n");
248 vm_jump_prog(this->vm, state->pgN - 1); 242 if (!vm_prev_pg(this->vm)) {
243 fprintf(MSG_OUT, "libdvdnav: prev chapter failed.\n");
244 pthread_mutex_unlock(&this->vm_lock);
245 return S_ERR;
246 }
249 this->position_current.still = 0; 247 this->position_current.still = 0;
250 this->vm->hop_channel++; 248 this->vm->hop_channel++;
251 fprintf(MSG_OUT, "libdvdnav: previous chapter done\n"); 249 fprintf(MSG_OUT, "libdvdnav: previous chapter done\n");
252 pthread_mutex_unlock(&this->vm_lock); 250 pthread_mutex_unlock(&this->vm_lock);
253 251
273 state = &(this->vm->state); 271 state = &(this->vm->state);
274 if((!state) || (!state->pgc) ) 272 if((!state) || (!state->pgc) )
275 return S_ERR; 273 return S_ERR;
276 274
277 pthread_mutex_lock(&this->vm_lock); 275 pthread_mutex_lock(&this->vm_lock);
278 /* Make sure this is not the last chapter */ 276 fprintf(MSG_OUT, "libdvdnav: next chapter\n");
279 if(state->pgN >= state->pgc->nr_of_programs) { 277 if (!vm_next_pg(this->vm)) {
280 fprintf(MSG_OUT, "libdvdnav: at last chapter. jumping to end of last cell.\n"); 278 fprintf(MSG_OUT, "libdvdnav: next chapter failed.\n");
281 this->vm->state.cellN = this->vm->state.pgc->nr_of_cells; 279 pthread_mutex_unlock(&this->vm_lock);
282 vm_get_next_cell(this->vm); 280 return S_ERR;
283 } else {
284 fprintf(MSG_OUT, "libdvdnav: next chapter\n");
285 vm_jump_prog(this->vm, state->pgN + 1);
286 } 281 }
287 this->position_current.still = 0; 282 this->position_current.still = 0;
288 this->vm->hop_channel++; 283 this->vm->hop_channel++;
289 fprintf(MSG_OUT, "libdvdnav: next chapter done\n"); 284 fprintf(MSG_OUT, "libdvdnav: next chapter done\n");
290 pthread_mutex_unlock(&this->vm_lock); 285 pthread_mutex_unlock(&this->vm_lock);