Mercurial > mplayer.hg
comparison mplayer.c @ 4156:22fadd4022b5
playtree-based config patch by Alban Bedel <albeu@free.fr>
author | arpi |
---|---|
date | Mon, 14 Jan 2002 23:38:49 +0000 |
parents | da00e9f57949 |
children | ac62f8534409 |
comparison
equal
deleted
inserted
replaced
4155:7c0b4665668d | 4156:22fadd4022b5 |
---|---|
95 //**************************************************************************// | 95 //**************************************************************************// |
96 #include "playtree.h" | 96 #include "playtree.h" |
97 | 97 |
98 play_tree_t* playtree; | 98 play_tree_t* playtree; |
99 | 99 |
100 #define PT_NEXT_ENTRY 1 | |
101 #define PT_PREV_ENTRY -1 | |
102 #define PT_NEXT_SRC 2 | |
103 #define PT_PREV_SRC -2 | |
104 #define PT_UP_NEXT 3 | |
105 #define PT_UP_PREV -3 | |
106 | |
107 //**************************************************************************// | |
108 // Config | |
109 //**************************************************************************// | |
110 | |
111 m_config_t* mconfig; | |
112 | |
100 //**************************************************************************// | 113 //**************************************************************************// |
101 // Config file | 114 // Config file |
102 //**************************************************************************// | 115 //**************************************************************************// |
103 | 116 |
104 static int cfg_inc_verbose(struct config *conf){ ++verbose; return 0;} | 117 static int cfg_inc_verbose(struct config *conf){ ++verbose; return 0;} |
105 | 118 |
106 static int cfg_include(struct config *conf, char *filename){ | 119 static int cfg_include(struct config *conf, char *filename){ |
107 return parse_config_file(conf, filename); | 120 return m_config_parse_config_file(mconfig, filename); |
108 } | 121 } |
109 | 122 |
110 #include "get_path.c" | 123 #include "get_path.c" |
111 | 124 |
112 //**************************************************************************// | 125 //**************************************************************************// |
232 char* audio_driver=NULL; | 245 char* audio_driver=NULL; |
233 static int fullscreen=0; | 246 static int fullscreen=0; |
234 static int vidmode=0; | 247 static int vidmode=0; |
235 static int softzoom=0; | 248 static int softzoom=0; |
236 static int flip=-1; | 249 static int flip=-1; |
250 // We need this opt_* because the values are then calculated so the options use the opt_* | |
251 // and before each file we reset the calculated value using this opt_* values | |
252 static int opt_screen_size_x=0;//SCREEN_SIZE_X; | |
253 static int opt_screen_size_y=0;//SCREEN_SIZE_Y; | |
237 static int screen_size_x=0;//SCREEN_SIZE_X; | 254 static int screen_size_x=0;//SCREEN_SIZE_X; |
238 static int screen_size_y=0;//SCREEN_SIZE_Y; | 255 static int screen_size_y=0;//SCREEN_SIZE_Y; |
239 static int screen_size_xy=0; | 256 static int screen_size_xy=0; |
240 static float movie_aspect=-1.0; | 257 static float movie_aspect=-1.0; |
241 | 258 |
371 //extern void write_avi_header_1(FILE *f,int fcc,float fps,int width,int height); | 388 //extern void write_avi_header_1(FILE *f,int fcc,float fps,int width,int height); |
372 | 389 |
373 #include "mixer.h" | 390 #include "mixer.h" |
374 #include "cfg-mplayer.h" | 391 #include "cfg-mplayer.h" |
375 | 392 |
376 void parse_cfgfiles( void ) | 393 void parse_cfgfiles( m_config_t* conf ) |
377 { | 394 { |
378 char *conffile; | 395 char *conffile; |
379 int conffile_fd; | 396 int conffile_fd; |
380 if (parse_config_file(conf, "/etc/mplayer.conf") < 0) | 397 if (m_config_parse_config_file(conf, "/etc/mplayer.conf") < 0) |
381 exit(1); | 398 exit(1); |
382 if ((conffile = get_path("")) == NULL) { | 399 if ((conffile = get_path("")) == NULL) { |
383 mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_NoHomeDir); | 400 mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_NoHomeDir); |
384 } else { | 401 } else { |
385 mkdir(conffile, 0777); | 402 mkdir(conffile, 0777); |
390 if ((conffile_fd = open(conffile, O_CREAT | O_EXCL | O_WRONLY, 0666)) != -1) { | 407 if ((conffile_fd = open(conffile, O_CREAT | O_EXCL | O_WRONLY, 0666)) != -1) { |
391 mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_CreatingCfgFile, conffile); | 408 mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_CreatingCfgFile, conffile); |
392 write(conffile_fd, default_config, strlen(default_config)); | 409 write(conffile_fd, default_config, strlen(default_config)); |
393 close(conffile_fd); | 410 close(conffile_fd); |
394 } | 411 } |
395 if (parse_config_file(conf, conffile) < 0) | 412 if (m_config_parse_config_file(conf, conffile) < 0) |
396 exit(1); | 413 exit(1); |
397 free(conffile); | 414 free(conffile); |
398 } | 415 } |
399 } | 416 } |
400 } | 417 } |
415 static sh_audio_t *sh_audio=NULL; | 432 static sh_audio_t *sh_audio=NULL; |
416 static sh_video_t *sh_video=NULL; | 433 static sh_video_t *sh_video=NULL; |
417 | 434 |
418 // for multifile support: | 435 // for multifile support: |
419 play_tree_iter_t* playtree_iter = NULL; | 436 play_tree_iter_t* playtree_iter = NULL; |
420 char **filenames=NULL; | |
421 int num_filenames=0; | |
422 int curr_filename=0; | |
423 | 437 |
424 char* filename=NULL; //"MI2-Trailer.avi"; | 438 char* filename=NULL; //"MI2-Trailer.avi"; |
425 int file_format=DEMUXER_TYPE_UNKNOWN; | 439 int file_format=DEMUXER_TYPE_UNKNOWN; |
426 // | 440 |
427 int delay_corrected=1; | 441 int delay_corrected=1; |
428 char* title="MPlayer"; | 442 char* title="MPlayer"; |
429 | 443 |
430 // movie info: | 444 // movie info: |
431 int out_fmt=0; | 445 int out_fmt=0; |
491 if ( argv[0] ) | 505 if ( argv[0] ) |
492 if(!strcmp(argv[0],"gmplayer") || | 506 if(!strcmp(argv[0],"gmplayer") || |
493 (strrchr(argv[0],'/') && !strcmp(strrchr(argv[0],'/'),"/gmplayer") ) ) | 507 (strrchr(argv[0],'/') && !strcmp(strrchr(argv[0],'/'),"/gmplayer") ) ) |
494 use_gui=1; | 508 use_gui=1; |
495 | 509 |
496 parse_cfgfiles(); | |
497 num_filenames=parse_command_line(conf, argc, argv, envp, &filenames); | |
498 if(num_filenames<0) exit(1); // error parsing cmdline | |
499 | |
500 playtree = play_tree_new(); | 510 playtree = play_tree_new(); |
501 { | 511 |
502 play_tree_t* list = NULL; | 512 mconfig = m_config_new(playtree); |
503 int i; | 513 m_config_register_options(mconfig,mplayer_opts); |
504 play_tree_t *entry = NULL, *tree = play_tree_new(); | 514 // TODO : add something to let modules register their options |
505 for(i= 0; i < num_filenames ; i++) { | 515 parse_cfgfiles(mconfig); |
506 entry = entry != NULL ? play_tree_new() : tree; | 516 |
507 play_tree_add_file(entry,filenames[i]); | 517 |
508 play_tree_append_entry(tree,entry); | 518 |
509 } | 519 if(m_config_parse_command_line(mconfig, argc, argv, envp) < 0) exit(1); // error parsing cmdline |
510 | 520 |
511 entry = play_tree_new(); | |
512 play_tree_set_child(entry,tree); | |
513 list = entry; | |
514 if(playlist_file!=NULL) { | |
515 entry = parse_playlist_file(playlist_file); | |
516 if(entry != NULL){ | |
517 if(list) play_tree_append_entry(list,entry); | |
518 else list = entry; | |
519 } | |
520 } | |
521 if(list) play_tree_set_child(playtree,list); | |
522 } | |
523 playtree = play_tree_cleanup(playtree); | 521 playtree = play_tree_cleanup(playtree); |
524 if(playtree) { | 522 if(playtree) { |
525 playtree_iter = play_tree_iter_new(playtree); | 523 playtree_iter = play_tree_iter_new(playtree,mconfig); |
526 if(playtree_iter) { | 524 if(playtree_iter) { |
527 if(play_tree_iter_step(playtree_iter,0,0) != PLAY_TREE_ITER_ENTRY) { | 525 if(play_tree_iter_step(playtree_iter,0,0) != PLAY_TREE_ITER_ENTRY) { |
528 play_tree_iter_free(playtree_iter); | 526 play_tree_iter_free(playtree_iter); |
529 playtree_iter = NULL; | 527 playtree_iter = NULL; |
530 } | 528 } |
604 // Many users forget to include command line in bugreports... | 602 // Many users forget to include command line in bugreports... |
605 if(verbose){ | 603 if(verbose){ |
606 printf("CommandLine:"); | 604 printf("CommandLine:"); |
607 for(i=1;i<argc;i++)printf(" '%s'",argv[i]); | 605 for(i=1;i<argc;i++)printf(" '%s'",argv[i]); |
608 printf("\n"); | 606 printf("\n"); |
609 printf("num_filenames: %d\n",num_filenames); | |
610 } | 607 } |
611 | 608 |
612 mp_msg_init(verbose+MSGL_STATUS); | 609 mp_msg_init(verbose+MSGL_STATUS); |
613 | 610 |
614 //------ load global data first ------ | 611 //------ load global data first ------ |
1170 mp_msg(MSGT_CPLAYER,MSGL_INFO,"%s video codec: [%s] drv:%d prio:%d (%s)\n",video_codec?"Forcing":"Detected",sh_video->codec->name,sh_video->codec->driver,sh_video->codec->priority!=-1?sh_video->codec->priority:0,sh_video->codec->info); | 1167 mp_msg(MSGT_CPLAYER,MSGL_INFO,"%s video codec: [%s] drv:%d prio:%d (%s)\n",video_codec?"Forcing":"Detected",sh_video->codec->name,sh_video->codec->driver,sh_video->codec->priority!=-1?sh_video->codec->priority:0,sh_video->codec->info); |
1171 | 1168 |
1172 for(i=0;i<CODECS_MAX_OUTFMT;i++){ | 1169 for(i=0;i<CODECS_MAX_OUTFMT;i++){ |
1173 // int ret; | 1170 // int ret; |
1174 out_fmt=sh_video->codec->outfmt[i]; | 1171 out_fmt=sh_video->codec->outfmt[i]; |
1175 if(out_fmt==0xFFFFFFFF) continue; | 1172 if(out_fmt==(signed int)0xFFFFFFFF) continue; |
1176 #ifdef USE_LIBVO2 | 1173 #ifdef USE_LIBVO2 |
1177 vo_flags=vo2_query_format(video_out); | 1174 vo_flags=vo2_query_format(video_out); |
1178 #else | 1175 #else |
1179 vo_flags=video_out->query_format(out_fmt); | 1176 vo_flags=video_out->query_format(out_fmt); |
1180 #endif | 1177 #endif |
1221 //if(verbose) printf("X11 running at %dx%d depth: %d\n",vo_screenwidth,vo_screenheight,vo_depthonscreen); | 1218 //if(verbose) printf("X11 running at %dx%d depth: %d\n",vo_screenwidth,vo_screenheight,vo_depthonscreen); |
1222 } | 1219 } |
1223 if(!screen_size_xy) screen_size_xy=vo_screenwidth; // scale with asp.ratio | 1220 if(!screen_size_xy) screen_size_xy=vo_screenwidth; // scale with asp.ratio |
1224 } | 1221 } |
1225 #endif | 1222 #endif |
1223 | |
1226 // Set default VGA 1:1 aspect as fallback ::atmos | 1224 // Set default VGA 1:1 aspect as fallback ::atmos |
1227 if(movie_aspect>-1.0) sh_video->aspect = movie_aspect; // cmdline overrides autodetect | 1225 if(movie_aspect>-1.0) sh_video->aspect = movie_aspect; // cmdline overrides autodetect |
1228 // if(!sh_video->aspect) sh_video->aspect=1.0; | 1226 // if(!sh_video->aspect) sh_video->aspect=1.0; |
1229 | 1227 screen_size_x = opt_screen_size_x; |
1228 screen_size_y = opt_screen_size_y; | |
1230 if(screen_size_xy||screen_size_x||screen_size_y){ | 1229 if(screen_size_xy||screen_size_x||screen_size_y){ |
1231 if(screen_size_xy>0){ | 1230 if(screen_size_xy>0){ |
1232 if(screen_size_xy<=8){ | 1231 if(screen_size_xy<=8){ |
1233 screen_size_x=screen_size_xy*sh_video->disp_w; | 1232 screen_size_x=screen_size_xy*sh_video->disp_w; |
1234 screen_size_y=screen_size_xy*sh_video->disp_h; | 1233 screen_size_y=screen_size_xy*sh_video->disp_h; |
1827 } | 1826 } |
1828 } | 1827 } |
1829 #endif | 1828 #endif |
1830 | 1829 |
1831 if(osd_function==OSD_PAUSE){ | 1830 if(osd_function==OSD_PAUSE){ |
1831 #ifdef HAVE_NEW_GUI | |
1832 int gui_pause_flag=0; // gany! | 1832 int gui_pause_flag=0; // gany! |
1833 #endif | |
1833 mp_msg(MSGT_CPLAYER,MSGL_STATUS,"\n------ PAUSED -------\r");fflush(stdout); | 1834 mp_msg(MSGT_CPLAYER,MSGL_STATUS,"\n------ PAUSED -------\r");fflush(stdout); |
1834 #ifdef HAVE_NEW_GUI | 1835 #ifdef HAVE_NEW_GUI |
1835 if(use_gui) mplShMem->Playing=2; | 1836 if(use_gui) mplShMem->Playing=2; |
1836 #endif | 1837 #endif |
1837 if (audio_out && sh_audio) | 1838 if (audio_out && sh_audio) |
1961 osd_show_av_delay = 9; // show the A-V delay in OSD | 1962 osd_show_av_delay = 9; // show the A-V delay in OSD |
1962 if(sh_audio) sh_audio->timer+=0.1; | 1963 if(sh_audio) sh_audio->timer+=0.1; |
1963 break; | 1964 break; |
1964 // quit | 1965 // quit |
1965 case KEY_ESC: // ESC | 1966 case KEY_ESC: // ESC |
1966 case 'q': exit_player(MSGTR_Exit_quit); | 1967 case 'q': |
1967 case '>': | 1968 exit_player(MSGTR_Exit_quit); |
1968 if(curr_filename>=num_filenames-1) | |
1969 break; | |
1970 case KEY_ENTER: // ESC | 1969 case KEY_ENTER: // ESC |
1971 eof=2; // jump to next file | 1970 eof=1; // force jump to next file : quit if no next file |
1972 break; | |
1973 case '<': | |
1974 if(curr_filename < 1) | |
1975 break; | |
1976 curr_filename-=2; | |
1977 eof=2; | |
1978 break; | 1971 break; |
1979 case 'g': grab_frames=2;break; | 1972 case 'g': grab_frames=2;break; |
1980 // pause | 1973 // pause |
1981 case 'p': | 1974 case 'p': |
1982 case ' ': | 1975 case ' ': |
1983 osd_function=OSD_PAUSE; | 1976 osd_function=OSD_PAUSE; |
1984 break; | 1977 break; |
1985 case KEY_HOME: | 1978 case KEY_HOME: |
1986 { | 1979 { |
1987 play_tree_iter_t* i = play_tree_iter_new_copy(playtree_iter); | 1980 play_tree_iter_t* i = play_tree_iter_new_copy(playtree_iter); |
1988 if(play_tree_iter_step(i,1,0) == PLAY_TREE_ITER_ENTRY) | 1981 if(play_tree_iter_up_step(i,1,0) == PLAY_TREE_ITER_ENTRY) |
1989 eof = 1; | 1982 eof = PT_UP_NEXT; |
1990 play_tree_iter_free(i); | 1983 play_tree_iter_free(i); |
1991 } | 1984 } |
1992 break; | 1985 break; |
1993 case KEY_END: | 1986 case KEY_END: |
1994 { | 1987 { |
1995 play_tree_iter_t* i = play_tree_iter_new_copy(playtree_iter); | 1988 play_tree_iter_t* i = play_tree_iter_new_copy(playtree_iter); |
1989 if(play_tree_iter_up_step(i,-1,0) == PLAY_TREE_ITER_ENTRY) | |
1990 eof = PT_UP_PREV; | |
1991 play_tree_iter_free(i); | |
1992 } | |
1993 break; | |
1994 case '>': | |
1995 { | |
1996 play_tree_iter_t* i = play_tree_iter_new_copy(playtree_iter); | |
1997 if(play_tree_iter_step(i,1,0) == PLAY_TREE_ITER_ENTRY) | |
1998 eof = PT_NEXT_ENTRY; | |
1999 play_tree_iter_free(i); | |
2000 } | |
2001 break; | |
2002 case '<': | |
2003 { | |
2004 play_tree_iter_t* i = play_tree_iter_new_copy(playtree_iter); | |
1996 if(play_tree_iter_step(i,-1,0) == PLAY_TREE_ITER_ENTRY) | 2005 if(play_tree_iter_step(i,-1,0) == PLAY_TREE_ITER_ENTRY) |
1997 eof = -1; | 2006 eof = PT_PREV_ENTRY; |
1998 play_tree_iter_free(i); | 2007 play_tree_iter_free(i); |
1999 } | 2008 } |
2000 break; | 2009 break; |
2001 case KEY_INS: | 2010 case KEY_INS: |
2002 if(playtree_iter->num_files > 1 && playtree_iter->file < playtree_iter->num_files) | 2011 if(playtree_iter->num_files > 1 && playtree_iter->file < playtree_iter->num_files) |
2003 eof = 2; | 2012 eof = PT_NEXT_SRC; |
2004 break; | 2013 break; |
2005 case KEY_DEL: | 2014 case KEY_DEL: |
2006 if(playtree_iter->num_files > 1 && playtree_iter->file > 1) | 2015 if(playtree_iter->num_files > 1 && playtree_iter->file > 1) |
2007 eof = -2; | 2016 eof = PT_PREV_SRC; |
2008 break; | 2017 break; |
2009 case 'o': // toggle OSD | 2018 case 'o': // toggle OSD |
2010 osd_level=(osd_level+1)%3; | 2019 osd_level=(osd_level+1)%3; |
2011 break; | 2020 break; |
2012 case 'z': | 2021 case 'z': |
2343 | 2352 |
2344 } | 2353 } |
2345 | 2354 |
2346 goto_next_file: // don't jump here after ao/vo/getch initialization! | 2355 goto_next_file: // don't jump here after ao/vo/getch initialization! |
2347 | 2356 |
2348 if(eof == 1 || eof == -1) { | 2357 if(eof == PT_NEXT_ENTRY || eof == PT_PREV_ENTRY) { |
2349 if(play_tree_iter_step(playtree_iter,eof,0) == PLAY_TREE_ITER_ENTRY) { | 2358 if(play_tree_iter_step(playtree_iter,eof,0) == PLAY_TREE_ITER_ENTRY) { |
2350 uninit_player(INITED_ALL-(INITED_GUI+INITED_LIRC)); | 2359 uninit_player(INITED_ALL-(INITED_GUI+INITED_LIRC)); |
2351 eof = 1; | 2360 eof = 1; |
2352 } else { | 2361 } else { |
2353 play_tree_iter_free(playtree_iter); | 2362 play_tree_iter_free(playtree_iter); |
2354 playtree_iter = NULL; | 2363 playtree_iter = NULL; |
2355 } | 2364 } |
2356 } else { | 2365 } else if (eof == PT_UP_NEXT || eof == PT_UP_PREV) { |
2366 eof = eof == PT_UP_NEXT ? 1 : -1; | |
2367 if(play_tree_iter_up_step(playtree_iter,eof,0) == PLAY_TREE_ITER_ENTRY) { | |
2368 uninit_player(INITED_ALL-(INITED_GUI+INITED_LIRC)); | |
2369 eof = 1; | |
2370 } else { | |
2371 play_tree_iter_free(playtree_iter); | |
2372 playtree_iter = NULL; | |
2373 } | |
2374 }else { // NEXT PREV SRC | |
2357 uninit_player(INITED_ALL-(INITED_GUI+INITED_LIRC)); | 2375 uninit_player(INITED_ALL-(INITED_GUI+INITED_LIRC)); |
2358 eof = eof == -2 ? -1 : 1; | 2376 eof = eof == PT_PREV_SRC ? -1 : 1; |
2359 } | 2377 } |
2360 | 2378 |
2361 goto_next_file_src: // When we have multiple src for file | 2379 goto_next_file_src: // When we have multiple src for file |
2362 | 2380 |
2363 if(eof == 0) eof = 1; | 2381 if(eof == 0) eof = 1; |