[Toxine-cvs] CVS: toxine/src commands.c,1.74,1.75 common.h,1.31,1.32 main.c,1.35,1.36 utils.c,1.30,1
Brought to you by:
f1rmb
From: Daniel Caujolle-B. <f1...@us...> - 2004-05-30 22:25:19
|
Update of /cvsroot/toxine/toxine/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20943 Modified Files: commands.c common.h main.c utils.c xine_commands.c Log Message: watchdog added (see 'set' command). Index: commands.c =================================================================== RCS file: /cvsroot/toxine/toxine/src/commands.c,v retrieving revision 1.74 retrieving revision 1.75 diff -u -r1.74 -r1.75 --- commands.c 30 May 2004 19:25:23 -0000 1.74 +++ commands.c 30 May 2004 22:25:05 -0000 1.75 @@ -375,7 +375,9 @@ "set audio volume <level>\n" "set interative <[yes | no | 1 | 0 | true | false]>\n" "set mrl <mrl>\n" - "set loop <[playlist | mrl]>" + "set loop <[playlist | mrl]>\n" + "set watchdog <[yes | no | 1 | 0 | on | off]>\n" + "set watchdog timeout <secs>" }, { "shell", OPTIONAL_ARGS, do_shell, "Execute a shell, or a command if an argument to this command is given.", @@ -428,6 +430,7 @@ * Callback called on XINE_EVENT_PLAYBACK_FINISHED event */ static void finished_cb(toxine_t *tox) { + int result; if(tox->ignore_finished) return; @@ -445,7 +448,11 @@ error_code_clear(tox); pinfo("xine_open(%s):", tox->current_mrl); - if(xine_open(tox->stream, tox->current_mrl)) { + start_watchdog(tox, "xine_open"); + result = xine_open(tox->stream, tox->current_mrl); + stop_watchdog(tox); + + if(result) { tox->xine_state |= XINE_OPEN; _xine_play(NULL, tox, (void *)NO_ARGS); } @@ -489,7 +496,11 @@ int err; error_code_clear(tox); - if((err = xine_get_pos_length(tox->stream, NULL, &secs, NULL))) + start_watchdog(tox, "xine_get_pos_length"); + err = xine_get_pos_length(tox->stream, NULL, &secs, NULL); + stop_watchdog(tox); + + if(err) secs /= 1000; else error_code_set(tox, TOX_ERR_XINE_GET_POS_LENGTH); @@ -654,7 +665,9 @@ tox->audio.mixer.enable = 0; tox->audio.mixer.caps = 0; + start_watchdog(tox, "xine_open_audio_driver"); tox->audio.port = xine_open_audio_driver(tox->xine, (const char*)tox->audio.name, NULL); + stop_watchdog(tox); if(tox->audio.port == NULL) { perr("xine_load_audio_output_plugin() failed to load '%s' driver.\n", tox->audio.name); error_code_set(tox, TOX_ERR_XINE_OPEN_AUDIO_DRIVER); @@ -919,6 +932,17 @@ _xine_stream_new(NULL, tox, NULL); } +#ifdef LOCAL_BUILD + { + char cwd[_PATH_MAX]; + + getcwd(&cwd[0], sizeof(cwd)); + pinfo("****************************************************\n"); + pinfo("BIG FAT WARNING: You're loading output plugins from '%s/plugins/.libs'.\n", cwd); + pinfo("****************************************************\n"); + } +#endif + if(tox->stdin) { tox->interactive = 0; toxine_handle_stdin(tox); @@ -1114,7 +1138,7 @@ if(toxine_is_arg_contain(tox, 1, "mrl")) toxine_set_current_mrl(tox, (toxine_get_arg(tox, 2))); - if(toxine_is_arg_contain(tox, 1, "loop")) { + else if(toxine_is_arg_contain(tox, 1, "loop")) { const char *lmode = toxine_get_arg(tox, 2); int i, mode = -1; @@ -1230,6 +1254,29 @@ } } } + else if(toxine_is_arg_contain(tox, 1, "watchdog")) { + if(nargs >= 3) { + + if(toxine_is_arg_contain(tox, 2, "timeout")) { + const char *arg = toxine_get_arg(tox, 3); + int value = strtol(arg, (char **)&arg, 10); + + if(value >= 1) { + pinfo("new watchdog timeout: %d sec(s)\n", value); + tox->watchdog.timeout = value; + } + else + perr("watchdog timeout value should be >= 1.\n"); + } + } + else { + const char *arg = toxine_get_arg(tox, 2); + int bool = toxine_get_bool_value(arg); + + pinfo("Watchdog is '%s'\n", (bool) ? "enable" : "disable"); + tox->watchdog.enabled = bool; + } + } } } @@ -1270,6 +1317,7 @@ * Start to playback an mrl. */ static void do_play(commands_t *command, toxine_t *tox, void *data) { + int result; return_if_no_init(tox); return_if_no_stream(tox); @@ -1286,7 +1334,10 @@ } pinfo("xine_open(%s):", tox->current_mrl); - if(xine_open(tox->stream, tox->current_mrl)) { + start_watchdog(tox, "xine_open"); + result = xine_open(tox->stream, tox->current_mrl); + stop_watchdog(tox); + if(result) { tox->xine_state |= XINE_OPEN; _xine_play(command, tox, (void *)NO_ARGS); } @@ -1311,27 +1362,43 @@ * Pause/Resume playback. */ static void do_pause(commands_t *command, toxine_t *tox, void *data) { + int speed; return_if_no_init(tox); error_code_clear(tox); - if((xine_get_param(tox->stream, XINE_PARAM_SPEED)) != XINE_SPEED_PAUSE) - xine_set_param(tox->stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE); + pinfo("xine_get_param():\n"); + start_watchdog(tox, "xine_get_param"); + speed = xine_get_param(tox->stream, XINE_PARAM_SPEED); + stop_watchdog(tox); + pinfo(".\n"); + + if(speed != XINE_SPEED_PAUSE) + speed = XINE_SPEED_PAUSE; else - xine_set_param(tox->stream, XINE_PARAM_SPEED, XINE_SPEED_NORMAL); + speed = XINE_SPEED_NORMAL; + pinfo("xine_set_param(%d):\n", speed); + start_watchdog(tox, "xine_set_param"); + xine_set_param(tox->stream, XINE_PARAM_SPEED, speed); + stop_watchdog(tox); + pinfo(".\n"); } /* * Jump in stream. */ static void do_jump(commands_t *command, toxine_t *tox, void *data) { - int pos; + int pos, seekable, result; return_if_no_init(tox); error_code_clear(tox); - if((xine_get_stream_info(tox->stream, XINE_STREAM_INFO_SEEKABLE)) == 0) { + start_watchdog(tox, "ine_get_stream_info"); + seekable = xine_get_stream_info(tox->stream, XINE_STREAM_INFO_SEEKABLE); + stop_watchdog(tox); + + if(seekable == 0) { pinfo("Stream is not seekable\n"); return; } @@ -1344,7 +1411,10 @@ pos = atoi((toxine_get_arg(tox, 1))); - if(!xine_play(tox->stream, pos, 0)) { + start_watchdog(tox, "xine_play"); + result = xine_play(tox->stream, pos, 0); + stop_watchdog(tox); + if(!result) { perr("xine_play() failed.\n"); error_code_set(tox, TOX_ERR_XINE_PLAY); } @@ -1355,12 +1425,16 @@ * Seek in stream. */ static void do_seek(commands_t *command, toxine_t *tox, void *data) { - int msec; + int msec, seekable, result; return_if_no_init(tox); error_code_clear(tox); - if((xine_get_stream_info(tox->stream, XINE_STREAM_INFO_SEEKABLE)) == 0) { + start_watchdog(tox, "xine_get_stream_info"); + seekable = xine_get_stream_info(tox->stream, XINE_STREAM_INFO_SEEKABLE); + stop_watchdog(tox); + + if(seekable == 0) { pinfo("Stream is not seekable\n"); return; } @@ -1375,8 +1449,11 @@ if(msec < 0) msec = 0; - - if(!xine_play(tox->stream, 0, msec)) { + + start_watchdog(tox, "xine_play"); + result = xine_play(tox->stream, 0, msec); + stop_watchdog(tox); + if(!result) { perr("xine_play() failed.\n"); error_code_set(tox, TOX_ERR_XINE_PLAY); } @@ -1410,6 +1487,7 @@ */ static void do_version(commands_t *command, toxine_t *tox, void *data) { int major, minor, sub; + const char *str; error_code_clear(tox); @@ -1417,9 +1495,16 @@ pinfo("Copyright 2002-2004, Daniel Caujolle-Bert <f1...@us...>.\n"); pinfo("Built with xine library %d.%d.%d (%s).\n", XINE_MAJOR_VERSION, XINE_MINOR_VERSION, XINE_SUB_VERSION, XINE_VERSION); + + start_watchdog(tox, "xine_get_version"); xine_get_version(&major, &minor, &sub); - pinfo("Found xine library version: %d.%d.%d (%s).\n", - major, minor, sub, xine_get_version_string()); + stop_watchdog(tox); + + start_watchdog(tox, "xine_get_version_string"); + str = xine_get_version_string(); + stop_watchdog(tox); + + pinfo("Found xine library version: %d.%d.%d (%s).\n", major, minor, sub, str); pinfo("Using readline version %s.\n", rl_library_version); pinfo(".\n"); } @@ -1576,7 +1661,11 @@ if(status_value >= 0) { /* STOP PLAY QUIT */ do { xine_usec_sleep((1/90000.0)*2); + + start_watchdog(tox, "xine_get_status"); status = xine_get_status(tox->stream); + stop_watchdog(tox); + status_happend = (status == status_value) ? 1 : 0; } while(!status_happend); @@ -1612,7 +1701,11 @@ do { xine_usec_sleep((1/90000.0)*2); + + start_watchdog(tox, "xine_get_param"); speed_status = xine_get_param(tox->stream, XINE_PARAM_SPEED); + stop_watchdog(tox); + status_happend = (speed == speed_status) ? 1 : 0; } while(!status_happend); @@ -1743,7 +1836,11 @@ * start playback with new selected stream */ if(tox->xine && (old_cur != tox->playlist.cur)) { - int status = xine_get_status(tox->stream); + int status; + + start_watchdog(tox, "xine_get_status"); + status = xine_get_status(tox->stream); + stop_watchdog(tox); if(status == XINE_STATUS_PLAY) _xine_play(NULL, tox, (void *)NO_ARGS); @@ -1784,7 +1881,11 @@ plugname = toxine_get_arg(tox, 2); pinfo("Grab mrls from '%s' input plugin.\n", plugname); + + start_watchdog(tox, "xine_get_autoplay_mrls"); ap = xine_get_autoplay_mrls(tox->xine, plugname, &mrls); + stop_watchdog(tox); + if(ap && mrls) { for(i = 0; i < mrls; i++) @@ -1920,6 +2021,9 @@ pinfo(" current: '%d'\n", tox->playlist.cur); pinfo(" loop: '%s' [%s]\n", (tox->playlist.loop) ? "YES" : "NO", loop_modes[tox->loop_mode].name); + pinfo(" Watchdog:\n"); + pinfo(" enabled: '%s'\n", (tox->watchdog.enabled) ? "yes" : "no"); + pinfo(" timeout: '%d' second(s)\n", tox->watchdog.timeout); pinfo(" Script:\n"); pinfo(" in use: '%s'\n", (tox->script.in_use) ? "YES" : "NO"); pinfo(" file: '%s'\n", (tox->script.filename) ? tox->script.filename : "not set"); @@ -1933,8 +2037,12 @@ int ret, pos; #warning Set last result return_if_no_init(tox); + + start_watchdog(tox, "xine_get_pos_length"); + ret = xine_get_pos_length(tox->stream, &pos, NULL, NULL); + stop_watchdog(tox); - if(!(ret = xine_get_pos_length(tox->stream, &pos, NULL, NULL))) + if(!ret) error_code_set(tox, TOX_ERR_XINE_GET_POS_LENGTH); else toxine_draw_bar(tox, "Current position", 0, 65535, pos); @@ -1943,13 +2051,16 @@ int err, seconds; return_if_no_init(tox); + + start_watchdog(tox, "xine_get_pos_length"); + err = xine_get_pos_length(tox->stream, NULL, &seconds, NULL); + stop_watchdog(tox); - if(!(err = xine_get_pos_length(tox->stream, NULL, &seconds, NULL))) + if(!err) error_code_set(tox, TOX_ERR_XINE_GET_POS_LENGTH); else { seconds /= 1000; - pinfo("Current time: %02d:%02d:%02d\n", - seconds / (60 * 60), (seconds / 60) % 60, seconds % 60); + pinfo("Current time: %02d:%02d:%02d\n", seconds / (60 * 60), (seconds / 60) % 60, seconds % 60); } } @@ -2381,7 +2492,11 @@ * start playback with new selected stream */ if(tox->xine && (old_cur != tox->playlist.cur)) { - int status = xine_get_status(tox->stream); + int status; + + start_watchdog(tox, "xine_get_status"); + status = xine_get_status(tox->stream); + stop_watchdog(tox); if(status == XINE_STATUS_PLAY) _xine_play(NULL, tox, (void *)NO_ARGS); @@ -2446,16 +2561,27 @@ } static void do_dumpconfig(commands_t *command, toxine_t *tox, void *data) { + int result; _cfg_entry_t cfg_entry; return_if_no_new(tox); error_code_clear(tox); pinfo("Dumping all config object:\n"); - if((xine_config_get_first_entry(tox->xine, &cfg_entry))) { + + start_watchdog(tox, "xine_config_get_first_entry"); + result = xine_config_get_first_entry(tox->xine, &cfg_entry); + stop_watchdog(tox); + + if(result) { do { toxine_dump_config_entry(tox, &cfg_entry); - } while((xine_config_get_next_entry(tox->xine, &cfg_entry))); + + start_watchdog(tox, "xine_config_get_next_entry"); + result = xine_config_get_next_entry(tox->xine, &cfg_entry); + stop_watchdog(tox); + + } while(result); } else error_code_set(tox, TOX_ERR_XINE_CONFIG_GET_FIRST_ENTRY); Index: common.h =================================================================== RCS file: /cvsroot/toxine/toxine/src/common.h,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- common.h 27 May 2004 00:27:39 -0000 1.31 +++ common.h 30 May 2004 22:25:05 -0000 1.32 @@ -36,6 +36,18 @@ #include "vo_plugin.h" #include "errors.h" +#ifndef timersub +#define timersub(a, b, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ + if ((result)->tv_usec < 0) { \ + --(result)->tv_sec; \ + (result)->tv_usec += 1000000; \ + } \ + } while (0) +#endif + #ifndef __GNUC__ #define __tox_func__ __func__ #else @@ -188,6 +200,24 @@ } while(0) +#define start_watchdog(x,f) do { \ + pthread_mutex_lock(&(x)->watchdog.mutex); \ + if((x)->watchdog.running) { \ + perr("GASP! Watchdog is already running for '%s()'\n", (x)->watchdog.function); \ + abort(); \ + } \ + snprintf((x)->watchdog.function, sizeof((x)->watchdog.function), "%s", (f)); \ + (x)->watchdog.running = 1; \ + gettimeofday(&(x)->watchdog.tv, NULL); \ + pthread_mutex_unlock(&(x)->watchdog.mutex); \ + } while(0) + +#define stop_watchdog(x) do { \ + pthread_mutex_lock(&(x)->watchdog.mutex); \ + (x)->watchdog.running = 0; \ + pthread_mutex_unlock(&(x)->watchdog.mutex); \ + } while(0) + #ifndef NAME_MAX #define _NAME_MAX 256 #else @@ -214,6 +244,16 @@ struct toxine_s { pid_t pid; + + struct { + int enabled; + pthread_mutex_t mutex; + char function[256]; + int running; + int timeout; /* in secs */ + struct timeval tv; + } watchdog; + int argc; char **argv; Index: main.c =================================================================== RCS file: /cvsroot/toxine/toxine/src/main.c,v retrieving revision 1.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- main.c 27 May 2004 21:23:43 -0000 1.35 +++ main.c 30 May 2004 22:25:05 -0000 1.36 @@ -109,11 +109,52 @@ } } +static void *_watchdog_loop(void *data) { + toxine_t *tox = (toxine_t *) data; + int i = 0; + + while(tox->running) { + + if(tox->watchdog.enabled) { + if(i % 2) { + + if(tox->watchdog.running) { + long int timeout; + struct timeval tv, tvd; + + pthread_mutex_lock(&tox->watchdog.mutex); + + gettimeofday(&tv, NULL); + timersub(&tv, &tox->watchdog.tv, &tvd); + timeout = tvd.tv_sec + (tvd.tv_usec / 1000000.0); + + if(timeout > tox->watchdog.timeout) { + pout("\n"); + perr("Watchdog triggered:\n"); + perr(" Time exceeded, >%ds, in function '%s()', exiting...\n", + tox->watchdog.timeout, tox->watchdog.function); + + exit(TOX_ERR_DEADLOCK); + } + + pthread_mutex_unlock(&tox->watchdog.mutex); + } + } + } + + xine_usec_sleep(500000.0); + i++; + } + + pthread_exit(NULL); +} + /* * Display version/copyright banner. */ static void toxine_show_version(toxine_t *tox) { - int major, minor, sub; + int major, minor, sub; + const char *str; pout("This is toxine - xine shell v%s\n" "(c) 2002-2003 by Daniel Caujolle-Bert <f1...@us...>.\n", VERSION); @@ -121,10 +162,16 @@ pout("Built with xine library %d.%d.%d (%s)\n", XINE_MAJOR_VERSION, XINE_MINOR_VERSION, XINE_SUB_VERSION, XINE_VERSION); + start_watchdog(tox, "xine_get_version"); xine_get_version (&major, &minor, &sub); + stop_watchdog(tox); + - pout("Found xine library version: %d.%d.%d (%s).\n", - major, minor, sub, xine_get_version_string()); + start_watchdog(tox, "xine_get_version_string"); + str = xine_get_version_string(); + stop_watchdog(tox); + + pout("Found xine library version: %d.%d.%d (%s).\n", major, minor, sub, str); } @@ -159,6 +206,8 @@ if(tox) { int i; + pthread_mutex_destroy(&tox->watchdog.mutex); + if(tox->msg_fd >= 0) close(tox->msg_fd); @@ -221,29 +270,36 @@ int interactive = 1; int i; toxine_error_code_t last_error; - + pthread_t pth; + /* Check xine library version */ if(!xine_check_version(1, 0, 0)) { int major, minor, sub; - + xine_get_version(&major, &minor, &sub); + fprintf(stderr, "Require xine library version 1.0.0, found %d.%d.%d.\n", major, minor, sub); exit(TOX_ERR_WRONG_VERSION); } tox = (toxine_t *) xine_xmalloc(sizeof(toxine_t)); - tox->pid = getppid(); - tox->command.remain = NULL; - tox->command.line = NULL; - tox->command.command = NULL; - tox->command.execute = 0; - tox->xine_state = 0; - tox->msg_fd = -1; - tox->playlist.cur = -1; - tox->playlist.loop = 0; - tox->argc = 0; - tox->argv = NULL; + tox->pid = getppid(); + + pthread_mutex_init(&tox->watchdog.mutex, NULL); + tox->watchdog.enabled = 0; + tox->watchdog.running = 0; + tox->watchdog.timeout = 15; /* 15 secs timeout */ + tox->command.remain = NULL; + tox->command.line = NULL; + tox->command.command = NULL; + tox->command.execute = 0; + tox->xine_state = 0; + tox->msg_fd = -1; + tox->playlist.cur = -1; + tox->playlist.loop = 0; + tox->argc = 0; + tox->argv = NULL; /* * parse command line @@ -351,6 +407,9 @@ perr("Cannot dup2 stderr: %s\n", strerror(errno)); } + tox->running = 1; + pthread_create(&pth, NULL, _watchdog_loop, (void *)tox); + toxine_show_version(tox); toxine_get_extra_argv(tox, argc - optind, &argv[optind], argv[0]); @@ -362,13 +421,18 @@ char *cfgfile = ".xine/toxine_config"; if (!(tox->configfile = getenv ("XINERC"))) { - tox->configfile = (char *) xine_xmalloc((strlen((xine_get_homedir())) + strlen(cfgfile))+2); - sprintf(tox->configfile, "%s/%s", (xine_get_homedir()), cfgfile); + const char *homedir; + + start_watchdog(tox, "xine_get_homedir"); + homedir = xine_get_homedir(); + stop_watchdog(tox); + + tox->configfile = (char *) xine_xmalloc((strlen(homedir) + strlen(cfgfile))+2); + sprintf(tox->configfile, "%s/%s", homedir, cfgfile); } } - tox->running = 1; tox->playlist.mmk = NULL; tox->playlist.thread_num = 0;; tox->loop_mode = PLAYLIST_LOOP; Index: utils.c =================================================================== RCS file: /cvsroot/toxine/toxine/src/utils.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- utils.c 27 May 2004 00:27:39 -0000 1.30 +++ utils.c 30 May 2004 22:25:05 -0000 1.31 @@ -194,8 +194,11 @@ void toxine_update_prompt(toxine_t *tox) { int i = 0, s = -1; - if(tox->xine_state & XINE_STREAM) + if(tox->xine_state & XINE_STREAM) { + start_watchdog(tox, "xine_get_status"); s = xine_get_status(tox->stream); + stop_watchdog(tox); + } while(prompt_state[i].state != NULL) { if(prompt_state[i].xine_state == s) { @@ -584,15 +587,23 @@ break; } + start_watchdog(tox, "xine_config_update_entry"); xine_config_update_entry(tox->xine, entry); + stop_watchdog(tox); } void toxine_config_update_range(toxine_t *tox, char *key, int min, int max) { + int result; _cfg_entry_t entry; error_code_clear(tox); memset(&entry, 0, sizeof(_cfg_entry_t)); - if(xine_config_lookup_entry(tox->xine, key, &entry)) + + start_watchdog(tox, "xine_config_lookup_entry"); + result = xine_config_lookup_entry(tox->xine, key, &entry); + stop_watchdog(tox); + + if(result) _config_update(tox, &entry, XINE_CONFIG_TYPE_RANGE, min, max, 0, NULL); else { perr("WOW, range key %s isn't registered\n", key); @@ -601,11 +612,17 @@ } void toxine_config_update_string(toxine_t *tox, char *key, char *string) { + int result; _cfg_entry_t entry; error_code_clear(tox); memset(&entry, 0, sizeof(_cfg_entry_t)); - if((xine_config_lookup_entry(tox->xine, key, &entry)) && string) + + start_watchdog(tox, "xine_config_lookup_entry"); + result = xine_config_lookup_entry(tox->xine, key, &entry); + stop_watchdog(tox); + + if(result && string) _config_update(tox, &entry, XINE_CONFIG_TYPE_STRING, 0, 0, 0, string); else { if(string == NULL) @@ -618,11 +635,17 @@ } void toxine_config_update_enum(toxine_t *tox, char *key, int value) { + int result; _cfg_entry_t entry; error_code_clear(tox); memset(&entry, 0, sizeof(_cfg_entry_t)); - if(xine_config_lookup_entry(tox->xine, key, &entry)) + + start_watchdog(tox, "xine_config_lookup_entry"); + result = xine_config_lookup_entry(tox->xine, key, &entry); + stop_watchdog(tox); + + if(result) _config_update(tox, &entry, XINE_CONFIG_TYPE_ENUM, 0, 0, value, NULL); else { perr("WOW, enum key %s isn't registered\n", key); @@ -631,11 +654,17 @@ } void toxine_config_update_bool(toxine_t *tox, char *key, int value) { + int result; _cfg_entry_t entry; error_code_clear(tox); memset(&entry, 0, sizeof(_cfg_entry_t)); - if(xine_config_lookup_entry(tox->xine, key, &entry)) + + start_watchdog(tox, "xine_config_lookup_entry"); + result = xine_config_lookup_entry(tox->xine, key, &entry); + stop_watchdog(tox); + + if(result) _config_update(tox, &entry, XINE_CONFIG_TYPE_BOOL, 0, 0, ((value > 0) ? 1 : 0), NULL); else { perr("WOW, bool key %s isn't registered\n", key); @@ -644,11 +673,17 @@ } void toxine_config_update_num(toxine_t *tox, char *key, int value) { + int result; _cfg_entry_t entry; error_code_clear(tox); memset(&entry, 0, sizeof(_cfg_entry_t)); - if(xine_config_lookup_entry(tox->xine, key, &entry)) + + start_watchdog(tox, "xine_config_lookup_entry"); + result = xine_config_lookup_entry(tox->xine, key, &entry); + stop_watchdog(tox); + + if(result) _config_update(tox, &entry, XINE_CONFIG_TYPE_NUM, 0, 0, value, NULL); else { perr("WOW, num key %s isn't registered\n", key); @@ -658,15 +693,20 @@ void toxine_config_load(toxine_t *tox) { error_code_clear(tox); - if(tox) + if(tox) { + start_watchdog(tox, "xine_config_load"); xine_config_load(tox->xine, tox->configfile); + stop_watchdog(tox); + } } void toxine_config_save(toxine_t *tox) { error_code_clear(tox); if(tox) { return_if_no_new(tox); + start_watchdog(tox, "xine_config_save"); xine_config_save(tox->xine, tox->configfile); + stop_watchdog(tox); } } Index: xine_commands.c =================================================================== RCS file: /cvsroot/toxine/toxine/src/xine_commands.c,v retrieving revision 1.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- xine_commands.c 30 May 2004 19:25:23 -0000 1.47 +++ xine_commands.c 30 May 2004 22:25:05 -0000 1.48 @@ -307,7 +307,9 @@ return_if_no_stream(tox); + start_watchdog(tox, "xine_get_error"); err = xine_get_error(tox->stream); + stop_watchdog(tox); switch(err) { case XINE_ERROR_NONE: @@ -444,7 +446,9 @@ } pinfo("xine_new():\n"); + start_watchdog(tox, "xine_new"); tox->xine = xine_new(); + stop_watchdog(tox); pinfo(".\n"); tox->xine_state |= XINE_NEW; @@ -470,7 +474,9 @@ } pinfo("xine_stream_new():\n"); + start_watchdog(tox, "xine_steam_new"); tox->stream = xine_stream_new(tox->xine, tox->audio.port, tox->video.port); + stop_watchdog(tox); pinfo(".\n"); if(tox->stream) { @@ -482,8 +488,13 @@ error_code_set(tox, TOX_ERR_XINE_STREAM_NEW); } + start_watchdog(tox, "xine_event_new_queue"); tox->event_queue = xine_event_new_queue(tox->stream); + stop_watchdog(tox); + + start_watchdog(tox, "xine_event_create_listenen_thread"); xine_event_create_listener_thread(tox->event_queue, toxine_event_listener, (void *) tox); + stop_watchdog(tox); } /* @@ -504,7 +515,9 @@ _xine_new(NULL, tox, NULL); pinfo("xine_init():\n"); + start_watchdog(tox, "xine_init"); xine_init(tox->xine); + stop_watchdog(tox); pinfo(".\n"); tox->xine_state |= XINE_INIT; pthread_mutex_init(&tox->event.mutex, NULL); @@ -543,9 +556,13 @@ toxine_set_current_mrl(tox, mrl); pinfo("xine_open(%s):\n", tox->current_mrl); - if(!(result = xine_open(tox->stream, tox->current_mrl))) - error_code_set(tox, TOX_ERR_XINE_OPEN); + start_watchdog(tox, "xine_open"); + result = xine_open(tox->stream, tox->current_mrl); + stop_watchdog(tox); + if(!result) + error_code_set(tox, TOX_ERR_XINE_OPEN); + toxine_set_last_int_result(tox, result); pinfo("-- returned %d\n", result); tox->xine_state |= XINE_OPEN; @@ -717,13 +734,23 @@ if(need_open) { pinfo("xine_open(%s) && xine_play(%d, %d):\n", mrl, start, time); - if((!(open_result = xine_open(tox->stream, mrl))) || (!(result = xine_play(tox->stream, start, time)))) { + + start_watchdog(tox, "xine_open"); + open_result = xine_open(tox->stream, mrl); + stop_watchdog(tox); + + start_watchdog(tox, "xine_play"); + result = xine_play(tox->stream, start, time); + stop_watchdog(tox); + + if(!open_result || !result) { if(!open_result) { error_code_set(tox, TOX_ERR_XINE_OPEN); result = open_result; } else error_code_set(tox, TOX_ERR_XINE_PLAY); + toxine_handle_xine_errors(tox); } else @@ -732,7 +759,11 @@ } else { pinfo("xine_play(%d, %d):\n", start, time); - if(!(result = xine_play(tox->stream, start, time))) { + start_watchdog(tox, "xine_play"); + result = xine_play(tox->stream, start, time); + stop_watchdog(tox); + + if(!result) { error_code_set(tox, TOX_ERR_XINE_PLAY); toxine_handle_xine_errors(tox); } @@ -770,9 +801,13 @@ value = atoi(((char *)toxine_get_arg(tox, 2))); pinfo("xine_trick_mode(%s, %d):\n", xine_tricks[i].name, value); + start_watchdog(tox, "xine_trick_mode"); result = xine_trick_mode(tox->stream, trick_mode, value); + stop_watchdog(tox); + if(!result) error_code_set(tox, TOX_ERR_XINE_TRICK_MODE); + toxine_set_last_int_result(tox, result); pinfo("--returned %d\n", result); } @@ -810,7 +845,10 @@ uint32_t stream_info; pinfo("xine_get_stream_info(%s):\n", stream_infos[i].name); + start_watchdog(tox, "xine_get_stream_info"); stream_info = xine_get_stream_info(tox->stream, stream_infos[i].type); + stop_watchdog(tox); + toxine_set_last_int_result(tox, stream_info); toxine_show_stream_info(tox, stream_infos[i].type, stream_info); pinfo(".\n"); @@ -840,7 +878,10 @@ const char *meta_info; pinfo("xine_get_meta_info(%s):\n", meta_infos[i].name); + start_watchdog(tox, "xine_get_meta_info"); meta_info = xine_get_meta_info(tox->stream, stream_infos[i].type); + stop_watchdog(tox); + toxine_set_last_char_result(tox, meta_info); switch(meta_infos[i].type) { @@ -872,7 +913,9 @@ error_code_clear(tox); tox->ignore_finished = 1; pinfo("xine_stop():\n"); + start_watchdog(tox, "xine_stop"); xine_stop(tox->stream); + stop_watchdog(tox); pinfo(".\n"); } @@ -886,7 +929,9 @@ return_if_no_stream(tox); pinfo("xine_eject():\n"); + start_watchdog(tox, "xine_eject"); retval = xine_eject(tox->stream); + stop_watchdog(tox); toxine_set_last_int_result(tox, retval); pinfo("returned %d.\n", retval); pinfo(".\n"); @@ -902,7 +947,7 @@ error_code_clear(tox); toxine_config_save(tox); - + if(tox->xine_state & XINE_STREAM) { _xine_close(NULL, tox, NULL); _xine_dispose(NULL, tox, NULL); @@ -911,7 +956,9 @@ if(tox->xine_state & XINE_INIT) { if(tox->event_queue) { pinfo("xine_event_dispose_queue():\n"); + start_watchdog(tox, "xine_event_dispose_queue"); xine_event_dispose_queue(tox->event_queue); + stop_watchdog(tox); pinfo(".\n"); tox->event_queue = NULL; } @@ -926,12 +973,16 @@ tox->video.cur_plugin = NULL; if(tox->audio.port) { + start_watchdog(tox, "xine_close_audio_driver"); xine_close_audio_driver(tox->xine, tox->audio.port); + stop_watchdog(tox); tox->audio.port = NULL; } pinfo("xine_exit():\n"); + start_watchdog(tox, "xine_exit"); xine_exit(tox->xine); + stop_watchdog(tox); pinfo(".\n"); tox->xine = NULL; tox->xine_state = 0; @@ -943,7 +994,7 @@ * */ void _xine_get_error(commands_t *command, toxine_t *tox, void *data) { - int xine_errno; + int xine_errno; char buffer[2048]; toxine_unset_last_result(tox); @@ -951,7 +1002,9 @@ error_code_clear(tox); pinfo("xine_get_error():\n"); + start_watchdog(tox, "xine_get_error"); xine_errno = xine_get_error(tox->stream); + stop_watchdog(tox); toxine_set_last_int_result(tox, xine_errno); sprintf(buffer, "returned %d (", xine_errno); @@ -988,7 +1041,9 @@ error_code_clear(tox); pinfo("xine_get_status():\n"); + start_watchdog(tox, "xine_get_status"); status = xine_get_status(tox->stream); + stop_watchdog(tox); toxine_set_last_int_result(tox, status); for(i = 0; xine_status[i].name != NULL; i++) { @@ -1092,7 +1147,9 @@ } pinfo(buffer); + start_watchdog(tox, "xine_set_param"); xine_set_param(tox->stream, xine_params[found].param, value); + stop_watchdog(tox); pinfo(".\n"); } else { @@ -1130,7 +1187,9 @@ int result; pinfo("xine_get_param(%s):\n", xine_params[i].name); + start_watchdog(tox, "xine_get_param"); result = xine_get_param(tox->stream, xine_params[i].param); + stop_watchdog(tox); toxine_set_last_int_result(tox, result); pinfo("returned [%d]:\n", result); @@ -1262,9 +1321,13 @@ channel = tox->audio.channel; pinfo("xine_get_audio_lang(%d):\n", channel); + start_watchdog(tox, "xine_get_audio_lang"); ret = xine_get_audio_lang(tox->stream, channel, &lang[0]); + stop_watchdog(tox); + if(!ret) error_code_set(tox, TOX_ERR_XINE_GET_AUDIO_LANG); + toxine_set_last_int_result(tox, ret); poutalign(); pout("'%s'\n", lang); @@ -1290,9 +1353,13 @@ pinfo("xine_get_spu_lang(%d):\n", channel); + start_watchdog(tox, "xine_get_spu_lang"); ret = xine_get_spu_lang(tox->stream, channel, &lang[0]); + stop_watchdog(tox); + if(!ret) error_code_set(tox, TOX_ERR_XINE_GET_SPU_LANG); + toxine_set_last_int_result(tox, ret); poutalign(); pout("'%s'\n", lang); @@ -1311,9 +1378,13 @@ error_code_clear(tox); pinfo("xine_get_pos_length():\n"); + start_watchdog(tox, "xine_get_pos_length"); result = xine_get_pos_length (tox->stream, &stream, &time, &length); + stop_watchdog(tox); + if(!result) error_code_set(tox, TOX_ERR_XINE_GET_POS_LENGTH); + toxine_set_last_int_result(tox, result); stime = time / 1000; slength = length / 1000; @@ -1342,11 +1413,13 @@ bufname = toxine_get_arg(tox, 1); + start_watchdog(tox, "xine_get_log_names"); log_names = xine_get_log_names(tox->xine); + stop_watchdog(tox); if(!log_names) error_code_set(tox, TOX_ERR_XINE_GET_LOG_NAMES); toxine_set_last_achar_result(tox, log_names); - + if(log_names) { int i; @@ -1370,7 +1443,9 @@ else pinfo("xine_get_log(%s):\n", log); + start_watchdog(tox, "xine_get_log"); logs = xine_get_log(tox->xine, buftype); + stop_watchdog(tox); toxine_set_last_achar_result(tox, logs); if(logs) { char buffer[2048]; @@ -1402,7 +1477,9 @@ memset(&buffer, 0, sizeof(buffer)); pinfo("xine_get_log_names():\n"); + start_watchdog(tox, "xine_get_log_names"); log_names = xine_get_log_names(tox->xine); + stop_watchdog(tox); if(!log_names) error_code_set(tox, TOX_ERR_XINE_GET_LOG_NAMES); toxine_set_last_achar_result(tox, log_names); @@ -1430,7 +1507,9 @@ error_code_clear(tox); pinfo("xine_get_log_section_count():\n"); + start_watchdog(tox, "xine_get_log_section_count"); count = xine_get_log_section_count(tox->xine); + stop_watchdog(tox); toxine_set_last_int_result(tox, count); pinfo("returned %d\n", count); pinfo(".\n"); @@ -1450,7 +1529,9 @@ error_code_clear(tox); bufname = toxine_get_arg(tox, 1); + start_watchdog(tox, "xine_get_log_names"); log_names = xine_get_log_names(tox->xine); + stop_watchdog(tox); if(!log_names) error_code_set(tox, TOX_ERR_XINE_GET_LOG_NAMES); else { @@ -1478,7 +1559,9 @@ else pinfo("xine_log(%s, '%s')\n", log, msg); + start_watchdog(tox, "xine_log"); xine_log(tox->xine, buftype, msg); + stop_watchdog(tox); pinfo(".\n"); } @@ -1493,7 +1576,9 @@ error_code_clear(tox); pinfo("xine_get_browsable_input_plugin_ids():\n"); + start_watchdog(tox, "xine_get_browsable_input_plugin_ids"); inpp = xine_get_browsable_input_plugin_ids(tox->xine); + stop_watchdog(tox); toxine_set_last_achar_result(tox, inpp); if(inpp) { char buffer[4096]; @@ -1541,7 +1626,9 @@ smrl = toxine_get_arg(tox, 2); pinfo("xine_get_browse_mrls(%s,%s):\n", pname, smrl); + start_watchdog(tox, "xine_get_browse_mrls"); bmrls = xine_get_browse_mrls(tox->xine, pname, smrl, &mrls); + stop_watchdog(tox); { char *p[mrls + 1]; @@ -1622,7 +1709,9 @@ error_code_clear(tox); pinfo("xine_get_autoplay_input_plugin_ids():\n"); + start_watchdog(tox, "xine_get_autoplay_input_plugin_ids"); inpp = xine_get_autoplay_input_plugin_ids(tox->xine); + stop_watchdog(tox); toxine_set_last_achar_result(tox, inpp); if(inpp) { @@ -1665,7 +1754,9 @@ pname = toxine_get_arg(tox, 1); pinfo("xine_get_autoplay_mrls(%s):\n", pname); + start_watchdog(tox, "xine_get_autoplay_mrls"); ap = xine_get_autoplay_mrls(tox->xine, pname, &mrls); + stop_watchdog(tox); toxine_set_last_achar_result(tox, (const char *const *)ap); if(ap) { @@ -1694,7 +1785,9 @@ pname = toxine_get_arg(tox, 1); pinfo("xine_get_input_plugin_description(%s):\n", pname); + start_watchdog(tox, "xine_get_input_plugin_description"); ipd = xine_get_input_plugin_description(tox->xine, pname); + stop_watchdog(tox); toxine_set_last_char_result(tox, ipd); if(ipd) { pinfo("description of '%s' plugin id is:\n", pname); @@ -1719,7 +1812,9 @@ error_code_clear(tox); pinfo("xine_list_audio_output_plugins():\n"); + start_watchdog(tox, "xine_list_audio_output_plugins"); aop = xine_list_audio_output_plugins(tox->xine); + stop_watchdog(tox); toxine_set_last_achar_result(tox, aop); if(aop) { @@ -1757,7 +1852,9 @@ error_code_clear(tox); pinfo("xine_list_video_output_plugins():\n"); + start_watchdog(tox, "xine_list_video_output_plugins"); vop = xine_list_video_output_plugins(tox->xine); + stop_watchdog(tox); toxine_set_last_achar_result(tox, vop); if(vop) { @@ -1818,7 +1915,9 @@ gettimeofday(&xine_event.tv, NULL); pinfo("xine_event_send(%d):\n", event_type); + start_watchdog(tox, "xine_event_send"); xine_event_send(tox->stream, &xine_event); + stop_watchdog(tox); pinfo(".\n"); } else { @@ -1838,6 +1937,7 @@ * ****** CONFIG ****** */ void _xine_config_get_first_entry(commands_t *command, toxine_t *tox, void *data) { + int result; _cfg_entry_t cfg_entry; toxine_unset_last_result(tox); @@ -1845,7 +1945,11 @@ error_code_clear(tox); pinfo("xine_config_get_first_entry():\n"); - if((xine_config_get_first_entry(tox->xine, &cfg_entry))) + start_watchdog(tox, "xine_config_get_first_entry"); + result = xine_config_get_first_entry(tox->xine, &cfg_entry); + stop_watchdog(tox); + + if(result) toxine_dump_config_entry(tox, &cfg_entry); else { perr("xine_config_get_first_entry() returned NULL\n"); @@ -1855,6 +1959,7 @@ pinfo(".\n"); } void _xine_config_get_next_entry(commands_t *command, toxine_t *tox, void *data) { + int result; _cfg_entry_t cfg_entry; toxine_unset_last_result(tox); @@ -1862,7 +1967,11 @@ error_code_clear(tox); pinfo("xine_config_get_next_entry():\n"); - if((xine_config_get_next_entry(tox->xine, &cfg_entry))) + start_watchdog(tox, "xine_config_get_next_entry"); + result = xine_config_get_next_entry(tox->xine, &cfg_entry); + stop_watchdog(tox); + + if(result) toxine_dump_config_entry(tox, &cfg_entry); else { perr("xine_config_get_next_entry() returned NULL\n"); @@ -1872,7 +1981,8 @@ pinfo(".\n"); } void _xine_config_lookup_entry(commands_t *command, toxine_t *tox, void *data) { - const char *key; + const char *key; + int result; _cfg_entry_t cfg_entry; toxine_unset_last_result(tox); @@ -1881,7 +1991,11 @@ key = toxine_get_arg(tox, 1); pinfo("xine_config_lookup_entry(%s):\n", key); - if((xine_config_lookup_entry(tox->xine, key, &cfg_entry))) + start_watchdog(tox, "xine_config_lookup_entry"); + result = xine_config_lookup_entry(tox->xine, key, &cfg_entry); + stop_watchdog(tox); + + if(result) toxine_dump_config_entry(tox, &cfg_entry); else { perr("Entry '%s' doesn't exist.\n", key); @@ -1901,6 +2015,7 @@ if(toxine_is_args(tox) >= 2) { const char *svalue; + int result; int valid_entry = 0; key = toxine_get_arg(tox, 1); @@ -1908,7 +2023,11 @@ value = atoi(((char *) svalue)); pinfo("xine_config_lookup_entry(%s):\n", key); - if((xine_config_lookup_entry(tox->xine, key, &cfg_entry))) { + start_watchdog(tox, "xine_config_lookup_entry"); + result = xine_config_lookup_entry(tox->xine, key, &cfg_entry); + stop_watchdog(tox); + + if(result) { switch(cfg_entry.type) { @@ -1936,7 +2055,9 @@ if(valid_entry) { pinfo("xine_config_update_entry(%s):\n", key); + start_watchdog(tox, "xine_config_update_entry"); xine_config_update_entry(tox->xine, &cfg_entry); + stop_watchdog(tox); pinfo(".\n"); } } @@ -1968,7 +2089,9 @@ } pinfo("xine_config_load(%s):\n", tox->configfile); + start_watchdog(tox, "xine_config_load"); xine_config_load(tox->xine, tox->configfile); + stop_watchdog(tox); pinfo(".\n"); } @@ -1983,7 +2106,9 @@ filename = toxine_get_arg(tox, 1); pinfo("xine_config_save(%s):\n", (filename) ? filename : tox->configfile); + start_watchdog(tox, "xine_config_save"); xine_config_save(tox->xine, ((filename) ? filename : tox->configfile)); + stop_watchdog(tox); pinfo(".\n"); } @@ -1994,7 +2119,9 @@ error_code_clear(tox); pinfo("xine_config_reset():\n"); + start_watchdog(tox, "xine_config_reset"); xine_config_reset(tox->xine); + stop_watchdog(tox); pinfo(".\n"); } /* @@ -2012,7 +2139,9 @@ error_code_clear(tox); pinfo("xine_get_version():\n"); + start_watchdog(tox, "xine_get_version"); xine_get_version(&major, &minor, &sub); + stop_watchdog(tox); sprintf(buffer, "%d.%d.%d", major, minor, sub); toxine_set_last_char_result(tox, buffer); @@ -2031,7 +2160,9 @@ error_code_clear(tox); pinfo("xine_get_version_string():\n"); + start_watchdog(tox, "xine_get_version_string"); result = xine_get_version_string(); + stop_watchdog(tox); if(!result) error_code_set(tox, TOX_ERR_XINE_GET_VERSION_STRING); toxine_set_last_char_result(tox, result); @@ -2052,7 +2183,9 @@ if(toxine_is_args(tox) >= 1) { if((sscanf((toxine_get_arg(tox, 1)), "%d.%d.%d", &major, &minor, &sub)) == 3) { pinfo("xine_check_version(%d,%d,%d):\n", major, minor, sub); + start_watchdog(tox, "xine_check_version"); retval = xine_check_version(major, minor, sub); + stop_watchdog(tox); if(!retval) error_code_set(tox, TOX_ERR_XINE_CHECK_VERSION); toxine_set_last_int_result(tox, retval); @@ -2068,7 +2201,9 @@ error_code_clear(tox); pinfo("xine_close():\n"); + start_watchdog(tox, "xine_close"); xine_close(tox->stream); + stop_watchdog(tox); pinfo(".\n"); tox->xine_state &= ~XINE_OPEN; } @@ -2080,13 +2215,17 @@ if(tox->event_queue) { pinfo("xine_event_dispose_queue():\n"); + start_watchdog(tox, "xine_event_dispose_queue"); xine_event_dispose_queue(tox->event_queue); + stop_watchdog(tox); pinfo(".\n"); tox->event_queue = NULL; } pinfo("xine_dispose():\n"); + start_watchdog(tox, "xine_dispose"); xine_dispose(tox->stream); + stop_watchdog(tox); tox->stream = NULL; tox->xine_state &= ~(XINE_OPEN | XINE_STREAM); pinfo(".\n"); @@ -2100,7 +2239,9 @@ error_code_clear(tox); pinfo("xine_get_file_extensions():\n"); + start_watchdog(tox, "xine_get_file_extensions"); exts = xine_get_file_extensions(tox->xine); + stop_watchdog(tox); toxine_set_last_char_result(tox, exts); pinfo("returned: '%s'\n", (exts) ? exts : "NONE"); pinfo(".\n"); @@ -2115,7 +2256,9 @@ error_code_clear(tox); pinfo("xine_get_mime_types():\n"); + start_watchdog(tox, "xine_get_mime_types"); mimes = xine_get_mime_types(tox->xine); + stop_watchdog(tox); toxine_set_last_char_result(tox, mimes); pinfo("returned: '%s'\n", (mimes) ? mimes : "NONE"); pinfo(".\n"); @@ -2143,9 +2286,13 @@ sprintf(buffer, "xine_frame-%d.frm", (unsigned int)(time(NULL))); filename = buffer; } - + + start_watchdog(tox, "xine_get_stream_info"); width = xine_get_stream_info(tox->stream,XINE_STREAM_INFO_VIDEO_WIDTH); + stop_watchdog(tox); + start_watchdog(tox, "xine_get_stream_info"); height = xine_get_stream_info(tox->stream,XINE_STREAM_INFO_VIDEO_HEIGHT); + stop_watchdog(tox); if((!width) || (!height)) { perr("Wrong frame size: %dx%d\n", width, height); @@ -2157,7 +2304,11 @@ frame = (uint8_t *) xine_xmalloc(sizeof(uint8_t) * size); pinfo("xine_get_current_frame():\n"); - if((result = xine_get_current_frame(tox->stream, &width, &height, &ratio_code, &format, frame))) { + start_watchdog(tox, "xine_get_current_frame"); + result = xine_get_current_frame(tox->stream, &width, &height, &ratio_code, &format, frame); + stop_watchdog(tox); + + if(result) { toxine_set_last_int_result(tox, result); pinfo("get frame: %dx%d, ratio %d, format %d\n", width, height, ratio_code, format); @@ -2211,14 +2362,18 @@ pinfo("Meta info:\n"); for(i = 0; meta_infos[i].name != NULL; i++) { + start_watchdog(tox, "xine_get_meta_info"); minfo = xine_get_meta_info(tox->stream, meta_infos[i].type); + stop_watchdog(tox); toxine_set_last_char_result(tox, minfo); pinfo("%s: %s\n", meta_infos[i].name, (minfo) ? (char *) minfo : "Unavailable"); } pinfo("\n"); pinfo("Stream info:\n"); for(i = 0; stream_infos[i].name != NULL; i++) { + start_watchdog(tox, "xine_get_stream_info"); iinfo = xine_get_stream_info(tox->stream, stream_infos[i].type); + stop_watchdog(tox); toxine_set_last_int_result(tox, iinfo); pinfo("%s: ", stream_infos[i].name); toxine_show_stream_info(tox, stream_infos[i].type, iinfo); |