comparison searching.c @ 122:29b046894eac src

use the new VM copy mechanism to try-run program skipping and report failure in case we end with a stopped VM
author mroi
date Wed, 12 Mar 2003 11:39:49 +0000
parents bd8601b74c3d
children 87400040e4a4
comparison
equal deleted inserted replaced
121:545bd4fc0a16 122:29b046894eac
296 296
297 return S_OK; 297 return S_OK;
298 } 298 }
299 299
300 dvdnav_status_t dvdnav_next_pg_search(dvdnav_t *this) { 300 dvdnav_status_t dvdnav_next_pg_search(dvdnav_t *this) {
301 vm_t *try_vm;
301 302
302 if(!this) { 303 if(!this) {
303 printerr("Passed a NULL pointer."); 304 printerr("Passed a NULL pointer.");
304 return S_ERR; 305 return S_ERR;
305 } 306 }
312 } 313 }
313 314
314 #ifdef LOG_DEBUG 315 #ifdef LOG_DEBUG
315 fprintf(MSG_OUT, "libdvdnav: next chapter\n"); 316 fprintf(MSG_OUT, "libdvdnav: next chapter\n");
316 #endif 317 #endif
317 if (!vm_jump_next_pg(this->vm)) { 318 /* make a copy of current VM and try to navigate the copy to the next PG */
318 fprintf(MSG_OUT, "libdvdnav: next chapter failed.\n"); 319 try_vm = vm_new_copy(this->vm);
319 printerr("Skip to next chapter failed."); 320 if (!vm_jump_next_pg(try_vm) || try_vm->stopped) {
320 pthread_mutex_unlock(&this->vm_lock); 321 vm_free_copy(try_vm);
321 return S_ERR; 322 /* next_pg failed, try to jump at least to the next cell */
322 } 323 try_vm = vm_new_copy(this->vm);
324 vm_get_next_cell(try_vm);
325 if (try_vm->stopped) {
326 vm_free_copy(try_vm);
327 fprintf(MSG_OUT, "libdvdnav: next chapter failed.\n");
328 printerr("Skip to next chapter failed.");
329 pthread_mutex_unlock(&this->vm_lock);
330 return S_ERR;
331 }
332 }
333 /* merge changes on success */
334 vm_merge(this->vm, try_vm);
335 vm_free_copy(try_vm);
323 this->position_current.still = 0; 336 this->position_current.still = 0;
324 this->vm->hop_channel++; 337 this->vm->hop_channel++;
325 #ifdef LOG_DEBUG 338 #ifdef LOG_DEBUG
326 fprintf(MSG_OUT, "libdvdnav: next chapter done\n"); 339 fprintf(MSG_OUT, "libdvdnav: next chapter done\n");
327 #endif 340 #endif