comparison mplayer.c @ 1729:d6c99f70449e

fix hprogressbar
author pontscho
date Tue, 28 Aug 2001 15:55:02 +0000
parents 9da2b587b029
children bea87c823666
comparison
equal deleted inserted replaced
1728:014b29286ec4 1729:d6c99f70449e
64 64
65 #ifdef HAVE_LIRC 65 #ifdef HAVE_LIRC
66 #include "lirc_mp.h" 66 #include "lirc_mp.h"
67 #endif 67 #endif
68 68
69 #ifdef HAVE_NEW_GUI
70 #include "Gui/mplayer/play.h"
71 #endif
69 72
70 #define DEBUG if(0) 73 #define DEBUG if(0)
71 #ifdef HAVE_GUI
72 int nogui=1;
73 #endif
74 int verbose=0; 74 int verbose=0;
75 int quiet=0; 75 int quiet=0;
76 76
77 #define ABS(x) (((x)>=0)?(x):(-(x))) 77 #define ABS(x) (((x)>=0)?(x):(-(x)))
78 78
188 188
189 extern float gui_position; 189 extern float gui_position;
190 190
191 extern void avi_fixate(); 191 extern void avi_fixate();
192 192
193 #ifdef HAVE_GUI
194 #include "../Gui/mplayer/psignal.h"
195 #define GUI_MSG(x) if ( !nogui ) { mplSendMessage( x ); usec_sleep( 10000 ); }
196 #else
197 #define GUI_MSG(x)
198 #endif
199
200 // options: 193 // options:
201 194
202 int divx_quality=0; 195 int divx_quality=0;
203 static int auto_quality=0; 196 static int auto_quality=0;
204 static int output_quality=0; 197 static int output_quality=0;
287 280
288 void exit_player(char* how){ 281 void exit_player(char* how){
289 total_time_usage_start=GetTimer()-total_time_usage_start; 282 total_time_usage_start=GetTimer()-total_time_usage_start;
290 283
291 // restore terminal: 284 // restore terminal:
292 #ifdef HAVE_GUI 285 #ifdef HAVE_NEW_GUI
293 if ( nogui ) 286 if ( !use_gui ) getch2_disable();
294 #endif 287 #else
295 getch2_disable(); 288 getch2_disable();
289 #endif
290
296 291
297 #ifdef USE_LIBVO2 292 #ifdef USE_LIBVO2
298 if(video_out) vo2_close(video_out); 293 if(video_out) vo2_close(video_out);
299 #else 294 #else
300 if(video_out) video_out->uninit(); 295 if(video_out) video_out->uninit();
306 301
307 if(audio_out) audio_out->uninit(); 302 if(audio_out) audio_out->uninit();
308 303
309 if(encode_name) avi_fixate(); 304 if(encode_name) avi_fixate();
310 #ifdef HAVE_LIRC 305 #ifdef HAVE_LIRC
311 #ifdef HAVE_GUI
312 if ( nogui )
313 #endif
314 lirc_mp_cleanup(); 306 lirc_mp_cleanup();
315 #endif 307 #endif
316 308
317 if(how) mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_Exiting,how); 309 if(how) mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_Exiting,how);
318 mp_msg(MSGT_CPLAYER,MSGL_V,"max framesize was %d bytes\n",max_framesize); 310 mp_msg(MSGT_CPLAYER,MSGL_V,"max framesize was %d bytes\n",max_framesize);
345 kill(getpid(),SIGKILL); 337 kill(getpid(),SIGKILL);
346 } 338 }
347 mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_IntBySignal,x, 339 mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_IntBySignal,x,
348 current_module?current_module:"unknown" 340 current_module?current_module:"unknown"
349 ); 341 );
350 #ifdef HAVE_GUI
351 if ( !nogui )
352 {
353 mplShMem->items.error.signal=x;
354 strcpy( mplShMem->items.error.module,current_module?current_module:"unknown" );
355 }
356 #endif
357 exit_player(NULL); 342 exit_player(NULL);
358 } 343 }
359 344
360 extern stream_t* open_stream(char* filename,int vcd_track,int* file_format); 345 extern stream_t* open_stream(char* filename,int vcd_track,int* file_format);
361 346
406 free(conffile); 391 free(conffile);
407 } 392 }
408 } 393 }
409 } 394 }
410 395
411 #ifndef HAVE_GUI 396 //ifndef HAVE_GUI
412 int main(int argc,char* argv[], char *envp[]){ 397 int main(int argc,char* argv[], char *envp[]){
413 #else 398 //else
414 int mplayer(int argc,char* argv[], char *envp[]){ 399 // int mplayer(int argc,char* argv[], char *envp[]){
415 #endif 400 //endif
416 401
417 #ifdef USE_SUB 402 #ifdef USE_SUB
418 static subtitle* subtitles=NULL; 403 static subtitle* subtitles=NULL;
419 #endif 404 #endif
420 405
563 appInit( argc,argv,envp,(void*)mDisplay ); 548 appInit( argc,argv,envp,(void*)mDisplay );
564 } 549 }
565 #endif 550 #endif
566 551
567 #ifdef HAVE_LIRC 552 #ifdef HAVE_LIRC
568 #ifdef HAVE_GUI
569 if ( nogui )
570 #endif
571 lirc_mp_setup(); 553 lirc_mp_setup();
572 #endif 554 #endif
573 555
574 #ifdef USE_TERMCAP 556 #ifdef USE_TERMCAP
575 load_termcap(NULL); // load key-codes 557 if ( !use_gui ) load_termcap(NULL); // load key-codes
576 #endif 558 #endif
577 559
578 560
579 //========= Catch terminate signals: ================ 561 //========= Catch terminate signals: ================
580 // terminate requests: 562 // terminate requests:
581 signal(SIGTERM,exit_sighandler); // kill 563 signal(SIGTERM,exit_sighandler); // kill
582 signal(SIGHUP,exit_sighandler); // kill -HUP / xterm closed 564 signal(SIGHUP,exit_sighandler); // kill -HUP / xterm closed
583 565
584 #ifdef HAVE_GUI 566 signal(SIGINT,exit_sighandler); // Interrupt from keyboard
585 if ( nogui )
586 #endif
587 signal(SIGINT,exit_sighandler); // Interrupt from keyboard
588 567
589 signal(SIGQUIT,exit_sighandler); // Quit from keyboard 568 signal(SIGQUIT,exit_sighandler); // Quit from keyboard
590 // fatal errors: 569 // fatal errors:
591 signal(SIGBUS,exit_sighandler); // bus error 570 signal(SIGBUS,exit_sighandler); // bus error
592 signal(SIGSEGV,exit_sighandler); // segfault 571 signal(SIGSEGV,exit_sighandler); // segfault
982 mp_msg(MSGT_CPLAYER,MSGL_V,"video_out->init(%dx%d->%dx%d,flags=%d,'%s',0x%X)\n", 961 mp_msg(MSGT_CPLAYER,MSGL_V,"video_out->init(%dx%d->%dx%d,flags=%d,'%s',0x%X)\n",
983 sh_video->disp_w,sh_video->disp_h, 962 sh_video->disp_w,sh_video->disp_h,
984 screen_size_x,screen_size_y, 963 screen_size_x,screen_size_y,
985 fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3), 964 fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3),
986 title,out_fmt); 965 title,out_fmt);
987
988 #ifdef HAVE_GUI
989 if ( !nogui )
990 {
991 mplShMem->items.videodata.width=sh_video->disp_w;
992 mplShMem->items.videodata.height=sh_video->disp_h;
993 mplSendMessage( mplSetVideoData );
994 }
995 #endif
996 966
997 #ifdef USE_LIBVO2 967 #ifdef USE_LIBVO2
998 if(!vo2_start(video_out, 968 if(!vo2_start(video_out,
999 sh_video->disp_w,sh_video->disp_h,out_fmt,0, 969 sh_video->disp_w,sh_video->disp_h,out_fmt,0,
1000 fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3) )){ 970 fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3) )){
1292 ++drop_frame_cnt; 1262 ++drop_frame_cnt;
1293 if (verbose > 0 && drop_frame_cnt%10 == 0) 1263 if (verbose > 0 && drop_frame_cnt%10 == 0)
1294 mp_msg(MSGT_AVSYNC,MSGL_DBG2,"\nstill dropping, %.2f\n", time_frame); 1264 mp_msg(MSGT_AVSYNC,MSGL_DBG2,"\nstill dropping, %.2f\n", time_frame);
1295 } 1265 }
1296 } 1266 }
1297 video_out->check_events(); // check events AST
1298 #ifdef HAVE_NEW_GUI 1267 #ifdef HAVE_NEW_GUI
1299 if(use_gui){ 1268 if(use_gui){
1300 wsHandleEvents();mplTimerHandler(0); // handle GUI timer events 1269 wsHandleEvents();mplTimerHandler(0); // handle GUI timer events
1301 } 1270 }
1302 #endif 1271 #endif
1272 video_out->check_events(); // check events AST
1303 } else { 1273 } else {
1304 // It's time to sleep... 1274 // It's time to sleep...
1305 current_module="sleep"; 1275 current_module="sleep";
1306 1276
1307 time_frame-=GetRelativeTime(); // reset timer 1277 time_frame-=GetRelativeTime(); // reset timer
1502 1472
1503 if(osd_function==OSD_PAUSE){ 1473 if(osd_function==OSD_PAUSE){
1504 mp_msg(MSGT_CPLAYER,MSGL_STATUS,"\n------ PAUSED -------\r");fflush(stdout); 1474 mp_msg(MSGT_CPLAYER,MSGL_STATUS,"\n------ PAUSED -------\r");fflush(stdout);
1505 if (audio_out && sh_audio) 1475 if (audio_out && sh_audio)
1506 audio_out->pause(); // pause audio, keep data if possible 1476 audio_out->pause(); // pause audio, keep data if possible
1507 #ifdef HAVE_GUI
1508 if ( nogui )
1509 {
1510 #endif
1511 while( 1477 while(
1512 #ifdef HAVE_LIRC 1478 #ifdef HAVE_LIRC
1513 lirc_mp_getinput()<=0 && 1479 lirc_mp_getinput()<=0 &&
1514 #endif 1480 #endif
1515 (use_stdin || getch2(20)<=0) && mplayer_get_key()<=0){ 1481 (use_stdin || getch2(20)<=0) && mplayer_get_key()<=0){
1522 } 1488 }
1523 #endif 1489 #endif
1524 if(use_stdin) usec_sleep(1000); // do not eat the CPU 1490 if(use_stdin) usec_sleep(1000); // do not eat the CPU
1525 } 1491 }
1526 osd_function=OSD_PLAY; 1492 osd_function=OSD_PLAY;
1527 #ifdef HAVE_GUI
1528 } else while( osd_function != OSD_PLAY ) usec_sleep( 1000 );
1529 #endif
1530 if (audio_out && sh_audio) 1493 if (audio_out && sh_audio)
1531 audio_out->resume(); // resume audio 1494 audio_out->resume(); // resume audio
1532 } 1495 }
1533 1496
1534 1497
1779 current_module=NULL; 1742 current_module=NULL;
1780 } 1743 }
1781 1744
1782 #ifdef HAVE_NEW_GUI 1745 #ifdef HAVE_NEW_GUI
1783 if(use_gui){ 1746 if(use_gui){
1784 int len=((demuxer->movi_end-demuxer->movi_start)>>8); 1747 int len=((demuxer->movi_end-demuxer->movi_start));
1785 if(len>0) 1748 // if(len>0)
1786 gui_position=(demuxer->filepos-demuxer->movi_start)/len; 1749 // gui_position=(float)(demuxer->filepos-demuxer->movi_start)/len;
1787 else 1750 // else
1788 gui_position=-1; 1751 // gui_position=-1;
1752 if ( len > 0 ) mplShMem->Position=(float)(demuxer->filepos-demuxer->movi_start) / len * 100.0f;
1753 else mplShMem->Position=0;
1754 mplShMem->TimeSec=d_video->pts;
1789 } 1755 }
1790 #endif 1756 #endif
1791 1757
1792 1758
1793 //================= Update OSD ==================== 1759 //================= Update OSD ====================
1840 1806
1841 if(curr_filename+1<num_filenames){ 1807 if(curr_filename+1<num_filenames){
1842 // partial uninit: 1808 // partial uninit:
1843 1809
1844 // restore terminal: 1810 // restore terminal:
1845 #ifdef HAVE_GUI 1811 #ifdef HAVE_NEW_GUI
1846 if ( nogui ) 1812 if ( !use_gui ) getch2_disable();
1847 #endif 1813 #else
1848 getch2_disable(); 1814 getch2_disable();
1815 #endif
1849 1816
1850 current_module="uninit_vo"; 1817 current_module="uninit_vo";
1851 1818
1852 #ifdef USE_LIBVO2 1819 #ifdef USE_LIBVO2
1853 if(video_out) vo2_close(video_out); 1820 if(video_out) vo2_close(video_out);