diff -Naur -wbBE -X ignore_list main-cvs/cfg-mplayer.h main-devel/cfg-mplayer.h --- main-cvs/cfg-mplayer.h 2004-11-01 17:06:22.000000000 +0800 +++ main-devel/cfg-mplayer.h 2004-11-12 11:58:35.000000000 +0800 @@ -415,6 +415,7 @@ {"use-stdin", "-use-stdin has been renamed to -noconsolecontrols, use that instead.", CONF_TYPE_PRINT, 0, 0, 0, NULL}, {"noconsolecontrols", &noconsolecontrols, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL}, {"consolecontrols", &noconsolecontrols, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 0, NULL}, + {"daemon", &daemon_mode, CONF_TYPE_FLAG,CONF_GLOBAL , 0, 1, NULL}, #define MAIN_CONF #include "cfg-common.h" diff -Naur -wbBE -X ignore_list main-cvs/mplayer.c main-devel/mplayer.c --- main-cvs/mplayer.c 2004-11-11 15:33:08.000000000 +0800 +++ main-devel/mplayer.c 2004-11-16 09:12:46.000000000 +0800 @@ -85,6 +85,7 @@ #include "input/input.h" int slave_mode=0; +int daemon_mode=0; int verbose=0; int identify=0; int quiet=0; @@ -1220,7 +1221,10 @@ } #endif - if(!filename){ + // Daemon mode implies slave mode + if (daemon_mode) slave_mode = 1; + + if(!filename && !daemon_mode){ if(!use_gui){ // no file/vcd/dvd -> show HELP: mp_msg(MSGT_CPLAYER, MSGL_INFO, help_text); @@ -1449,6 +1453,79 @@ #endif //--------------------------------------------------------------------------- +// =================== Daemon mode idle loop (STOP state) =================== + if (daemon_mode) + { + current_module="daemon"; + + /* When there is no playtree iterator, daemon waits for input */ + while (! playtree_iter) + { + mp_cmd_t* cmd; + while ((cmd = mp_input_get_cmd(0,0,0)) != NULL) + { + play_tree_t* entry = NULL; + switch (cmd->id) + { + case MP_CMD_LOADFILE: + /* Let filename be the sole entry in the playtree */ + entry = play_tree_new(); + play_tree_add_file(entry, cmd->args[0].v.s); + break; + + case MP_CMD_LOADLIST: + /* Parse playtree entries from play list */ + entry = parse_playlist_file(cmd->args[0].v.s); + if (! entry) + mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_PlaylistLoadUnable,cmd->args[0].v.s); + break; + + case MP_CMD_SWITCH_RATIO: + if (cmd->nargs == 0) + { + /* If no ratio is specified, auto detect from media */ + movie_aspect = -1.0; + } + else movie_aspect = cmd->args[0].v.f; + break; + + case MP_CMD_QUIT: + exit_player_with_rc(MSGTR_Exit_quit, (cmd->nargs > 0) ? cmd->args[0].v.i : 0); + break; + } + + /* Insert new entry into playtree */ + if (entry) + { + /* Setup an empty playtree */ + if (playtree) play_tree_free_list(playtree->child, 1); + else playtree = play_tree_new(); + + if (playtree) + { + play_tree_set_child(playtree, entry); + playtree_iter = play_tree_iter_new(playtree,mconfig); + } + else play_tree_free(entry, 1); + } + + /* Obtain filename from new playtree iterator */ + if (playtree_iter) + { + if (play_tree_iter_step(playtree_iter, 0, 0) + != PLAY_TREE_ITER_ENTRY) + { + play_tree_iter_free(playtree_iter); + playtree_iter = NULL; + } + else filename = play_tree_iter_get_file(playtree_iter,1); + } + } + usec_sleep(20000); + } + } +//--------------------------------------------------------------------------- + if(filename) mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_Playing, filename); //==================== Open VOB-Sub ============================ @@ -4133,7 +4210,7 @@ } #endif -if(use_gui || playtree_iter != NULL){ +if(daemon_mode || use_gui || playtree_iter != NULL){ eof = 0; goto play_next_file; diff -Naur -wbBE -X ignore_list main-cvs/DOCS/man/en/mplayer.1 main-devel/DOCS/man/en/mplayer.1 --- main-cvs/DOCS/man/en/mplayer.1 2004-11-18 09:33:34.000000000 +0800 +++ main-devel/DOCS/man/en/mplayer.1 2004-11-18 09:54:59.000000000 +0800 @@ -1940,6 +1940,16 @@ Not supported by all video output drivers. . .TP +.B \-daemon (also see \-slave) +Switches on daemon mode, in which MPlayer behaves identically to \-slave mode +when a movie is playing, but remains in an infinite loop when no movies are +playing. When no movies are playing, MPlayer responds only to the 'loadfile', + 'loadlist', 'switch_ratio' and 'quit' commands from stdin. +.br +.I NOTE: +See \-slave mode for a description of its operation. +. +.TP .B \-dfbopts (\-vo directfb only) Specify a parameter list for the directfb video output driver. .