comparison mplayer.c @ 5112:70fb281bb13c

changed printf's to mp_msg
author alex
date Fri, 15 Mar 2002 22:25:57 +0000
parents 40d2bcb1b671
children 621a68b911a9
comparison
equal deleted inserted replaced
5111:1514c5d060d5 5112:70fb281bb13c
13 #include <sys/stat.h> 13 #include <sys/stat.h>
14 14
15 #include <signal.h> 15 #include <signal.h>
16 #include <time.h> 16 #include <time.h>
17 #include <fcntl.h> 17 #include <fcntl.h>
18
19 #include <errno.h>
18 20
19 #include "version.h" 21 #include "version.h"
20 #include "config.h" 22 #include "config.h"
21 23
22 #include "mp_msg.h" 24 #include "mp_msg.h"
575 use_gui=0; 577 use_gui=0;
576 } 578 }
577 #endif 579 #endif
578 580
579 if(video_driver && strcmp(video_driver,"help")==0){ 581 if(video_driver && strcmp(video_driver,"help")==0){
580 printf("Available video output drivers:\n"); 582 mp_msg(MSGT_CPLAYER, MSGL_INFO, "Available video output drivers:\n");
581 i=0; 583 i=0;
582 while (video_out_drivers[i]) { 584 while (video_out_drivers[i]) {
583 const vo_info_t *info = video_out_drivers[i++]->get_info (); 585 const vo_info_t *info = video_out_drivers[i++]->get_info ();
584 printf("\t%s\t%s\n", info->short_name, info->name); 586 printf("\t%s\t%s\n", info->short_name, info->name);
585 } 587 }
586 printf("\n"); 588 printf("\n");
587 exit(0); 589 exit(0);
588 } 590 }
589 591
590 if(audio_driver && strcmp(audio_driver,"help")==0){ 592 if(audio_driver && strcmp(audio_driver,"help")==0){
591 printf("Available audio output drivers:\n"); 593 mp_msg(MSGT_CPLAYER, MSGL_INFO, "Available audio output drivers:\n");
592 i=0; 594 i=0;
593 while (audio_out_drivers[i]) { 595 while (audio_out_drivers[i]) {
594 const ao_info_t *info = audio_out_drivers[i++]->info; 596 const ao_info_t *info = audio_out_drivers[i++]->info;
595 printf("\t%s\t%s\n", info->short_name, info->name); 597 printf("\t%s\t%s\n", info->short_name, info->name);
596 } 598 }
609 // kill(getpid(),SIGKILL); 611 // kill(getpid(),SIGKILL);
610 } 612 }
611 } 613 }
612 614
613 if(audio_codec && strcmp(audio_codec,"help")==0){ 615 if(audio_codec && strcmp(audio_codec,"help")==0){
614 printf("Available audio codecs:\n"); 616 mp_msg(MSGT_CPLAYER, MSGL_INFO, "Available audio codecs:\n");
615 list_codecs(1); 617 list_codecs(1);
616 printf("\n"); 618 printf("\n");
617 exit(0); 619 exit(0);
618 } 620 }
619 if(video_codec && strcmp(video_codec,"help")==0){ 621 if(video_codec && strcmp(video_codec,"help")==0){
620 printf("Available video codecs:\n"); 622 mp_msg(MSGT_CPLAYER, MSGL_INFO, "Available video codecs:\n");
621 list_codecs(0); 623 list_codecs(0);
622 printf("\n"); 624 printf("\n");
623 exit(0); 625 exit(0);
624 } 626 }
625 627
626 628
627 if(!filename && !vcd_track && !dvd_title && !tv_param_on){ 629 if(!filename && !vcd_track && !dvd_title && !tv_param_on){
628 if(!use_gui){ 630 if(!use_gui){
629 // no file/vcd/dvd -> show HELP: 631 // no file/vcd/dvd -> show HELP:
630 printf("%s",help_text); 632 mp_msg(MSGT_CPLAYER, MSGL_INFO, help_text);
631 exit(0); 633 exit(0);
632 } else gui_no_filename=1; 634 } else gui_no_filename=1;
633 } 635 }
634 636
635 // Many users forget to include command line in bugreports... 637 // Many users forget to include command line in bugreports...
636 if(verbose){ 638 if(verbose){
637 printf("CommandLine:"); 639 mp_msg(MSGT_CPLAYER, MSGL_INFO, "CommandLine:");
638 for(i=1;i<argc;i++)printf(" '%s'",argv[i]); 640 for(i=1;i<argc;i++)printf(" '%s'",argv[i]);
639 printf("\n"); 641 printf("\n");
640 } 642 }
641 643
642 mp_msg_init(verbose+MSGL_STATUS); 644 mp_msg_init(verbose+MSGL_STATUS);
664 666
665 #ifdef HAVE_RTC 667 #ifdef HAVE_RTC
666 if(!nortc) 668 if(!nortc)
667 { 669 {
668 if ((rtc_fd = open("/dev/rtc", O_RDONLY)) < 0) 670 if ((rtc_fd = open("/dev/rtc", O_RDONLY)) < 0)
669 perror ("Linux RTC init: open"); 671 mp_msg(MSGT_CPLAYER, MSGL_ERR, "Linux RTC init error: %s\n", strerror(errno));
670 else { 672 else {
671 unsigned long irqp; 673 unsigned long irqp;
672 674
673 /* if (ioctl(rtc_fd, RTC_IRQP_SET, _) < 0) { */ 675 /* if (ioctl(rtc_fd, RTC_IRQP_SET, _) < 0) { */
674 if (ioctl(rtc_fd, RTC_IRQP_READ, &irqp) < 0) { 676 if (ioctl(rtc_fd, RTC_IRQP_READ, &irqp) < 0) {
675 perror ("Linux RTC init: ioctl (rtc_irqp_read)"); 677 mp_msg(MSGT_CPLAYER, MSGL_ERR, "Linux RTC init error in ioctl (rtc_irqp_read): %s\n", strerror(errno));
676 close (rtc_fd); 678 close (rtc_fd);
677 rtc_fd = -1; 679 rtc_fd = -1;
678 } else if (ioctl(rtc_fd, RTC_PIE_ON, 0) < 0) { 680 } else if (ioctl(rtc_fd, RTC_PIE_ON, 0) < 0) {
679 /* variable only by the root */ 681 /* variable only by the root */
680 perror ("Linux RTC init: ioctl (rtc_pie_on)"); 682 mp_msg(MSGT_CPLAYER, MSGL_ERR, "Linux RTC init error in ioctl (rtc_pie_on): %s\n", strerror(errno));
681 close (rtc_fd); 683 close (rtc_fd);
682 rtc_fd = -1; 684 rtc_fd = -1;
683 } else 685 } else
684 printf("Using Linux's hardware RTC timing (%ldHz)\n", irqp); 686 mp_msg(MSGT_CPLAYER, MSGL_INFO, "Using Linux's hardware RTC timing (%ldHz)\n", irqp);
685 } 687 }
686 } 688 }
687 #ifdef HAVE_NEW_GUI 689 #ifdef HAVE_NEW_GUI
688 // breaks DGA and SVGAlib and VESA drivers: --A'rpi 690 // breaks DGA and SVGAlib and VESA drivers: --A'rpi
689 // and now ? -- Pontscho 691 // and now ? -- Pontscho
690 if(use_gui) setuid( getuid() ); // strongly test, please check this. 692 if(use_gui) setuid( getuid() ); // strongly test, please check this.
691 #endif 693 #endif
692 if(rtc_fd<0) 694 if(rtc_fd<0)
693 #endif 695 #endif
694 printf("Using %s timing\n",softsleep?"software":"usleep()"); 696 mp_msg(MSGT_CPLAYER, MSGL_INFO, "Using %s timing\n",softsleep?"software":"usleep()");
695 697
696 #ifdef USE_TERMCAP 698 #ifdef USE_TERMCAP
697 if ( !use_gui ) load_termcap(NULL); // load key-codes 699 if ( !use_gui ) load_termcap(NULL); // load key-codes
698 #endif 700 #endif
699 701
1654 ++drop_frame_cnt; 1656 ++drop_frame_cnt;
1655 if(drop_frame_cnt>50 && AV_delay>0.5 && !drop_message){ 1657 if(drop_frame_cnt>50 && AV_delay>0.5 && !drop_message){
1656 drop_message=1; 1658 drop_message=1;
1657 mp_msg(MSGT_AVSYNC,MSGL_WARN,MSGTR_SystemTooSlow); 1659 mp_msg(MSGT_AVSYNC,MSGL_WARN,MSGTR_SystemTooSlow);
1658 } 1660 }
1659 printf ("A-V SYNC: FRAMEDROP (SH_AV_delay=%.3f)!\n", SH_AV_delay); 1661 mp_msg(MSGT_AVSYNC,MSGL_INFO,"A-V SYNC: FRAMEDROP (SH_AV_delay=%.3f)!\n", SH_AV_delay);
1660 mp_msg(MSGT_AVSYNC,MSGL_DBG2,"\nframe drop %d, %.2f\n", drop_frame, time_frame); 1662 mp_msg(MSGT_AVSYNC,MSGL_DBG2,"\nframe drop %d, %.2f\n", drop_frame, time_frame);
1661 /* go into unlimited-TF cycle */ 1663 /* go into unlimited-TF cycle */
1662 time_frame = SH_AV_delay; 1664 time_frame = SH_AV_delay;
1663 } else { 1665 } else {
1664 #define SL_CORR_AVG_LEN 125 1666 #define SL_CORR_AVG_LEN 125
1673 SH_AV_delay - time_frame > (frame_time + time_frame_corr_avg) * -UNEXP_CORR_MAX) 1675 SH_AV_delay - time_frame > (frame_time + time_frame_corr_avg) * -UNEXP_CORR_MAX)
1674 time_frame = SH_AV_delay; 1676 time_frame = SH_AV_delay;
1675 else { 1677 else {
1676 if (SH_AV_delay - time_frame > (frame_time + time_frame_corr_avg) * UNEXP_CORR_WARN || 1678 if (SH_AV_delay - time_frame > (frame_time + time_frame_corr_avg) * UNEXP_CORR_WARN ||
1677 SH_AV_delay - time_frame < (frame_time + time_frame_corr_avg) * -UNEXP_CORR_WARN) 1679 SH_AV_delay - time_frame < (frame_time + time_frame_corr_avg) * -UNEXP_CORR_WARN)
1678 printf ("WARNING: A-V SYNC LAG TOO LARGE: %.3f {%.3f - %.3f} (too little UNEXP_CORR_MAX?)\n", 1680 mp_msg(MSGT_AVSYNC, MSGL_WARN, "WARNING: A-V SYNC LAG TOO LARGE: %.3f {%.3f - %.3f} (too little UNEXP_CORR_MAX?)\n",
1679 SH_AV_delay - time_frame, SH_AV_delay, time_frame); 1681 SH_AV_delay - time_frame, SH_AV_delay, time_frame);
1680 time_frame += (frame_time + time_frame_corr_avg) * ((SH_AV_delay > time_frame) ? 1682 time_frame += (frame_time + time_frame_corr_avg) * ((SH_AV_delay > time_frame) ?
1681 UNEXP_CORR_MAX : -UNEXP_CORR_MAX); 1683 UNEXP_CORR_MAX : -UNEXP_CORR_MAX);
1682 } 1684 }
1683 } /* /start dropframe */ 1685 } /* /start dropframe */
1705 if(rtc_fd>=0){ 1707 if(rtc_fd>=0){
1706 // -------- RTC ----------- 1708 // -------- RTC -----------
1707 while (time_frame > 0.000) { 1709 while (time_frame > 0.000) {
1708 unsigned long long rtc_ts; 1710 unsigned long long rtc_ts;
1709 if (read (rtc_fd, &rtc_ts, sizeof(rtc_ts)) <= 0) 1711 if (read (rtc_fd, &rtc_ts, sizeof(rtc_ts)) <= 0)
1710 perror ("read (rtc_fd)"); 1712 mp_msg(MSGT_CPLAYER, MSGL_ERR, "Linux RTC read error: %s\n", strerror(errno));
1711 time_frame-=GetRelativeTime(); 1713 time_frame-=GetRelativeTime();
1712 } 1714 }
1713 } else 1715 } else
1714 #endif 1716 #endif
1715 { 1717 {
1721 else 1723 else
1722 usec_sleep(1000000*(time_frame-0.020)); 1724 usec_sleep(1000000*(time_frame-0.020));
1723 time_frame-=GetRelativeTime(); 1725 time_frame-=GetRelativeTime();
1724 } 1726 }
1725 if(softsleep){ 1727 if(softsleep){
1726 if(time_frame<0) printf("Warning! softsleep underflow!\n"); 1728 if(time_frame<0) mp_msg(MSGT_AVSYNC, MSGL_WARN, "Warning! Softsleep underflow!\n");
1727 while(time_frame>0) time_frame-=GetRelativeTime(); // burn the CPU 1729 while(time_frame>0) time_frame-=GetRelativeTime(); // burn the CPU
1728 } 1730 }
1729 } 1731 }
1730 1732
1731 } 1733 }
2155 case '6': 2157 case '6':
2156 case '7': 2158 case '7':
2157 case '8': 2159 case '8':
2158 rel_seek_secs=0.99*(float)(c-'1')/7.0; 2160 rel_seek_secs=0.99*(float)(c-'1')/7.0;
2159 abs_seek_pos=3; 2161 abs_seek_pos=3;
2160 printf("ABS seek to %5.3f \n",rel_seek_secs); 2162 printf ("ABS seek to %5.3f \n",rel_seek_secs);
2161 break; 2163 break;
2162 #else 2164 #else
2163 /* User wants to have screen shot */ 2165 /* User wants to have screen shot */
2164 case 'S': 2166 case 'S':
2165 case 's': 2167 case 's':
2530 default : { 2532 default : {
2531 #ifdef HAVE_NEW_GUI 2533 #ifdef HAVE_NEW_GUI
2532 if ( ( use_gui )&&( cmd->id > MP_CMD_GUI_EVENTS ) ) guiGetEvent( guiIEvent,(char *)cmd->id ); 2534 if ( ( use_gui )&&( cmd->id > MP_CMD_GUI_EVENTS ) ) guiGetEvent( guiIEvent,(char *)cmd->id );
2533 else 2535 else
2534 #endif 2536 #endif
2535 printf("Received unknow cmd %s\n",cmd->name); 2537 mp_msg(MSGT_CPLAYER, MSGL_V, "Received unknow cmd %s\n",cmd->name);
2536 } 2538 }
2537 } 2539 }
2538 mp_cmd_free(cmd); 2540 mp_cmd_free(cmd);
2539 } 2541 }
2540 } 2542 }