From: maan Date: Thu, 13 Jul 2006 10:41:40 +0000 (+0200) Subject: Merge branch 'master' into my-osx X-Git-Tag: v0.2.14~59 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=c715d5c6ec226fe172ef3b8a52ccf769b745594b;hp=c839ef92e35d5604748aa4674b400156ff7baced Merge branch 'master' into my-osx --- diff --git a/Makefile.in b/Makefile.in index a451e892..2aece7ce 100644 --- a/Makefile.in +++ b/Makefile.in @@ -6,20 +6,16 @@ exec_prefix = @exec_prefix@ BINDIR = @bindir@ VARDIR = /var/paraslash -PKGDATADIR = @datadir@/@PACKAGE_NAME@ +PKGDATADIR = @datarootdir@/@PACKAGE_NAME@ FONTDIR = $(PKGDATADIR)/fonts PICDIR = $(PKGDATADIR)/pics -MANDIR = @prefix@/share/man/man1 +MANDIR = @datarootdir@/man/man1 install_sh = @install_sh@ -SSL_LIBS = @SSL_LIBS@ -SSL_LDFLAGS = @SSL_LDFLAGS@ -extra_binaries = @extra_binaries@ build_date = $(shell date) system = $(shell uname -rs) cc_version = $(shell $(CC) --version | head -n 1) -version = @PACKAGE_VERSION@ codename = oriented abstraction DEBUG_CPPFLAGS += -Wno-sign-compare -g -Wunused -Wundef -W @@ -45,7 +41,6 @@ CPPFLAGS += -DFONTDIR='"$(PKGDATADIR)/fonts"' CPPFLAGS += -DPICDIR='"$(PKGDATADIR)/pics"' CPPFLAGS += -DBUILD_DATE='"$(build_date)"' CPPFLAGS += -DSYSTEM='"$(system)"' -CPPFLAGS += -DVERSION='"$(version)"' CPPFLAGS += -DCODENAME='"$(codename)"' CPPFLAGS += -DCC_VERSION='"$(cc_version)"' CPPFLAGS += -Werror-implicit-function-declaration @@ -53,7 +48,7 @@ CPPFLAGS += -Wmissing-format-attribute CPPFLAGS += -Wunused-macros CPPFLAGS += -Wshadow -BINARIES = para_server para_client para_gui para_audiod para_audioc para_recv para_filter para_write $(extra_binaries) +BINARIES = para_server para_client para_gui para_audiod para_audioc para_recv para_filter para_write @extra_binaries@ FONTS := $(wildcard fonts/*.png) PICS := $(wildcard pics/paraslash/*.jpg) diff --git a/NEWS b/NEWS index 9c8d2cce..c4e087b5 100644 --- a/NEWS +++ b/NEWS @@ -8,8 +8,8 @@ NEWS A bunch of new features and core changes. - the new paraslash scheduler, short and sweet. - - Support for m4a files via the new aac filter/ and audio - format handler (requires libfaad). + - Support for m4a/mp4 files via the new aac audio format + handler/filter (requires libfaad). - each writer has its own command line parser, just like para_recv and para_filter. - new writer: osxplay (thanks to Gerd Becker) @@ -18,8 +18,9 @@ A bunch of new features and core changes. - para_client is integrated in para_audiod - random/playlist selector: improved info strings - new audiod commands: tasks, kill - - update to libortp-0.10.0 + - update to libortp-0.10.1 - para_fade: wake time defaults to 8 hours from now + - update to autoconf-2.60 ------------------------------------------ diff --git a/SFont.c b/SFont.c index 8a078c9f..daed6b51 100644 --- a/SFont.c +++ b/SFont.c @@ -24,7 +24,7 @@ #include /* strlen */ SFont_FontInfo InternalFont; -Uint32 GetPixel(SDL_Surface * Surface, Sint32 X, Sint32 Y) +static Uint32 GetPixel(SDL_Surface *Surface, Sint32 X, Sint32 Y) { Uint8 *bits; @@ -45,8 +45,7 @@ Uint32 GetPixel(SDL_Surface * Surface, Sint32 X, Sint32 Y) return *((Uint8 *) Surface->pixels + Y * Surface->pitch + X); break; case 2: - return *((Uint16 *) Surface->pixels + Y * Surface->pitch / 2 + - X); + return *((Uint16 *) Surface->pixels + Y * Surface->pitch / 2 + X); break; case 3:{ /* Format/endian independent */ Uint8 r, g, b; @@ -57,8 +56,7 @@ Uint32 GetPixel(SDL_Surface * Surface, Sint32 X, Sint32 Y) } break; case 4: - return *((Uint32 *) Surface->pixels + Y * Surface->pitch / 4 + - X); + return *((Uint32 *) Surface->pixels + Y * Surface->pitch / 4 + X); break; } @@ -79,12 +77,11 @@ void InitFont2(SFont_FontInfo * Font) while (x < Font->Surface->w) { if (GetPixel(Font->Surface, x, 0) == - SDL_MapRGB(Font->Surface->format, 255, 0, 255)) { + SDL_MapRGB(Font->Surface->format, 255, 0, 255)) { Font->CharPos[i++] = x; - while ((x < Font->Surface->w - 1) - && (GetPixel(Font->Surface, x, 0) == - SDL_MapRGB(Font->Surface->format, 255, 0, - 255))) + while ((x < Font->Surface->w - 1) && + (GetPixel(Font->Surface, x, 0) == + SDL_MapRGB(Font->Surface->format, 255, 0, 255))) x++; Font->CharPos[i++] = x; } @@ -98,17 +95,6 @@ void InitFont2(SFont_FontInfo * Font) GetPixel(Font->Surface, 0, Font->Surface->h - 1)); } -#if 0 -void InitFont(SDL_Surface * Font) -{ - InternalFont.Surface = Font; - InitFont2(&InternalFont); -} - -#endif - - - void PutString2(SDL_Surface * Surface, SFont_FontInfo * Font, int x, int y, const char *text) { @@ -124,15 +110,14 @@ void PutString2(SDL_Surface * Surface, SFont_FontInfo * Font, int x, int y, ofs = ((unsigned char) text[i] - 33) * 2 + 1; srcrect.w = dstrect.w = (Font->CharPos[ofs + 2] + Font->CharPos[ofs + 1]) / 2 - - (Font->CharPos[ofs] + Font->CharPos[ofs - 1]) - / 2; + - (Font->CharPos[ofs] + + Font->CharPos[ofs - 1]) / 2; srcrect.h = dstrect.h = Font->Surface->h - 1; - srcrect.x = - (Font->CharPos[ofs] + Font->CharPos[ofs - 1]) / 2; + srcrect.x = (Font->CharPos[ofs] + + Font->CharPos[ofs - 1]) / 2; srcrect.y = 1; - dstrect.x = - x - (float) (Font->CharPos[ofs] - - Font->CharPos[ofs - 1]) / 2; + dstrect.x = x - (float) (Font->CharPos[ofs] + - Font->CharPos[ofs - 1]) / 2; dstrect.y = y; SDL_BlitSurface(Font->Surface, &srcrect, Surface, &dstrect); @@ -160,7 +145,7 @@ int TextWidth2(SFont_FontInfo * Font, char *text) return x; } -void SFont_InternalInput(SDL_Surface * Dest, SFont_FontInfo * Font, int x, +static void SFont_InternalInput(SDL_Surface * Dest, SFont_FontInfo * Font, int x, int y, int PixelWidth, char *text) { SDL_Event event; @@ -208,7 +193,7 @@ void SFont_InternalInput(SDL_Surface * Dest, SFont_FontInfo * Font, int x, blinktimer = SDL_GetTicks() + 500; if (blink) { PutString2(Dest, Font, - x + TextWidth2(Font, text), y, "|"); + x + TextWidth2(Font, text), y, "|"); SDL_UpdateRects(Dest, 1, &rect); } else { SDL_BlitSurface(Back, NULL, Dest, &rect); @@ -226,7 +211,7 @@ void SFont_InternalInput(SDL_Surface * Dest, SFont_FontInfo * Font, int x, } void SFont_Input2(SDL_Surface * Dest, SFont_FontInfo * Font, int x, int y, - int PixelWidth, char *text) + int PixelWidth, char *text) { SFont_InternalInput(Dest, Font, x, y, PixelWidth, text); } diff --git a/aac_afh.c b/aac_afh.c index d60588b4..a3a24bc0 100644 --- a/aac_afh.c +++ b/aac_afh.c @@ -230,7 +230,7 @@ static char *aac_read_chunk(long unsigned current_chunk, ssize_t *len) return (char *)inbuf; } -static const char* aac_suffixes[] = {"m4a", NULL}; +static const char* aac_suffixes[] = {"m4a", "mp4", NULL}; /** the init function of the aac audio format handler */ void aac_afh_init(struct audio_format_handler *p) { diff --git a/audiod.c b/audiod.c index 3b611196..c88facc7 100644 --- a/audiod.c +++ b/audiod.c @@ -400,16 +400,18 @@ static void rn_event_handler(struct task *t) } } -static void open_receiver(int format) +static int open_receiver(int format) { struct audio_format_info *a = &afi[format]; struct slot_info *s; int ret, slot_num; struct receiver_node *rn; + const struct timeval restart_delay = {1, 0}; - slot_num = get_empty_slot(); - if (slot_num < 0) - clean_exit(EXIT_FAILURE, PARA_STRERROR(-slot_num)); + ret = get_empty_slot(); + if (ret < 0) + goto err; + slot_num = ret; s = &slot[slot_num]; s->format = format; s->receiver_node = para_calloc(sizeof(struct receiver_node)); @@ -418,11 +420,9 @@ static void open_receiver(int format) rn->conf = a->receiver_conf; ret = a->receiver->open(s->receiver_node); if (ret < 0) { - PARA_ERROR_LOG("failed to open receiver (%s)\n", - PARA_STRERROR(-ret)); free(s->receiver_node); s->receiver_node = NULL; - return; + goto err; } PARA_NOTICE_LOG("started %s: %s receiver in slot %d\n", audio_formats[s->format], a->receiver->name, slot_num); @@ -432,6 +432,11 @@ static void open_receiver(int format) rn->task.event_handler = rn_event_handler; sprintf(rn->task.status, "%s receiver node", rn->receiver->name); register_task(&rn->task); + return 1; +err: + PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret)); + tv_add(now, &restart_delay, &afi[format].restart_barrier); + return ret; } static int receiver_running(int format) @@ -463,8 +468,7 @@ static int open_current_receiver(struct sched *s) s->timeout = diff; return 0; } - open_receiver(i); - return 1; + return open_receiver(i) < 0? 0 : 1; } static void compute_time_diff(const struct timeval *status_time) @@ -657,7 +661,6 @@ static void audiod_post_select(__a_unused struct sched *s, { int i; - /* save away the current time for other users */ t->ret = 1; FOR_EACH_SLOT(i) try_to_close_slot(i); @@ -952,8 +955,7 @@ static void command_post_select(struct sched *s, struct task *t) struct command_task *ct = t->private_data; t->ret = 1; /* always successful */ - if (audiod_status != AUDIOD_OFF) - audiod_status_dump(); + audiod_status_dump(); if (!FD_ISSET(ct->fd, &s->rfds)) return; ret = handle_connect(ct->fd); diff --git a/audiod.h b/audiod.h index c8d5fc2e..e4faea4e 100644 --- a/audiod.h +++ b/audiod.h @@ -86,6 +86,7 @@ extern const char *status_item_list[NUM_STAT_ITEMS]; void __noreturn clean_exit(int status, const char *msg); int handle_connect(int accept_fd); void audiod_status_dump(void); +void dump_empty_status(void); /** iterate over all slots */ #define FOR_EACH_SLOT(_slot) for (_slot = 0; _slot < MAX_STREAM_SLOTS; _slot++) diff --git a/audiod_command.c b/audiod_command.c index fe26b663..312cfee1 100644 --- a/audiod_command.c +++ b/audiod_command.c @@ -608,33 +608,65 @@ out: void audiod_status_dump(void) { - static char *p_ts, *p_us, *p_as, *p_df; struct timeval *t = wstime(); - char *us, *tmp = get_time_string(t); - - if (tmp && (!p_ts || strcmp(tmp, p_ts))) - stat_client_write(tmp, SI_PLAY_TIME); - free(p_ts); - p_ts = tmp; + char *old, *new, *tmp; + + old = stat_task->stat_item_values[SI_PLAY_TIME]; + new = get_time_string(t); + if (new) { + if (!old || strcmp(old, new)) { + free(old); + stat_client_write(new, SI_PLAY_TIME); + stat_task->stat_item_values[SI_PLAY_TIME] = new; + } else + free(new); + } - us = uptime_str(); - tmp = make_message("%s:%s\n", status_item_list[SI_AUDIOD_UPTIME], us); - free(us); - if (!p_us || strcmp(p_us, tmp)) + new = uptime_str(); + old = stat_task->stat_item_values[SI_AUDIOD_UPTIME]; + if (!old || strcmp(old, new)) { + free(old); + tmp = make_message("%s:%s\n", + status_item_list[SI_AUDIOD_UPTIME], new); stat_client_write(tmp, SI_AUDIOD_UPTIME); - free(p_us); - p_us = tmp; - - tmp = audiod_status_string(); - if (!p_as || strcmp(p_as, tmp)) - stat_client_write(tmp, SI_AUDIOD_STATUS); - free(p_as); - p_as = tmp; - - tmp = decoder_flags(); - if (!p_df || strcmp(p_df, tmp)) - stat_client_write(tmp, SI_DECODER_FLAGS); - free(p_df); - p_df = tmp; + free(tmp); + stat_task->stat_item_values[SI_AUDIOD_UPTIME] = new; + } else + free(new); + + old = stat_task->stat_item_values[SI_AUDIOD_STATUS]; + new = audiod_status_string(); + if (!old || strcmp(old, new)) { + free(old); + stat_client_write(new, SI_AUDIOD_STATUS); + stat_task->stat_item_values[SI_AUDIOD_STATUS] = new; + } else + free(new); + + old = stat_task->stat_item_values[SI_DECODER_FLAGS]; + new = decoder_flags(); + if (!old || strcmp(old, new)) { + stat_client_write(new, SI_DECODER_FLAGS); + stat_task->stat_item_values[SI_DECODER_FLAGS] = new; + } else + free(new); } +/** + * send empty status list + * + * Send to each connected client the full status item list + * with empty values. + */ +void dump_empty_status(void) +{ + int i; + + FOR_EACH_STAT_ITEM(i) { + char *tmp = make_message("%s:\n", status_item_list[i]); + stat_client_write(tmp, i); + free(tmp); + free(stat_task->stat_item_values[i]); + stat_task->stat_item_values[i] = NULL; + } +} diff --git a/client.c b/client.c index 95dacd75..88ea5af2 100644 --- a/client.c +++ b/client.c @@ -42,7 +42,7 @@ void para_log(int ll, const char* fmt,...) va_list argp; /* ignore log message if loglevel is not high enough */ - if (!pcd || ll < pcd->conf.loglevel_arg) + if (pcd && ll < pcd->conf.loglevel_arg) return; va_start(argp, fmt); vfprintf(stderr, fmt, argp); diff --git a/client_common.c b/client_common.c index b77c192f..c738079b 100644 --- a/client_common.c +++ b/client_common.c @@ -278,11 +278,8 @@ void client_post_select(struct sched *s, struct task *t) case CL_SENDING: /* FIXME: might block */ PARA_INFO_LOG("loaded: %zd\n", *pcd->in_loaded); t->ret = send_bin_buffer(pcd->fd, pcd->inbuf, *pcd->in_loaded); - if (t->ret <= 0) { - if (!t->ret) - t->ret = 1; + if (t->ret < 0) return; - } *pcd->in_loaded = 0; /* FIXME: short writes */ return; case CL_RECEIVING: diff --git a/command.c b/command.c index ea42ef43..52d56c9e 100644 --- a/command.c +++ b/command.c @@ -603,7 +603,8 @@ static int com_version(int socket_fd, int argc, __a_unused char **argv) { if (argc != 1) return -E_COMMAND_SYNTAX; - return send_buffer(socket_fd, "para_server-" VERSION ", \"" CODENAME "\"\n" + return send_buffer(socket_fd, "para_server-" PACKAGE_VERSION ", \"" + CODENAME "\"\n" COPYRIGHT "\n" "built: " BUILD_DATE "\n" SYSTEM ", " CC_VERSION "\n" @@ -1100,7 +1101,8 @@ int handle_connect(int fd, struct sockaddr_in *addr) in_addr = addr; challenge_nr = random(); /* send Welcome message */ - ret = send_va_buffer(fd, "This is para_server, version " VERSION ".\n" ); + ret = send_va_buffer(fd, "This is para_server, version " + PACKAGE_VERSION ".\n" ); if (ret < 0) goto err_out; /* recv auth request line */ diff --git a/compress_filter.ggo b/compress_filter.ggo index a889b035..6c9cfeba 100644 --- a/compress_filter.ggo +++ b/compress_filter.ggo @@ -3,5 +3,5 @@ section "The dynamic audio range compressor" option "blocksize" b "larger blocksize means fewer volume adjustments per time unit" int typestr="number" default="16" optional option "aggressiveness" a "controls the maximum amount to amplify by" int typestr="number" default="2" optional option "inertia" i "how much inertia ramping has" int typestr="number" default="6" optional -option "target_level" t "target signal level (0-32768)" int typestr="number" default="25000" optional +option "target_level" t "target signal level (0-32768)" int typestr="number" default="20000" optional option "damp" d "if non-zero, scale down after normalizing" int typestr="number" default="0" optional diff --git a/daemon.c b/daemon.c index d3a43b9a..edaf7f9c 100644 --- a/daemon.c +++ b/daemon.c @@ -101,7 +101,8 @@ void close_log(FILE* logfile) */ void log_welcome(const char *whoami, int loglevel) { - PARA_INFO_LOG("welcome to %s " VERSION " ("BUILD_DATE")\n", whoami); + PARA_INFO_LOG("welcome to %s " PACKAGE_VERSION " ("BUILD_DATE")\n", + whoami); PARA_DEBUG_LOG("using loglevel %d\n", loglevel); } diff --git a/dbadm.c b/dbadm.c index 40ecf0b8..4772c969 100644 --- a/dbadm.c +++ b/dbadm.c @@ -150,6 +150,8 @@ static int commit_changes(char *filename) // ITEM **items; int i; char buf[MAXLINE] = "para_client sa "; + int fds[3] = {0, 0, 0}; + pid_t pid; for (i = 0; i < n_choices; ++i) { strcat(buf, item_name(my_items[i])); @@ -162,7 +164,7 @@ static int commit_changes(char *filename) strcat(buf, filename); //printf("old atts: %s\n", atts); //printf("%s\n", buf); - return system(buf); + return para_exec_cmdline_pid(&pid, buf, fds); } static char *get_current_filename(void) @@ -330,11 +332,8 @@ repeat: goto repeat; /* Enter */ case 10: - endwin(); if (atts_modified) commit_changes(filename); - else - printf("Attributes unchanged\n"); goto out; default: goto repeat; @@ -342,7 +341,7 @@ repeat: out: if (my_items) { free_item(my_items[0]); - free_item(my_items[1]); + free_item(my_items[1]); } for (i = 0; i < n_choices; i++) free(choices[i]); diff --git a/dccp_send.c b/dccp_send.c index aba21a6d..3592a282 100644 --- a/dccp_send.c +++ b/dccp_send.c @@ -120,15 +120,22 @@ static void dccp_shutdown_client(struct dccp_client *dc) free(dc); } +#define DCCP_RETRIES 100 + static int dccp_write(int fd, const char *buf, size_t len) { size_t size, written = 0; - int ret; + int ret, retries = 0; again: size = PARA_MIN(1024, len - written); ret = write(fd, buf + written, size); - if (ret < 0) - goto err_out; + if (ret < 0) { + if (errno != EAGAIN || !retries++ > DCCP_RETRIES) + goto err_out; + PARA_DEBUG_LOG("EAGAIN #%d@%d/%d\n", retries, written, len); + goto again; + } + retries = 0; written += ret; if (written >= len) return written; diff --git a/fd.c b/fd.c index 36b3769d..dd07466c 100644 --- a/fd.c +++ b/fd.c @@ -47,8 +47,8 @@ int file_exists(const char *fn) * \param n the highest-numbered descriptor in any of the two sets, plus 1 * \param readfds fds that should be checked for readability * \param writefds fds that should be checked for writablility - * \param timeout upper bound on the amount of time elapsed before select() - * returns + * \param timeout_tv upper bound on the amount of time elapsed before select() + * returns * * \return The return value of the underlying select() call. * diff --git a/grab_client.c b/grab_client.c index efe9cf61..70b95f4f 100644 --- a/grab_client.c +++ b/grab_client.c @@ -170,7 +170,7 @@ void activate_grab_client(struct grab_client *gc, struct filter_node *fn) /** * activate inactive grab clients if possible * - * \param slot audiod's slot for the new audio file + * \param slot_num audiod's slot for the new audio file * \param audio_format_num the number of the audio format of the new audio file * \param filter_list the list of activated filters for that new audio file * diff --git a/gui.c b/gui.c index ffd1ea84..c0588197 100644 --- a/gui.c +++ b/gui.c @@ -31,7 +31,7 @@ INIT_GUI_ERRLISTS; extern const char *status_item_list[NUM_STAT_ITEMS]; static char *stat_content[NUM_STAT_ITEMS]; -#define STANDARD_STATUS_BAR "para_gui " VERSION " (hit ? for help)" +#define STANDARD_STATUS_BAR "para_gui " PACKAGE_VERSION " (hit ? for help)" static int signal_pipe; @@ -339,7 +339,7 @@ static void print_status_bar(void) if (!curses_active) return; wmove(sb.win, 0, 0); - align_str(sb.win,STANDARD_STATUS_BAR, sb.cols, CENTER); + align_str(sb.win, STANDARD_STATUS_BAR, sb.cols, CENTER); wrefresh(sb.win); } @@ -540,7 +540,7 @@ static void print_welcome(void) int ll = conf.loglevel_arg; if (ll > NOTICE) return; - outputf(COLOR_WELCOME, "Welcome to para_gui " VERSION + outputf(COLOR_WELCOME, "Welcome to para_gui " PACKAGE_VERSION " \"" CODENAME "\". Theme: %s", theme.name); wclrtoeol(bot.win); } @@ -1224,7 +1224,8 @@ static void com_enlarge_top_win(void) static void com_version(void) { - print_in_bar(COLOR_MSG, "para_gui " VERSION " \"" CODENAME "\""); + print_in_bar(COLOR_MSG, "para_gui " PACKAGE_VERSION " \"" + CODENAME "\""); } static void com_quit(void) diff --git a/gui.ggo b/gui.ggo index 34cbdb19..9701c39e 100644 --- a/gui.ggo +++ b/gui.ggo @@ -3,7 +3,7 @@ option "auto_decode" a "auto-decode audio stream" flag on option "config_file" c "(default='~/.paraslash/gui.conf')" string typestr="filename" optional option "loglevel" l "set loglevel (0-6)" int typestr="level" default="4" optional option "timeout" t "set timeout" int typestr="milliseconds" default="30" optional -option "stat_cmd" s "command to read server and audiod status data from" string typestr="command" default="para_audioc -t 100 stat" optional +option "stat_cmd" s "command to read server and audiod status data from" string typestr="command" default="para_audioc stat" optional section "mapping keys to commands" option "key_map" k "Map key k to command c using mode m. Mode may be d, x or p for display, external and paraslash commands, respectively. Of course, this option may be given multiple times, one for each key mapping." string typestr="k:m:c" optional multiple diff --git a/http_recv.c b/http_recv.c index 6a2f60f1..386aacbc 100644 --- a/http_recv.c +++ b/http_recv.c @@ -87,7 +87,7 @@ static char *make_request_msg(void) { char *ret, *hn = para_hostname(); ret = make_message("%s1.0\nHost: %s\nUser-Agent: para_recv/%s\n\n\n", - HTTP_GET_MSG, hn, VERSION); + HTTP_GET_MSG, hn, PACKAGE_VERSION); free(hn); return ret; } diff --git a/mysql_selector.c b/mysql_selector.c index 054c797e..45a10bac 100644 --- a/mysql_selector.c +++ b/mysql_selector.c @@ -1158,12 +1158,17 @@ static char *get_query(char *streamname, char *filename, int with_path) char *select_clause = NULL; if (!streamname) tmp = get_current_stream(); - else + else { tmp = escape_str(streamname); + if (!tmp) + return NULL; + } if (!strcmp(tmp, "(none)")) { free(tmp); if (filename) { char *ret, *ebn = escaped_basename(filename); + if (!ebn) + return NULL; ret = make_message("select to_days(now()) - " "to_days(lastplayed) from data " "where name = '%s'", ebn); @@ -2095,14 +2100,21 @@ static int com_sl(int fd, int argc, char *argv[]) num = atoi(argv[1]); if (!num) return -E_MYSQL_SYNTAX; - stream = (argc == 2)? get_current_stream() : escape_str(argv[2]); + if (argc == 2) { + stream = get_current_stream(); + if (!stream) + return -E_GET_STREAM; + } else { + stream = escape_str(argv[2]); + if (!stream) + return -E_ESCAPE; + } tmp = get_query(stream, NULL, 0); + free(stream); + if (!tmp) + return -E_GET_QUERY; query = make_message("%s limit %d", tmp, num); free(tmp); - ret = -E_GET_QUERY; - free(stream); - if (!query) - goto out; ret = -E_NORESULT; result = get_result(query); free(query); @@ -2388,6 +2400,8 @@ static int com_upd(int fd, int argc, __a_unused char *argv[]) goto out; send_va_buffer(fd, "new entry: %s\n", row[0]); erow = escape_str(row[0]); + if (!erow) + goto out; query = make_message("insert into data (name, pic_id) values " "('%s','%s')", erow, "1"); free(erow); @@ -2419,6 +2433,8 @@ static char **server_get_audio_file_list(unsigned int num) tmp = get_query(stream, NULL, 1); free(stream); + if (!tmp) + goto err_out; query = make_message("%s limit %d", tmp, num); free(tmp); result = get_result(query); @@ -2509,8 +2525,12 @@ static int com_cdb(int fd, int argc, char *argv[]) goto out; if (argc < 2) conf.mysql_database_arg = para_strdup("paraslash"); - else + else { + ret = -E_ESCAPE; conf.mysql_database_arg = escape_str(argv[1]); + if (!conf.mysql_database_arg) + goto out; + } query = make_message("create database %s", conf.mysql_database_arg); ret = real_query(query); free(query); diff --git a/ortp_recv.c b/ortp_recv.c index 1f2f78b7..287d7064 100644 --- a/ortp_recv.c +++ b/ortp_recv.c @@ -282,6 +282,7 @@ static int ortp_recv_open(struct receiver_node *rn) pord->session = rtp_session_new(RTP_SESSION_RECVONLY); PARA_NOTICE_LOG("receiving from %s:%d\n", c->host_arg, c->port_arg); rtp_session_set_local_addr(pord->session, c->host_arg, c->port_arg); + rtp_session_set_remote_addr(pord->session, c->host_arg, c->port_arg); rtp_session_set_payload_type(pord->session, PAYLOAD_AUDIO_CONTINUOUS); if (c->jitter_compensation_arg) { rtp_session_enable_adaptive_jitter_compensation(pord->session, TRUE); diff --git a/ortp_send.c b/ortp_send.c index dd4ee884..b084bb68 100644 --- a/ortp_send.c +++ b/ortp_send.c @@ -87,6 +87,20 @@ static void ortp_send_buf(char *buf, int len, long unsigned chunks_sent) } } +static int set_multicast(RtpSession *s) +{ + unsigned char loop = 1; + int ret; + + ret = setsockopt(s->rtp.socket, + IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof(loop)); + if (ret < 0) { + PARA_ERROR_LOG("IP_MULTICAST_LOOP error %d\n", ret); + + } + return 1; +} + static void ortp_init_session(struct ortp_target *ot) { RtpSession *s; @@ -108,7 +122,9 @@ static void ortp_init_session(struct ortp_target *ot) if (ret < 0) { rtp_session_destroy(ot->session); ot->session = NULL; + return; } + set_multicast(s); } /* called by afs */ diff --git a/para.h b/para.h index 26e04c6c..b5a8f7bb 100644 --- a/para.h +++ b/para.h @@ -155,8 +155,8 @@ int stat_item_valid(const char *item); int stat_line_valid(const char *); void stat_client_write(char *msg, int itemnum); int stat_client_add(int fd, long unsigned mask); -void dump_empty_status(void); unsigned for_each_line(char *, int, void (*)(char *)); +#define FOR_EACH_STAT_ITEM(i) for (i = 0; i < NUM_STAT_ITEMS; i++) struct stat_item_data { const char *prefix, *postfix; diff --git a/recv.c b/recv.c index bfc7a45d..3b1c6917 100644 --- a/recv.c +++ b/recv.c @@ -60,7 +60,9 @@ static void *parse_config(int argc, char *argv[], int *receiver_num) void rn_event_handler(struct task *t) { + struct receiver_node *rn = t->private_data; PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-t->ret)); + rn->eof = 1; unregister_task(t); } diff --git a/sdl_gui.c b/sdl_gui.c index b67b3d1e..97d0573a 100644 --- a/sdl_gui.c +++ b/sdl_gui.c @@ -356,7 +356,7 @@ static void init_SDL(void) SDL_EventState(SDL_MOUSEBUTTONUP, SDL_IGNORE); /* Set the window manager title bar */ SDL_WM_SetCaption("The Gui of death that makes you blind (paraslash " - VERSION ")", "SFont"); + PACKAGE_VERSION ")", "SFont"); } /* @@ -739,7 +739,7 @@ static int configfile_exists(void) */ int main(int argc, char *argv[]) { - int i, ret, fd; + int i, ret, fd = -1; SDLKey sym; sdl_gui_cmdline_parser(argc, argv, &args_info); @@ -759,7 +759,6 @@ int main(int argc, char *argv[]) height = args_info.height_arg; // printf("w=%i,h=%i,ret=%i, cf=%s\n", width, height, ret, args_info.config_file_arg); init_stat_items(); - fd = para_open_audiod_pipe(args_info.stat_cmd_arg); init_SDL(); for (i = 0; fonts[i].name[0]; i++) { char buf[MAXLINE]; @@ -775,6 +774,11 @@ int main(int argc, char *argv[]) update_input(); } for (;;) { + if (fd < 0) { + fd = para_open_audiod_pipe(args_info.stat_cmd_arg); + if (fd < 0) + clean_exit(EXIT_FAILURE); + } ret = draw_status(fd); if (ret < 0) { close(fd); @@ -802,10 +806,6 @@ int main(int argc, char *argv[]) || sym == SDLK_COMPOSE ) continue; - if (fd < 0) { - kill(0, SIGINT); - close(fd); - } fill_input_rect(); update_input(); if (!command_handler()) @@ -814,7 +814,6 @@ int main(int argc, char *argv[]) print_help(); update_pic(); SDL_UpdateRect(screen, 0, 0, 0, 0); - fd = para_open_audiod_pipe(args_info.stat_cmd_arg); break; } } diff --git a/sdl_gui.ggo b/sdl_gui.ggo index 3d04f8a2..8ea49287 100644 --- a/sdl_gui.ggo +++ b/sdl_gui.ggo @@ -4,5 +4,5 @@ option "width" x "Specify screen width" int typestr="pixels" default="1024" opti option "height" y "Specify screen height" int typestr="pixels" default="768" optional option "config_file" c "(default='~/.paraslash/sdl_gui.conf')" string typestr="filename" optional option "window-id" w "(currently ignored)" string typestr="filename" optional -option "stat_cmd" s "command to read server and audiod status data from" string typestr="command" default="para_audioc -t 100 stat" optional +option "stat_cmd" s "command to read server and audiod status data from" string typestr="command" default="para_audioc stat" optional option "pic_cmd" p "command to read pic from" string typestr="command" default="para_client pic" optional diff --git a/send.h b/send.h index bf1ca111..76a35123 100644 --- a/send.h +++ b/send.h @@ -101,6 +101,8 @@ static inline int write_ok(int fd) again: FD_ZERO(&wfds); FD_SET(fd, &wfds); + tv.tv_sec = 0; + tv.tv_usec = 0; ret = select(fd + 1, NULL, &wfds, NULL, &tv); if (ret < 0 && errno == EINTR) goto again; diff --git a/stat.c b/stat.c index 33fdb8c1..8220fd27 100644 --- a/stat.c +++ b/stat.c @@ -90,7 +90,6 @@ const char *status_item_list[NUM_STAT_ITEMS] = { [SI_AUDIOD_UPTIME] = "audiod_uptime", [SI_SELECTOR] = "dbtool" }; -#define FOR_EACH_STAT_ITEM(i) for (i = 0; i < NUM_STAT_ITEMS; i++) static void dump_stat_client_list(void) { @@ -174,24 +173,6 @@ void stat_client_write(char *msg, int itemnum) PARA_DEBUG_LOG("%d client(s)\n", num_clients); } -/** - * send empty status list - * - * Send to each connected client the full status item list - * with empty values. - */ -void dump_empty_status(void) -{ - int i; - - if (!initialized) - return; - FOR_EACH_STAT_ITEM(i) { - char *tmp = make_message("%s:\n", status_item_list[i]); - stat_client_write(tmp, i); - free(tmp); - } -} /** * check if string is a known status item. diff --git a/stdout.c b/stdout.c index 2e86fe96..1656bcc9 100644 --- a/stdout.c +++ b/stdout.c @@ -82,6 +82,8 @@ void stdout_post_select(struct sched *s, struct task *t) if (ret <= 0) return; *sot->loaded -= ret; + if (*sot->loaded) + memmove(sot->buf, sot->buf + ret, *sot->loaded); t->ret = 1; } diff --git a/time.c b/time.c index d6e07080..49b941bb 100644 --- a/time.c +++ b/time.c @@ -106,7 +106,7 @@ void tv_scale(const unsigned long mult, const struct timeval *tv, /** * compute fraction of given struct timeval * - * \param divider the integer value to divide by + * \param divisor the integer value to divide by * \param tv the timevalue to divide * \param result holds (1 / mult) * tv upon return */