Mercurial > libdvdnav.hg
comparison dvdnav.c @ 76:0e2abe7083de src
more consistent console output
author | mroi |
---|---|
date | Tue, 27 Aug 2002 19:15:08 +0000 |
parents | a23d50ba81d3 |
children | 033f011d8152 |
comparison
equal
deleted
inserted
replaced
75:06cda03dc1e5 | 76:0e2abe7083de |
---|---|
225 if(!this) { | 225 if(!this) { |
226 printerr("Passed a NULL pointer"); | 226 printerr("Passed a NULL pointer"); |
227 return S_ERR; | 227 return S_ERR; |
228 } | 228 } |
229 #ifdef LOG_DEBUG | 229 #ifdef LOG_DEBUG |
230 fprintf(stderr,"dvdnav:close:called\n"); | 230 fprintf(MSG_OUT, "libdvdnav: close:called\n"); |
231 #endif | 231 #endif |
232 | 232 |
233 if (this->file) { | 233 if (this->file) { |
234 DVDCloseFile(this->file); | 234 DVDCloseFile(this->file); |
235 #ifdef LOG_DEBUG | 235 #ifdef LOG_DEBUG |
236 fprintf(stderr,"dvdnav:close:file closing\n"); | 236 fprintf(MSG_OUT, "libdvdnav: close:file closing\n"); |
237 #endif | 237 #endif |
238 this->file = NULL; | 238 this->file = NULL; |
239 } | 239 } |
240 | 240 |
241 /* Free the VM */ | 241 /* Free the VM */ |
243 vm_free_vm(this->vm); | 243 vm_free_vm(this->vm); |
244 } | 244 } |
245 if (this->file) { | 245 if (this->file) { |
246 DVDCloseFile(this->file); | 246 DVDCloseFile(this->file); |
247 #ifdef LOG_DEBUG | 247 #ifdef LOG_DEBUG |
248 fprintf(stderr,"dvdnav:close2:file closing\n"); | 248 fprintf(MSG_OUT, "libdvdnav: close2:file closing\n"); |
249 #endif | 249 #endif |
250 this->file = NULL; | 250 this->file = NULL; |
251 } | 251 } |
252 pthread_mutex_destroy(&this->vm_lock); | 252 pthread_mutex_destroy(&this->vm_lock); |
253 | 253 |
263 | 263 |
264 dvdnav_status_t dvdnav_reset(dvdnav_t *this) { | 264 dvdnav_status_t dvdnav_reset(dvdnav_t *this) { |
265 dvdnav_status_t result; | 265 dvdnav_status_t result; |
266 | 266 |
267 #ifdef LOG_DEBUG | 267 #ifdef LOG_DEBUG |
268 printf("dvdnav:reset:called\n"); | 268 fprintf(MSG_OUT, "libdvdnav: reset:called\n"); |
269 #endif | 269 #endif |
270 if(!this) { | 270 if(!this) { |
271 printerr("Passed a NULL pointer"); | 271 printerr("Passed a NULL pointer"); |
272 return S_ERR; | 272 return S_ERR; |
273 } | 273 } |
274 #ifdef LOG_DEBUG | 274 #ifdef LOG_DEBUG |
275 printf("getting lock\n"); | 275 fprintf(MSG_OUT, "libdvdnav: getting lock\n"); |
276 #endif | 276 #endif |
277 pthread_mutex_lock(&this->vm_lock); | 277 pthread_mutex_lock(&this->vm_lock); |
278 #ifdef LOG_DEBUG | 278 #ifdef LOG_DEBUG |
279 printf("reseting vm\n"); | 279 fprintf(MSG_OUT, "libdvdnav: reseting vm\n"); |
280 #endif | 280 #endif |
281 if(vm_reset(this->vm, NULL) == -1) { | 281 if(vm_reset(this->vm, NULL) == -1) { |
282 printerr("Error restarting the VM"); | 282 printerr("Error restarting the VM"); |
283 pthread_mutex_unlock(&this->vm_lock); | 283 pthread_mutex_unlock(&this->vm_lock); |
284 return S_ERR; | 284 return S_ERR; |
285 } | 285 } |
286 #ifdef LOG_DEBUG | 286 #ifdef LOG_DEBUG |
287 printf("clearing dvdnav\n"); | 287 fprintf(MSG_OUT, "libdvdnav: clearing dvdnav\n"); |
288 #endif | 288 #endif |
289 result=dvdnav_clear(this); | 289 result=dvdnav_clear(this); |
290 #ifdef LOG_DEBUG | 290 #ifdef LOG_DEBUG |
291 printf("starting vm\n"); | 291 fprintf(MSG_OUT, "libdvdnav: starting vm\n"); |
292 #endif | 292 #endif |
293 // if(!this->started) { | 293 // if(!this->started) { |
294 // /* Start the VM */ | 294 // /* Start the VM */ |
295 // vm_start(this->vm); | 295 // vm_start(this->vm); |
296 // this->started = 1; | 296 // this->started = 1; |
297 // } | 297 // } |
298 #ifdef LOG_DEBUG | 298 #ifdef LOG_DEBUG |
299 printf("unlocking\n"); | 299 fprintf(MSG_OUT, "libdvdnav: unlocking\n"); |
300 #endif | 300 #endif |
301 pthread_mutex_unlock(&this->vm_lock); | 301 pthread_mutex_unlock(&this->vm_lock); |
302 return result; | 302 return result; |
303 } | 303 } |
304 | 304 |
336 uint32_t nStreamID; | 336 uint32_t nStreamID; |
337 /* uint8_t *p_start=p; */ | 337 /* uint8_t *p_start=p; */ |
338 | 338 |
339 | 339 |
340 if (p==NULL) { | 340 if (p==NULL) { |
341 fprintf(stderr,"Passed a NULL pointer.\n"); | 341 fprintf(MSG_OUT, "libdvdnav: Passed a NULL pointer.\n"); |
342 return 0; | 342 return 0; |
343 } | 343 } |
344 | 344 |
345 /* dprint("Checking packet...\n"); */ | 345 /* dprint("Checking packet...\n"); */ |
346 | 346 |
369 } | 369 } |
370 | 370 |
371 /* we should now have a PES packet here */ | 371 /* we should now have a PES packet here */ |
372 | 372 |
373 if (p[0] || p[1] || (p[2] != 1)) { | 373 if (p[0] || p[1] || (p[2] != 1)) { |
374 fprintf(stderr,"demux error! %02x %02x %02x (should be 0x000001) \n",p[0],p[1],p[2]); | 374 fprintf(MSG_OUT, "libdvdnav: demux error! %02x %02x %02x (should be 0x000001) \n",p[0],p[1],p[2]); |
375 return 0; | 375 return 0; |
376 } | 376 } |
377 | 377 |
378 nPacketLen = p[4] << 8 | p[5]; | 378 nPacketLen = p[4] << 8 | p[5]; |
379 nStreamID = p[3]; | 379 nStreamID = p[3]; |
382 p += nHeaderLen; | 382 p += nHeaderLen; |
383 | 383 |
384 if (nStreamID == 0xbf) { /* Private stream 2 */ | 384 if (nStreamID == 0xbf) { /* Private stream 2 */ |
385 /* | 385 /* |
386 * int i; | 386 * int i; |
387 * printf("dvdnav:nav packet=%u\n",p-p_start-6); | 387 * fprintf(MSG_OUT, "libdvdnav: nav packet=%u\n",p-p_start-6); |
388 * for(i=0;i<80;i++) { | 388 * for(i=0;i<80;i++) { |
389 * printf("%02x ",p[i-6]); | 389 * fprintf(MSG_OUT, "%02x ",p[i-6]); |
390 * } | 390 * } |
391 * printf("\n"); | 391 * fprintf(MSG_OUT, "\n"); |
392 */ | 392 */ |
393 if(p[0] == 0x00) { | 393 if(p[0] == 0x00) { |
394 navRead_PCI(nav_pci, p+1); | 394 navRead_PCI(nav_pci, p+1); |
395 } | 395 } |
396 | 396 |
544 return S_OK; | 544 return S_OK; |
545 } | 545 } |
546 | 546 |
547 vm_position_get(this->vm,&this->position_next); | 547 vm_position_get(this->vm,&this->position_next); |
548 /********** | 548 /********** |
549 fprintf(stderr, "POS-NEXT "); | 549 fprintf(MSG_OUT, "libdvdnav: POS-NEXT "); |
550 vm_position_print(this->vm, &this->position_next); | 550 vm_position_print(this->vm, &this->position_next); |
551 fprintf(stderr, "POS-CUR "); | 551 fprintf(MSG_OUT, "libdvdnav: POS-CUR "); |
552 vm_position_print(this->vm, &this->position_current); | 552 vm_position_print(this->vm, &this->position_current); |
553 **********/ | 553 **********/ |
554 | 554 |
555 if(this->position_current.hop_channel != this->position_next.hop_channel) { | 555 if(this->position_current.hop_channel != this->position_next.hop_channel) { |
556 this->position_current.hop_channel = this->position_next.hop_channel; | 556 this->position_current.hop_channel = this->position_next.hop_channel; |
563 | 563 |
564 | 564 |
565 if(this->spu_clut_changed) { | 565 if(this->spu_clut_changed) { |
566 (*event) = DVDNAV_SPU_CLUT_CHANGE; | 566 (*event) = DVDNAV_SPU_CLUT_CHANGE; |
567 #ifdef LOG_DEBUG | 567 #ifdef LOG_DEBUG |
568 fprintf(stderr,"libdvdnav:SPU_CLUT_CHANGE\n"); | 568 fprintf(MSG_OUT, "libdvdnav: SPU_CLUT_CHANGE\n"); |
569 #endif | 569 #endif |
570 (*len) = 16 * sizeof(uint32_t); | 570 (*len) = 16 * sizeof(uint32_t); |
571 memcpy(*buf, &(state->pgc->palette), 16 * sizeof(uint32_t)); | 571 memcpy(*buf, &(state->pgc->palette), 16 * sizeof(uint32_t)); |
572 this->spu_clut_changed = 0; | 572 this->spu_clut_changed = 0; |
573 #ifdef LOG_DEBUG | 573 #ifdef LOG_DEBUG |
574 fprintf(stderr,"libdvdnav:SPU_CLUT_CHANGE returning S_OK\n"); | 574 fprintf(MSG_OUT, "libdvdnav: SPU_CLUT_CHANGE returning S_OK\n"); |
575 #endif | 575 #endif |
576 pthread_mutex_unlock(&this->vm_lock); | 576 pthread_mutex_unlock(&this->vm_lock); |
577 return S_OK; | 577 return S_OK; |
578 } | 578 } |
579 | 579 |
580 if(this->position_current.spu_channel != this->position_next.spu_channel) { | 580 if(this->position_current.spu_channel != this->position_next.spu_channel) { |
581 dvdnav_spu_stream_change_event_t stream_change; | 581 dvdnav_spu_stream_change_event_t stream_change; |
582 (*event) = DVDNAV_SPU_STREAM_CHANGE; | 582 (*event) = DVDNAV_SPU_STREAM_CHANGE; |
583 #ifdef LOG_DEBUG | 583 #ifdef LOG_DEBUG |
584 fprintf(stderr,"libdvdnav:SPU_STREAM_CHANGE\n"); | 584 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE\n"); |
585 #endif | 585 #endif |
586 (*len) = sizeof(dvdnav_spu_stream_change_event_t); | 586 (*len) = sizeof(dvdnav_spu_stream_change_event_t); |
587 stream_change.physical_wide = vm_get_subp_active_stream(this->vm, 0); | 587 stream_change.physical_wide = vm_get_subp_active_stream(this->vm, 0); |
588 stream_change.physical_letterbox = vm_get_subp_active_stream(this->vm, 1); | 588 stream_change.physical_letterbox = vm_get_subp_active_stream(this->vm, 1); |
589 stream_change.physical_pan_scan = vm_get_subp_active_stream(this->vm, 2); | 589 stream_change.physical_pan_scan = vm_get_subp_active_stream(this->vm, 2); |
590 memcpy(*buf, &(stream_change), sizeof( dvdnav_spu_stream_change_event_t)); | 590 memcpy(*buf, &(stream_change), sizeof( dvdnav_spu_stream_change_event_t)); |
591 this->position_current.spu_channel = this->position_next.spu_channel; | 591 this->position_current.spu_channel = this->position_next.spu_channel; |
592 #ifdef LOG_DEBUG | 592 #ifdef LOG_DEBUG |
593 fprintf(stderr,"libdvdnav:SPU_STREAM_CHANGE stream_id_wide=%d\n",stream_change.physical_wide); | 593 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE stream_id_wide=%d\n",stream_change.physical_wide); |
594 fprintf(stderr,"libdvdnav:SPU_STREAM_CHANGE stream_id_letterbox=%d\n",stream_change.physical_letterbox); | 594 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE stream_id_letterbox=%d\n",stream_change.physical_letterbox); |
595 fprintf(stderr,"libdvdnav:SPU_STREAM_CHANGE stream_id_pan_scan=%d\n",stream_change.physical_pan_scan); | 595 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE stream_id_pan_scan=%d\n",stream_change.physical_pan_scan); |
596 #endif | 596 #endif |
597 pthread_mutex_unlock(&this->vm_lock); | 597 pthread_mutex_unlock(&this->vm_lock); |
598 if (stream_change.physical_wide != -1 && | 598 if (stream_change.physical_wide != -1 && |
599 stream_change.physical_letterbox != -1 && | 599 stream_change.physical_letterbox != -1 && |
600 stream_change.physical_pan_scan != -1) { | 600 stream_change.physical_pan_scan != -1) { |
601 #ifdef LOG_DEBUG | 601 #ifdef LOG_DEBUG |
602 fprintf(stderr,"libdvdnav:SPU_STREAM_CHANGE returning S_OK\n"); | 602 fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE returning S_OK\n"); |
603 #endif | 603 #endif |
604 return S_OK; | 604 return S_OK; |
605 } | 605 } |
606 } | 606 } |
607 | 607 |
608 if(this->position_current.audio_channel != this->position_next.audio_channel) { | 608 if(this->position_current.audio_channel != this->position_next.audio_channel) { |
609 dvdnav_audio_stream_change_event_t stream_change; | 609 dvdnav_audio_stream_change_event_t stream_change; |
610 (*event) = DVDNAV_AUDIO_STREAM_CHANGE; | 610 (*event) = DVDNAV_AUDIO_STREAM_CHANGE; |
611 #ifdef LOG_DEBUG | 611 #ifdef LOG_DEBUG |
612 fprintf(stderr,"libdvdnav:AUDIO_STREAM_CHANGE\n"); | 612 fprintf(MSG_OUT, "libdvdnav: AUDIO_STREAM_CHANGE\n"); |
613 #endif | 613 #endif |
614 (*len) = sizeof(dvdnav_audio_stream_change_event_t); | 614 (*len) = sizeof(dvdnav_audio_stream_change_event_t); |
615 stream_change.physical= vm_get_audio_active_stream( this->vm ); | 615 stream_change.physical= vm_get_audio_active_stream( this->vm ); |
616 memcpy(*buf, &(stream_change), sizeof( dvdnav_audio_stream_change_event_t)); | 616 memcpy(*buf, &(stream_change), sizeof( dvdnav_audio_stream_change_event_t)); |
617 this->position_current.audio_channel = this->position_next.audio_channel; | 617 this->position_current.audio_channel = this->position_next.audio_channel; |
618 #ifdef LOG_DEBUG | 618 #ifdef LOG_DEBUG |
619 fprintf(stderr,"libdvdnav:AUDIO_STREAM_CHANGE stream_id=%d returning S_OK\n",stream_change.physical); | 619 fprintf(MSG_OUT, "libdvdnav: AUDIO_STREAM_CHANGE stream_id=%d returning S_OK\n",stream_change.physical); |
620 #endif | 620 #endif |
621 pthread_mutex_unlock(&this->vm_lock); | 621 pthread_mutex_unlock(&this->vm_lock); |
622 return S_OK; | 622 return S_OK; |
623 } | 623 } |
624 | 624 |
733 /* End of VOBU */ | 733 /* End of VOBU */ |
734 | 734 |
735 if(this->vobu.vobu_next == SRI_END_OF_CELL) { | 735 if(this->vobu.vobu_next == SRI_END_OF_CELL) { |
736 /* End of Cell from NAV DSI info */ | 736 /* End of Cell from NAV DSI info */ |
737 #ifdef LOG_DEBUG | 737 #ifdef LOG_DEBUG |
738 fprintf(stderr, "Still set to %x\n", this->position_next.still); | 738 fprintf(MSG_OUT, "libdvdnav: Still set to %x\n", this->position_next.still); |
739 #endif | 739 #endif |
740 this->position_current.still = this->position_next.still; | 740 this->position_current.still = this->position_next.still; |
741 | 741 |
742 if( this->position_current.still == 0 || this->skip_still ) { | 742 if( this->position_current.still == 0 || this->skip_still ) { |
743 vm_get_next_cell(this->vm); | 743 vm_get_next_cell(this->vm); |
997 return this->position_next.still; | 997 return this->position_next.still; |
998 } | 998 } |
999 | 999 |
1000 /* | 1000 /* |
1001 * $Log$ | 1001 * $Log$ |
1002 * Revision 1.31 2002/08/27 19:15:08 mroi | |
1003 * more consistent console output | |
1004 * | |
1002 * Revision 1.30 2002/08/09 21:34:27 mroi | 1005 * Revision 1.30 2002/08/09 21:34:27 mroi |
1003 * update spu clut, spu channel and audio channel more often | 1006 * update spu clut, spu channel and audio channel more often |
1004 * | 1007 * |
1005 * Revision 1.29 2002/07/25 14:51:40 richwareham | 1008 * Revision 1.29 2002/07/25 14:51:40 richwareham |
1006 * Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled' | 1009 * Moved get_current_nav_pci into dvdnac.c, changed example to use it instead of 'home-rolled' |