Mercurial > libdvdnav.hg
comparison highlight.c @ 196:b751f0790ac6 src
Fix failure of some DVDs to activate buttons.
author | jcdutton |
---|---|
date | Sun, 11 May 2003 13:18:04 +0000 |
parents | b80dff4bef76 |
children | a20a5976a207 |
comparison
equal
deleted
inserted
replaced
195:6b1bfe8f5283 | 196:b751f0790ac6 |
---|---|
63 } | 63 } |
64 fprintf(MSG_OUT," @ %s fps", rate); | 64 fprintf(MSG_OUT," @ %s fps", rate); |
65 } | 65 } |
66 | 66 |
67 static void nav_print_PCI_GI(pci_gi_t *pci_gi) { | 67 static void nav_print_PCI_GI(pci_gi_t *pci_gi) { |
68 int i; | 68 int32_t i; |
69 | 69 |
70 fprintf(MSG_OUT,"libdvdnav: pci_gi:\n"); | 70 fprintf(MSG_OUT,"libdvdnav: pci_gi:\n"); |
71 fprintf(MSG_OUT,"libdvdnav: nv_pck_lbn 0x%08x\n", pci_gi->nv_pck_lbn); | 71 fprintf(MSG_OUT,"libdvdnav: nv_pck_lbn 0x%08x\n", pci_gi->nv_pck_lbn); |
72 fprintf(MSG_OUT,"libdvdnav: vobu_cat 0x%04x\n", pci_gi->vobu_cat); | 72 fprintf(MSG_OUT,"libdvdnav: vobu_cat 0x%04x\n", pci_gi->vobu_cat); |
73 fprintf(MSG_OUT,"libdvdnav: vobu_uop_ctl 0x%08x\n", *(uint32_t*)&pci_gi->vobu_uop_ctl); | 73 fprintf(MSG_OUT,"libdvdnav: vobu_uop_ctl 0x%08x\n", *(uint32_t*)&pci_gi->vobu_uop_ctl); |
88 } | 88 } |
89 fprintf(MSG_OUT,"\"\n"); | 89 fprintf(MSG_OUT,"\"\n"); |
90 } | 90 } |
91 | 91 |
92 static void nav_print_NSML_AGLI(nsml_agli_t *nsml_agli) { | 92 static void nav_print_NSML_AGLI(nsml_agli_t *nsml_agli) { |
93 int i, j = 0; | 93 int32_t i, j = 0; |
94 | 94 |
95 for(i = 0; i < 9; i++) | 95 for(i = 0; i < 9; i++) |
96 j |= nsml_agli->nsml_agl_dsta[i]; | 96 j |= nsml_agli->nsml_agl_dsta[i]; |
97 if(j == 0) | 97 if(j == 0) |
98 return; | 98 return; |
102 if(nsml_agli->nsml_agl_dsta[i]) | 102 if(nsml_agli->nsml_agl_dsta[i]) |
103 fprintf(MSG_OUT,"libdvdnav: nsml_agl_c%d_dsta 0x%08x\n", i + 1, | 103 fprintf(MSG_OUT,"libdvdnav: nsml_agl_c%d_dsta 0x%08x\n", i + 1, |
104 nsml_agli->nsml_agl_dsta[i]); | 104 nsml_agli->nsml_agl_dsta[i]); |
105 } | 105 } |
106 | 106 |
107 static void nav_print_HL_GI(hl_gi_t *hl_gi, int *btngr_ns, int *btn_ns) { | 107 static void nav_print_HL_GI(hl_gi_t *hl_gi, int32_t *btngr_ns, int32_t *btn_ns) { |
108 | 108 |
109 if((hl_gi->hli_ss & 0x03) == 0) | 109 if((hl_gi->hli_ss & 0x03) == 0) |
110 return; | 110 return; |
111 | 111 |
112 fprintf(MSG_OUT,"libdvdnav: hl_gi:\n"); | 112 fprintf(MSG_OUT,"libdvdnav: hl_gi:\n"); |
128 fprintf(MSG_OUT,"libdvdnav: fosl_btnn %d\n", hl_gi->fosl_btnn); | 128 fprintf(MSG_OUT,"libdvdnav: fosl_btnn %d\n", hl_gi->fosl_btnn); |
129 fprintf(MSG_OUT,"libdvdnav: foac_btnn %d\n", hl_gi->foac_btnn); | 129 fprintf(MSG_OUT,"libdvdnav: foac_btnn %d\n", hl_gi->foac_btnn); |
130 } | 130 } |
131 | 131 |
132 static void nav_print_BTN_COLIT(btn_colit_t *btn_colit) { | 132 static void nav_print_BTN_COLIT(btn_colit_t *btn_colit) { |
133 int i, j; | 133 int32_t i, j; |
134 | 134 |
135 j = 0; | 135 j = 0; |
136 for(i = 0; i < 6; i++) | 136 for(i = 0; i < 6; i++) |
137 j |= btn_colit->btn_coli[i/2][i&1]; | 137 j |= btn_colit->btn_coli[i/2][i&1]; |
138 if(j == 0) | 138 if(j == 0) |
144 fprintf(MSG_OUT,"libdvdnav: btn_cqoli %d %s_coli: %08x\n", | 144 fprintf(MSG_OUT,"libdvdnav: btn_cqoli %d %s_coli: %08x\n", |
145 i, (j == 0) ? "sl" : "ac", | 145 i, (j == 0) ? "sl" : "ac", |
146 btn_colit->btn_coli[i][j]); | 146 btn_colit->btn_coli[i][j]); |
147 } | 147 } |
148 | 148 |
149 static void nav_print_BTNIT(btni_t *btni_table, int btngr_ns, int btn_ns) { | 149 static void nav_print_BTNIT(btni_t *btni_table, int32_t btngr_ns, int32_t btn_ns) { |
150 int i, j, k; | 150 int32_t i, j, k; |
151 | 151 |
152 fprintf(MSG_OUT,"libdvdnav: btnit:\n"); | 152 fprintf(MSG_OUT,"libdvdnav: btnit:\n"); |
153 fprintf(MSG_OUT,"libdvdnav: btngr_ns: %i\n", btngr_ns); | 153 fprintf(MSG_OUT,"libdvdnav: btngr_ns: %i\n", btngr_ns); |
154 fprintf(MSG_OUT,"libdvdnav: btn_ns: %i\n", btn_ns); | 154 fprintf(MSG_OUT,"libdvdnav: btn_ns: %i\n", btn_ns); |
155 | 155 |
183 } | 183 } |
184 } | 184 } |
185 } | 185 } |
186 | 186 |
187 static void nav_print_HLI(hli_t *hli) { | 187 static void nav_print_HLI(hli_t *hli) { |
188 int btngr_ns = 0, btn_ns = 0; | 188 int32_t btngr_ns = 0, btn_ns = 0; |
189 | 189 |
190 fprintf(MSG_OUT,"libdvdnav: hli:\n"); | 190 fprintf(MSG_OUT,"libdvdnav: hli:\n"); |
191 nav_print_HL_GI(&hli->hl_gi, & btngr_ns, & btn_ns); | 191 nav_print_HL_GI(&hli->hl_gi, & btngr_ns, & btn_ns); |
192 nav_print_BTN_COLIT(&hli->btn_colit); | 192 nav_print_BTN_COLIT(&hli->btn_colit); |
193 nav_print_BTNIT(hli->btnit, btngr_ns, btn_ns); | 193 nav_print_BTNIT(hli->btnit, btngr_ns, btn_ns); |
203 #endif | 203 #endif |
204 | 204 |
205 | 205 |
206 /* Highlighting API calls */ | 206 /* Highlighting API calls */ |
207 | 207 |
208 dvdnav_status_t dvdnav_get_current_highlight(dvdnav_t *this, int *button) { | 208 dvdnav_status_t dvdnav_get_current_highlight(dvdnav_t *this, int32_t *button) { |
209 | 209 |
210 if(!this || !button) { | 210 if(!this || !button) { |
211 printerr("Passed a NULL pointer."); | 211 printerr("Passed a NULL pointer."); |
212 return DVDNAV_STATUS_ERR; | 212 return DVDNAV_STATUS_ERR; |
213 } | 213 } |
217 | 217 |
218 return DVDNAV_STATUS_OK; | 218 return DVDNAV_STATUS_OK; |
219 } | 219 } |
220 | 220 |
221 static btni_t *get_current_button(dvdnav_t *this, pci_t *pci) { | 221 static btni_t *get_current_button(dvdnav_t *this, pci_t *pci) { |
222 int button = 0; | 222 int32_t button = 0; |
223 | 223 |
224 if(!this || !pci) { | 224 if(!this || !pci) { |
225 printerr("Passed a NULL pointer."); | 225 printerr("Passed a NULL pointer."); |
226 return DVDNAV_STATUS_ERR; | 226 return DVDNAV_STATUS_ERR; |
227 } | 227 } |
228 if(!pci->hli.hl_gi.hli_ss) { | 228 if(!pci->hli.hl_gi.hli_ss) { |
229 printerr("Not in a menu."); | 229 printerr("Not in a menu."); |
230 return DVDNAV_STATUS_ERR; | 230 return DVDNAV_STATUS_ERR; |
231 } | 231 } |
232 #if 0 /* This causes some DVDs to fail to activate buttons. */ | |
232 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) { | 233 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) { |
233 printerr("This NAV has already been left."); | 234 printerr("This NAV has already been left."); |
234 return DVDNAV_STATUS_ERR; | 235 return DVDNAV_STATUS_ERR; |
235 } | 236 } |
237 #endif | |
236 | 238 |
237 button = this->vm->state.HL_BTNN_REG >> 10; | 239 button = this->vm->state.HL_BTNN_REG >> 10; |
238 #ifdef BUTTON_TESTING | 240 #ifdef BUTTON_TESTING |
239 nav_print_PCI(pci); | 241 nav_print_PCI(pci); |
240 #endif | 242 #endif |
332 | 334 |
333 return DVDNAV_STATUS_OK; | 335 return DVDNAV_STATUS_OK; |
334 } | 336 } |
335 | 337 |
336 dvdnav_status_t dvdnav_button_activate(dvdnav_t *this, pci_t *pci) { | 338 dvdnav_status_t dvdnav_button_activate(dvdnav_t *this, pci_t *pci) { |
337 int button; | 339 int32_t button; |
338 btni_t *button_ptr = NULL; | 340 btni_t *button_ptr = NULL; |
339 | 341 |
340 if(!this || !pci) { | 342 if(!this || !pci) { |
341 printerr("Passed a NULL pointer."); | 343 printerr("Passed a NULL pointer."); |
342 return DVDNAV_STATUS_ERR; | 344 return DVDNAV_STATUS_ERR; |
343 } | 345 } |
344 if(!pci->hli.hl_gi.hli_ss) { | 346 if(!pci->hli.hl_gi.hli_ss) { |
345 printerr("Not in a menu."); | 347 printerr("Not in a menu."); |
346 return DVDNAV_STATUS_ERR; | 348 return DVDNAV_STATUS_ERR; |
347 } | 349 } |
350 #if 0 /* This causes some DVDs to fail to activate buttons. */ | |
348 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) { | 351 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) { |
349 printerr("This NAV has already been left."); | 352 printerr("This NAV has already been left."); |
350 return DVDNAV_STATUS_ERR; | 353 return DVDNAV_STATUS_ERR; |
351 } | 354 } |
352 | 355 #endif |
353 pthread_mutex_lock(&this->vm_lock); | 356 pthread_mutex_lock(&this->vm_lock); |
354 | 357 |
355 button = this->vm->state.HL_BTNN_REG >> 10; | 358 button = this->vm->state.HL_BTNN_REG >> 10; |
356 | 359 |
357 if((button <= 0) || (button > pci->hli.hl_gi.btn_ns)) { | 360 if((button <= 0) || (button > pci->hli.hl_gi.btn_ns)) { |
421 this->sync_wait = 0; | 424 this->sync_wait = 0; |
422 pthread_mutex_unlock(&this->vm_lock); | 425 pthread_mutex_unlock(&this->vm_lock); |
423 return DVDNAV_STATUS_OK; | 426 return DVDNAV_STATUS_OK; |
424 } | 427 } |
425 | 428 |
426 dvdnav_status_t dvdnav_button_select(dvdnav_t *this, pci_t *pci, int button) { | 429 dvdnav_status_t dvdnav_button_select(dvdnav_t *this, pci_t *pci, int32_t button) { |
427 | 430 |
428 if(!this || !pci) { | 431 if(!this || !pci) { |
429 printerr("Passed a NULL pointer."); | 432 printerr("Passed a NULL pointer."); |
430 return DVDNAV_STATUS_ERR; | 433 return DVDNAV_STATUS_ERR; |
431 } | 434 } |
432 if(!pci->hli.hl_gi.hli_ss) { | 435 if(!pci->hli.hl_gi.hli_ss) { |
433 printerr("Not in a menu."); | 436 printerr("Not in a menu."); |
434 return DVDNAV_STATUS_ERR; | 437 return DVDNAV_STATUS_ERR; |
435 } | 438 } |
439 #if 0 /* This causes some DVDs to fail to activate buttons. */ | |
436 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) { | 440 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) { |
437 printerr("This NAV has already been left."); | 441 printerr("This NAV has already been left."); |
438 return DVDNAV_STATUS_ERR; | 442 return DVDNAV_STATUS_ERR; |
439 } | 443 } |
444 #endif | |
440 | 445 |
441 #ifdef BUTTON_TESTING | 446 #ifdef BUTTON_TESTING |
442 fprintf(MSG_OUT, "libdvdnav: Button select %i\n", button); | 447 fprintf(MSG_OUT, "libdvdnav: Button select %i\n", button); |
443 #endif | 448 #endif |
444 | 449 |
452 | 457 |
453 return DVDNAV_STATUS_OK; | 458 return DVDNAV_STATUS_OK; |
454 } | 459 } |
455 | 460 |
456 dvdnav_status_t dvdnav_button_select_and_activate(dvdnav_t *this, pci_t *pci, | 461 dvdnav_status_t dvdnav_button_select_and_activate(dvdnav_t *this, pci_t *pci, |
457 int button) { | 462 int32_t button) { |
458 /* A trivial function */ | 463 /* A trivial function */ |
459 if(dvdnav_button_select(this, pci, button) != DVDNAV_STATUS_ERR) | 464 if(dvdnav_button_select(this, pci, button) != DVDNAV_STATUS_ERR) |
460 return dvdnav_button_activate(this, pci); | 465 return dvdnav_button_activate(this, pci); |
461 return DVDNAV_STATUS_ERR; | 466 return DVDNAV_STATUS_ERR; |
462 } | 467 } |
463 | 468 |
464 dvdnav_status_t dvdnav_mouse_select(dvdnav_t *this, pci_t *pci, int x, int y) { | 469 dvdnav_status_t dvdnav_mouse_select(dvdnav_t *this, pci_t *pci, int32_t x, int32_t y) { |
465 int button, cur_button; | 470 int32_t button, cur_button; |
466 int best,dist,d; | 471 int32_t best,dist,d; |
467 int mx,my,dx,dy; | 472 int32_t mx,my,dx,dy; |
468 | 473 |
469 if(!this || !pci) { | 474 if(!this || !pci) { |
470 printerr("Passed a NULL pointer."); | 475 printerr("Passed a NULL pointer."); |
471 return DVDNAV_STATUS_ERR; | 476 return DVDNAV_STATUS_ERR; |
472 } | 477 } |
473 if(!pci->hli.hl_gi.hli_ss) { | 478 if(!pci->hli.hl_gi.hli_ss) { |
474 printerr("Not in a menu."); | 479 printerr("Not in a menu."); |
475 return DVDNAV_STATUS_ERR; | 480 return DVDNAV_STATUS_ERR; |
476 } | 481 } |
482 #if 0 /* This causes some DVDs to fail to activate buttons. */ | |
477 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) { | 483 if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) { |
478 printerr("This NAV has already been left."); | 484 printerr("This NAV has already been left."); |
479 return DVDNAV_STATUS_ERR; | 485 return DVDNAV_STATUS_ERR; |
480 } | 486 } |
487 #endif | |
481 | 488 |
482 cur_button = this->vm->state.HL_BTNN_REG >> 10; | 489 cur_button = this->vm->state.HL_BTNN_REG >> 10; |
483 | 490 |
484 best = 0; | 491 best = 0; |
485 dist = 0x08000000; /* >> than (720*720)+(567*567); */ | 492 dist = 0x08000000; /* >> than (720*720)+(567*567); */ |
501 dist = d; | 508 dist = d; |
502 best = button; | 509 best = button; |
503 } | 510 } |
504 } | 511 } |
505 } | 512 } |
506 | |
507 /* As an efficiency measure, only re-select the button | 513 /* As an efficiency measure, only re-select the button |
508 * if it is different to the previously selected one. */ | 514 * if it is different to the previously selected one. */ |
509 if (best != 0 && best != cur_button) | 515 if (best != 0 && best != cur_button) |
510 dvdnav_button_select(this, pci, best); | 516 dvdnav_button_select(this, pci, best); |
511 | 517 |
512 /* return DVDNAV_STATUS_OK only if we actually found a matching button */ | 518 /* return DVDNAV_STATUS_OK only if we actually found a matching button */ |
513 return best ? DVDNAV_STATUS_OK : DVDNAV_STATUS_ERR; | 519 return best ? DVDNAV_STATUS_OK : DVDNAV_STATUS_ERR; |
514 } | 520 } |
515 | 521 |
516 dvdnav_status_t dvdnav_mouse_activate(dvdnav_t *this, pci_t *pci, int x, int y) { | 522 dvdnav_status_t dvdnav_mouse_activate(dvdnav_t *this, pci_t *pci, int32_t x, int32_t y) { |
517 /* A trivial function */ | 523 /* A trivial function */ |
518 if(dvdnav_mouse_select(this, pci, x,y) != DVDNAV_STATUS_ERR) | 524 if(dvdnav_mouse_select(this, pci, x,y) != DVDNAV_STATUS_ERR) |
519 return dvdnav_button_activate(this, pci); | 525 return dvdnav_button_activate(this, pci); |
520 return DVDNAV_STATUS_ERR; | 526 return DVDNAV_STATUS_ERR; |
521 } | 527 } |