[Toxine-cvs] CVS: toxine/src commands.c,1.62,1.63 common.h,1.27,1.28 loader.c,1.15,1.16 main.c,1.29,
Brought to you by:
f1rmb
From: Daniel Caujolle-B. <f1...@us...> - 2004-05-17 19:53:38
|
Update of /cvsroot/toxine/toxine/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15578 Modified Files: commands.c common.h loader.c main.c utils.c utils.h xine_commands.c xine_commands.h Log Message: Add stdin control feature (-S). Index: commands.c =================================================================== RCS file: /cvsroot/toxine/toxine/src/commands.c,v retrieving revision 1.62 retrieving revision 1.63 diff -u -r1.62 -r1.63 --- commands.c 16 May 2004 20:28:39 -0000 1.62 +++ commands.c 17 May 2004 19:53:24 -0000 1.63 @@ -775,6 +775,38 @@ } } +static void toxine_handle_stdin(toxine_t *tox) { + int fd; + char c[255]; + int len; + fd_set set; + struct timeval tv; + + fd = STDIN_FILENO; + + while(tox->running) { + + FD_ZERO(&set); + FD_SET(fd, &set); + + tv.tv_sec = 0; + tv.tv_usec = 500000; + + select(fd + 1, &set, NULL, NULL, &tv); + + if(FD_ISSET(fd, &set)) { + len = read(fd, &c, 255); + if(len > 0) { + c[len - 1] = '\0'; + + toxine_set_command_line(tox, c); + toxine_handle_command(tox, NULL); + } + } + } + +} + /* * The main loop (except for execute and script mode). */ @@ -845,7 +877,11 @@ _xine_stream_new(NULL, tox, NULL); } - if(tox->script.in_use) { + if(tox->stdin) { + tox->interactive = 0; + toxine_handle_stdin(tox); + } + else if(tox->script.in_use) { toxine_handle_script(tox); tox->video.running = tox->running = 0; } @@ -942,7 +978,7 @@ if(toxine_is_arg_contain(tox, 2, "volume")) { if(tox->audio.mixer.enable) - toxine_draw_bar("Current audio volume", 0, 100, tox->audio.mixer.volume_level); + toxine_draw_bar(tox, "Current audio volume", 0, 100, tox->audio.mixer.volume_level); else pinfo("Audio mixer is disable.\n"); @@ -1174,7 +1210,7 @@ static void do_quit(commands_t *command, toxine_t *tox, void *data) { if(tox->interactive) { - if((toxine_confirm("Do you really want to quit toxine ? [yes|no]: "))) + if((toxine_confirm(tox, "Do you really want to quit toxine ? [yes|no]: "))) tox->video.running = tox->running = 0; } else @@ -1807,7 +1843,7 @@ return_if_no_init(tox); xine_get_pos_length(tox->stream, &pos, NULL, NULL); - toxine_draw_bar("Current position", 0, 65535, pos); + toxine_draw_bar(tox, "Current position", 0, 65535, pos); } else if(toxine_is_arg_contain(tox, 2, "time")) { int seconds; @@ -1904,7 +1940,7 @@ pinfo(" ident: '%s'\n", mmk.ident); pinfo(" mrl: '%s'\n", mmk.mrl); pinfo(" start @ %d, end @ %d.\n", mmk.start, mmk.end); - confirm = (tox->interactive) ? (toxine_confirm("Add mediamark ? [yes|no]: ")) : 1; + confirm = (tox->interactive) ? (toxine_confirm(tox, "Add mediamark ? [yes|no]: ")) : 1; if(confirm) { playlist_add_entry(tox, mmk.mrl, mmk.ident, mmk.start, mmk.end); @@ -1978,7 +2014,7 @@ pinfo(" ident: '%s'\n", mmk.ident); pinfo(" mrl: '%s'\n", mmk.mrl); pinfo(" start @ %d, end @ %d.\n", mmk.start, mmk.end); - confirm = (tox->interactive) ? (toxine_confirm("Add mediamark ? [yes|no]: ")) : 1; + confirm = (tox->interactive) ? (toxine_confirm(tox, "Add mediamark ? [yes|no]: ")) : 1; if(confirm) { playlist_add_entry(tox, mmk.mrl, mmk.ident, mmk.start, mmk.end); @@ -2200,7 +2236,7 @@ pinfo(" mrl: '%s'\n", mmk.mrl); pinfo(" start @ %d, end @ %d.\n", mmk.start, mmk.end); - confirm = (tox->interactive) ? (toxine_confirm("Replace mediamark ? [yes|no]: ")) : 1; + confirm = (tox->interactive) ? (toxine_confirm(tox, "Replace mediamark ? [yes|no]: ")) : 1; if(confirm) { playlist_replace_entry(&tox->playlist.mmk[entry], Index: common.h =================================================================== RCS file: /cvsroot/toxine/toxine/src/common.h,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- common.h 16 May 2004 20:28:40 -0000 1.27 +++ common.h 17 May 2004 19:53:24 -0000 1.28 @@ -82,39 +82,51 @@ } while(0) #define poutalign() do { \ - fprintf(stdout, "%s", EMPTY_PREFIX); \ - fflush(stdout); \ + if(!tox->stdin) { \ + fprintf(stdout, "%s", EMPTY_PREFIX); \ + fflush(stdout); \ + } \ } while(0) #define pout(FMT,ARGS...) do { \ - fprintf(stdout, FMT, ##ARGS); \ - fflush(stdout); \ + if(!tox->stdin) { \ + fprintf(stdout, FMT, ##ARGS); \ + fflush(stdout); \ + } \ } while(0) #define perr(FMT,ARGS...) do { \ - fprintf(stdout, "%s", ERROR_PREFIX); \ - fprintf(stdout, FMT, ##ARGS); \ - fflush(stdout); \ + if(!tox->stdin) { \ + fprintf(stdout, "%s", ERROR_PREFIX); \ + fprintf(stdout, FMT, ##ARGS); \ + fflush(stdout); \ + } \ } while(0) #define pinfo(FMT,ARGS...) do { \ - fprintf(stdout, "%s", INFO_PREFIX); \ - fprintf(stdout, FMT, ##ARGS); \ - fflush(stdout); \ + if(!tox->stdin) { \ + fprintf(stdout, "%s", INFO_PREFIX); \ + fprintf(stdout, FMT, ##ARGS); \ + fflush(stdout); \ + } \ } while(0) #define phelp(FMT,ARGS...) do { \ - fprintf(stdout, "%s", HELP_PREFIX); \ - fprintf(stdout, FMT, ##ARGS); \ - fflush(stdout); \ + if(!tox->stdin) { \ + fprintf(stdout, "%s", HELP_PREFIX); \ + fprintf(stdout, FMT, ##ARGS); \ + fflush(stdout); \ + } \ } while(0) #define pecho(FMT,ARGS...) do { \ - fprintf(stdout, "%s", ECHO_PREFIX); \ - fprintf(stdout, FMT, ##ARGS); \ - fflush(stdout); \ + if(!tox->stdin) { \ + fprintf(stdout, "%s", ECHO_PREFIX); \ + fprintf(stdout, FMT, ##ARGS); \ + fflush(stdout); \ + } \ } while(0) #define return_if_no_init(x) do { \ - if(((x)->xine == NULL) || !((x)->xine_state & XINE_INIT)) { \ + if(((x)->xine == NULL) || !((x)->xine_state & XINE_INIT)) { \ perr("%s(): xine engine uninitialized. Do it first.\n", \ __tox_func__); \ return; \ @@ -256,6 +268,8 @@ char buf[256]; char *ln; } script; + + int stdin; }; typedef struct commands_s commands_t; Index: loader.c =================================================================== RCS file: /cvsroot/toxine/toxine/src/loader.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- loader.c 11 Apr 2004 13:32:04 -0000 1.15 +++ loader.c 17 May 2004 19:53:25 -0000 1.16 @@ -35,7 +35,7 @@ extern int errno; -/* #define LOCAL_BUILD 1 */ +#define LOCAL_BUILD 1 #ifdef LOCAL_BUILD #undef TOXINE_PLUGINDIR #define TOXINE_PLUGINDIR "plugins/.libs" Index: main.c =================================================================== RCS file: /cvsroot/toxine/toxine/src/main.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- main.c 16 May 2004 20:35:11 -0000 1.29 +++ main.c 17 May 2004 19:53:25 -0000 1.30 @@ -55,7 +55,7 @@ static toxine_t *tox; /* options args */ -static const char *short_options = "?hs:e:o::vV:A:iI"; +static const char *short_options = "?hs:e:o::vV:A:iIS"; static struct option long_options[] = { { "help" , no_argument , 0, 'h' }, { "script" , required_argument, 0, 's' }, @@ -64,7 +64,8 @@ { "video" , required_argument, 0, 'V' }, { "audio" , required_argument, 0, 'A' }, { "interactive" , required_argument, 0, 'i' }, - { "autoinit" , no_argument, 0, 'I' }, + { "autoinit" , no_argument , 0, 'I' }, + { "stdin" , no_argument , 0, 'S' }, { "version" , no_argument , 0, 'v' }, { 0 , no_argument , 0, 0 } }; @@ -72,19 +73,19 @@ /* * Display version/copyright banner. */ -static void toxine_show_version(void) { +static void toxine_show_version(toxine_t *tox) { int major, minor, sub; - printf("This is toxine - xine shell v%s\n" - "(c) 2002-2003 by Daniel Caujolle-Bert <f1...@us...>.\n", VERSION); + pout("This is toxine - xine shell v%s\n" + "(c) 2002-2003 by Daniel Caujolle-Bert <f1...@us...>.\n", VERSION); - printf("Built with xine library %d.%d.%d (%s)\n", - XINE_MAJOR_VERSION, XINE_MINOR_VERSION, XINE_SUB_VERSION, XINE_VERSION); + pout("Built with xine library %d.%d.%d (%s)\n", + XINE_MAJOR_VERSION, XINE_MINOR_VERSION, XINE_SUB_VERSION, XINE_VERSION); xine_get_version (&major, &minor, &sub); - printf("Found xine library version: %d.%d.%d (%s).\n", - major, minor, sub, xine_get_version_string()); + pout("Found xine library version: %d.%d.%d (%s).\n", + major, minor, sub, xine_get_version_string()); } @@ -95,6 +96,7 @@ printf("Usage: toxine [options]\n"); printf(" -s, --script <filename> Use <filename> as toxine script file.\n"); + printf(" -S, --stdin Send commands line using stdin.\n"); printf(" -e, --execute <commands> Execute specified commands (like in prompt mode).\n"); printf(" -o, --output [filename] Save all messages in a file(*).\n"); printf(" *('toxine.out' if filename isn't specified).\n"); @@ -261,8 +263,12 @@ tox->autoinit = 1; break; + case 'S': + tox->stdin = 1; + break; + case 'v': /* Display version and exit*/ - toxine_show_version(); + toxine_show_version(tox); exit(1); break; @@ -292,7 +298,7 @@ fprintf(stderr, "Cannot dup2 stderr: %s\n", strerror(errno)); } - toxine_show_version(); + toxine_show_version(tox); toxine_get_extra_argv(tox, argc - optind, &argv[optind], argv[0]); Index: utils.c =================================================================== RCS file: /cvsroot/toxine/toxine/src/utils.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- utils.c 16 May 2004 20:28:40 -0000 1.26 +++ utils.c 17 May 2004 19:53:25 -0000 1.27 @@ -122,7 +122,7 @@ return pbuf; } -int toxine_confirm(char *message) { +int toxine_confirm(toxine_t *tox, char *message) { char *line; char prompt[strlen(HELP_PREFIX) + strlen(message) + 1]; @@ -146,7 +146,7 @@ return 0; } -void toxine_draw_bar(char *title, int min, int max, int val) { +void toxine_draw_bar(toxine_t *tox, char *title, int min, int max, int val) { float _val = (int) val; float _min = (int) min; float _max = (int) max; @@ -628,7 +628,7 @@ } } -void toxine_show_stream_info(int info_type, uint32_t iinfo) { +void toxine_show_stream_info(toxine_t *tox, int info_type, uint32_t iinfo) { switch(info_type) { case XINE_STREAM_INFO_BITRATE: case XINE_STREAM_INFO_SEEKABLE: Index: utils.h =================================================================== RCS file: /cvsroot/toxine/toxine/src/utils.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- utils.h 16 May 2004 20:28:40 -0000 1.13 +++ utils.h 17 May 2004 19:53:25 -0000 1.14 @@ -25,7 +25,7 @@ char *toxine_get_yesno_string(uint32_t val); char *toxine_get_fourcc_string(uint32_t f); char *toxine_atoa(char *str); -int toxine_confirm(char *message); +int toxine_confirm(toxine_t *tox, char *message); void toxine_update_prompt(toxine_t *tox); int toxine_system(int dont_run_as_root, char *command); int toxine_get_bool_value(const char *val); @@ -36,7 +36,7 @@ const char *toxine_get_arg(toxine_t *tox, int num); int toxine_is_arg_contain(toxine_t *tox, int pos, const char *arg); int toxine_mkdir_safe(char *path); -void toxine_draw_bar(char *title, int min, int max, int val); +void toxine_draw_bar(toxine_t *tox, char *title, int min, int max, int val); void toxine_set_last_char_result(toxine_t *tox, const char *result); void toxine_set_last_achar_result(toxine_t *tox, const char *const *result); @@ -53,7 +53,7 @@ void toxine_config_load(toxine_t *tox); void toxine_config_save(toxine_t *tox); -void toxine_show_stream_info(int info_type, uint32_t iinfo); +void toxine_show_stream_info(toxine_t *tox, int info_type, uint32_t iinfo); char *toxine_get_var(toxine_t *tox, const char *var); Index: xine_commands.c =================================================================== RCS file: /cvsroot/toxine/toxine/src/xine_commands.c,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- xine_commands.c 11 Apr 2004 13:29:38 -0000 1.44 +++ xine_commands.c 17 May 2004 19:53:25 -0000 1.45 @@ -31,6 +31,7 @@ #include <signal.h> #include <pthread.h> +#define XINE_ENABLE_EXPERIMENTAL_FEATURES 1 #include <xine.h> #include <xine/xineutils.h> @@ -676,7 +677,7 @@ } else { - printf("wrong command syntax, try 'syntax xine_play'\n"); + perr("wrong command syntax, try 'syntax xine_play'\n"); return; } @@ -772,7 +773,7 @@ pinfo("xine_get_stream_info(%s):\n", stream_infos[i].name); stream_info = xine_get_stream_info(tox->stream, stream_infos[i].type); toxine_set_last_int_result(tox, stream_info); - toxine_show_stream_info(stream_infos[i].type, stream_info); + toxine_show_stream_info(tox, stream_infos[i].type, stream_info); pinfo(".\n"); } } @@ -1107,7 +1108,7 @@ break; case XINE_PARAM_AUDIO_VOLUME: - toxine_draw_bar("audio volume", 0, 255, result); + toxine_draw_bar(tox, "audio volume", 0, 255, result); break; case XINE_PARAM_AUDIO_MUTE: @@ -1115,11 +1116,11 @@ break; case XINE_PARAM_AUDIO_COMPR_LEVEL: - toxine_draw_bar("compression level", 0, 255, result); + toxine_draw_bar(tox, "compression level", 0, 255, result); break; case XINE_PARAM_AUDIO_AMP_LEVEL: - toxine_draw_bar("amplification level", 0, 100, result); + toxine_draw_bar(tox, "amplification level", 0, 100, result); break; case XINE_PARAM_AUDIO_REPORT_LEVEL: @@ -1148,27 +1149,27 @@ break; case XINE_PARAM_VO_HUE: - toxine_draw_bar("video output hue", 0, 65535, result); + toxine_draw_bar(tox, "video output hue", 0, 65535, result); break; case XINE_PARAM_VO_SATURATION: - toxine_draw_bar("video output saturation", 0, 65535, result); + toxine_draw_bar(tox, "video output saturation", 0, 65535, result); break; case XINE_PARAM_VO_CONTRAST: - toxine_draw_bar("video output hue", 0, 65535, result); + toxine_draw_bar(tox, "video output hue", 0, 65535, result); break; case XINE_PARAM_VO_BRIGHTNESS: - toxine_draw_bar("video output brightness", 0, 65535, result); + toxine_draw_bar(tox, "video output brightness", 0, 65535, result); break; case XINE_PARAM_VO_ZOOM_X: - toxine_draw_bar("video output zoom X", 0, 100, result); + toxine_draw_bar(tox, "video output zoom X", 0, 100, result); break; case XINE_PARAM_VO_ZOOM_Y: - toxine_draw_bar("video output zoom Y", 0, 100, result); + toxine_draw_bar(tox, "video output zoom Y", 0, 100, result); break; case XINE_PARAM_VO_PAN_SCAN: @@ -1251,7 +1252,7 @@ toxine_set_last_int_result(tox, result); stime = time / 1000; slength = length / 1000; - toxine_draw_bar("", 0, length, time); + toxine_draw_bar(tox, "", 0, length, time); pinfo("position:\n"); pinfo("Stream %d (0...65535), " "time %02d:%02d:%02d (%dms).\n", @@ -2090,7 +2091,7 @@ iinfo = xine_get_stream_info(tox->stream, stream_infos[i].type); toxine_set_last_int_result(tox, iinfo); pinfo("%s: ", stream_infos[i].name); - toxine_show_stream_info(stream_infos[i].type, iinfo); + toxine_show_stream_info(tox, stream_infos[i].type, iinfo); } pinfo(".\n"); } Index: xine_commands.h =================================================================== RCS file: /cvsroot/toxine/toxine/src/xine_commands.h,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- xine_commands.h 7 Apr 2004 18:21:07 -0000 1.27 +++ xine_commands.h 17 May 2004 19:53:25 -0000 1.28 @@ -440,7 +440,6 @@ } - #if 0 /* ... */ /* xine_audio_port_t *xine_open_audio_driver (xine_t *self, const char *id, |