head 1.10; access; symbols pkgsrc-2013Q2:1.10.0.54 pkgsrc-2013Q2-base:1.10 pkgsrc-2012Q4:1.10.0.52 pkgsrc-2012Q4-base:1.10 pkgsrc-2011Q4:1.10.0.50 pkgsrc-2011Q4-base:1.10 pkgsrc-2011Q2:1.10.0.48 pkgsrc-2011Q2-base:1.10 pkgsrc-2009Q4:1.10.0.46 pkgsrc-2009Q4-base:1.10 pkgsrc-2008Q4:1.10.0.44 pkgsrc-2008Q4-base:1.10 pkgsrc-2008Q3:1.10.0.42 pkgsrc-2008Q3-base:1.10 cube-native-xorg:1.10.0.40 cube-native-xorg-base:1.10 pkgsrc-2008Q2:1.10.0.38 pkgsrc-2008Q2-base:1.10 pkgsrc-2008Q1:1.10.0.36 pkgsrc-2008Q1-base:1.10 pkgsrc-2007Q4:1.10.0.34 pkgsrc-2007Q4-base:1.10 pkgsrc-2007Q3:1.10.0.32 pkgsrc-2007Q3-base:1.10 pkgsrc-2007Q2:1.10.0.30 pkgsrc-2007Q2-base:1.10 pkgsrc-2007Q1:1.10.0.28 pkgsrc-2007Q1-base:1.10 pkgsrc-2006Q4:1.10.0.26 pkgsrc-2006Q4-base:1.10 pkgsrc-2006Q3:1.10.0.24 pkgsrc-2006Q3-base:1.10 pkgsrc-2006Q2:1.10.0.22 pkgsrc-2006Q2-base:1.10 pkgsrc-2006Q1:1.10.0.20 pkgsrc-2006Q1-base:1.10 pkgsrc-2005Q4:1.10.0.18 pkgsrc-2005Q4-base:1.10 pkgsrc-2005Q3:1.10.0.16 pkgsrc-2005Q3-base:1.10 pkgsrc-2005Q2:1.10.0.14 pkgsrc-2005Q2-base:1.10 pkgsrc-2005Q1:1.10.0.12 pkgsrc-2005Q1-base:1.10 pkgsrc-2004Q4:1.10.0.10 pkgsrc-2004Q4-base:1.10 pkgsrc-2004Q3:1.10.0.8 pkgsrc-2004Q3-base:1.10 pkgsrc-2004Q2:1.10.0.6 pkgsrc-2004Q2-base:1.10 pkgsrc-2004Q1:1.10.0.4 pkgsrc-2004Q1-base:1.10 pkgsrc-2003Q4:1.10.0.2 pkgsrc-2003Q4-base:1.10 buildlink2-base:1.10 netbsd-1-5-PATCH003:1.9 netbsd-1-5-PATCH001:1.3; locks; strict; comment @# @; 1.10 date 2002.05.05.13.13.17; author wiz; state dead; branches; next 1.9; 1.9 date 2002.03.25.06.25.01; author lukem; state Exp; branches; next 1.8; 1.8 date 2002.03.25.05.44.48; author lukem; state Exp; branches; next 1.7; 1.7 date 2002.02.04.17.07.02; author rxg; state dead; branches; next 1.6; 1.6 date 2002.01.16.07.59.54; author lukem; state Exp; branches; next 1.5; 1.5 date 2001.11.27.04.12.51; author lukem; state dead; branches; next 1.4; 1.4 date 2001.08.24.08.27.43; author lukem; state Exp; branches; next 1.3; 1.3 date 2001.03.25.16.21.52; author hubertf; state Exp; branches; next 1.2; 1.2 date 99.07.12.00.53.56; author hubertf; state dead; branches; next 1.1; 1.1 date 99.06.13.23.14.08; author hubertf; state Exp; branches; next ; desc @@ 1.10 log @Update to 0.16.0: Added configuration of radio device. Added 'save playlist' to main pop up menu. Added open_file, open_playlist, open_custom, and save_playlist to the skin spec. Many fixes to the ogg123 support (patch-ac). gtk specific command line options now work. Fixed a possible buffer over run in cpu percent usage polling (linux). SLIK 0.10.0: Added divider between dirs and files in path selection dialogs. Fixed a file descriptor leak in skin loader. Fixed writing of blank focus file name (should not be written at all) in the editor. Fixed unhiding of a widget to update it's state first. Fixed clist in place editing scroll bug. Fix and guard against a few cases that may cause a crash at startup. @ text @$NetBSD: patch-ac,v 1.9 2002/03/25 06:25:01 lukem Exp $ --- src/io_ogg123.c.orig Sat Feb 23 04:39:13 2002 +++ src/io_ogg123.c Mon Mar 25 17:16:37 2002 @@@@ -47,6 +47,62 @@@@ static gint ogg123_child_pid = -1; static int ogg123_pipe[2]; /* + *----------------------------------------------------------------------------- + * pipe functions + *----------------------------------------------------------------------------- + */ + +static gint ogg123_pipe_open(char *ogg_argv[], gint *ogg_child, + int ogg_pipe[2]) +{ + pid_t frk_pid; + + /* Create the pipe. */ + if (pipe(ogg_pipe)) + { + fprintf (stderr, _("Pipe failed.\n")); + return FALSE; + } + + if (debug_mode) printf("ogg123_pipe_open: %s\n", ogg_argv[0]); + + /* Create the child process. */ + frk_pid = fork (); + if (frk_pid == (pid_t) 0) + { + /* This is the child process. */ + dup2(ogg_pipe[1], 1); + dup2(ogg_pipe[1], 2); + close(ogg_pipe[0]); + + execvp(ogg_argv[0], ogg_argv); + printf(_("unable to run %s (in the path?)\n"), ogg_argv); + _exit(1); + } + else if (frk_pid < (pid_t) 0) + { + /* The fork failed. */ + fprintf (stderr, _("Fork failed.\n")); + close(ogg_pipe[0]); + close(ogg_pipe[1]); + *ogg_child = -1; + return FALSE; + } + else + { + /* This is the parent process. */ + *ogg_child = (int) frk_pid; + + close(ogg_pipe[1]); + ogg_pipe[1] = -1; + } + + if (debug_mode) printf("ogg123_pipe_open pid = %d\n", *ogg_child); + + return TRUE; +} + +/* *---------------------------------------------------------------------------- * title/description utils *---------------------------------------------------------------------------- @@@@ -100,21 +156,22 @@@@ OGGInfo *ogg123_info_get(const gchar *pa { OGGInfo *info = NULL; FILE *f; - gchar *command; + char *command[3]; + gint child_pid; + int child_pipe[2]; char buf[128]; if (!ogg123_info_found) return NULL; + command[0] = OGG123_BINARY_INFO; + command[1] = (char *)path; + command[2] = NULL; - command = g_strdup_printf("%s \"%s\"", OGG123_BINARY_INFO, path); - f = popen(command, "r"); - if (!f) + if (ogg123_pipe_open(command, &child_pid, child_pipe) == FALSE + || (f = fdopen(child_pipe[0], "r")) == NULL) { - printf("Failed to run \"%s\n\"", command); - g_free(command); + printf("Failed to run \"%s\n\"", command[0]); return NULL; } - g_free(command); - info = g_new0(OGGInfo, 1); while (fgets(buf, sizeof(buf), f) != NULL) @@@@ -163,7 +220,7 @@@@ OGGInfo *ogg123_info_get(const gchar *pa } } - pclose(f); + close(child_pipe[0]); info->bytes = filesize(path); @@@@ -178,20 +235,23 @@@@ GList *ogg123_comment_get(const gchar *p { GList *list = NULL; FILE *f; - gchar *command; + char *command[4]; + gint child_pid; + int child_pipe[2]; char buf[128]; if (!ogg123_comment_found) return NULL; + command[0] = OGG123_BINARY_COMMENT; + command[1] = "-l"; + command[2] = (char *)path; + command[3] = NULL; - command = g_strdup_printf("%s -l \"%s\"", OGG123_BINARY_COMMENT, path); - f = popen(command, "r"); - if (!f) + if (ogg123_pipe_open(command, &child_pid, child_pipe) == FALSE + || (f = fdopen(child_pipe[0], "r")) == NULL) { - printf("Failed to run \"%s\n\"", command); - g_free(command); + printf("Failed to run \"%s\n\"", command[0]); return NULL; } - g_free(command); while (fgets(buf, sizeof(buf), f) != NULL) { @@@@ -214,7 +274,7 @@@@ GList *ogg123_comment_get(const gchar *p g_free(key); } - pclose(f); + close(child_pipe[0]); return g_list_reverse(list); } @@@@ -250,16 +310,36 @@@@ const gchar *ogg123_comment_value(GList gint ogg123_comment_set(const gchar *path, GList *comments) { FILE *f; - gchar *command; GList *errlist; GList *work; char buf[128]; - gchar *tmp; + int argc, i; + char **argv; + gint child_pid; + int child_pipe[2]; if (!ogg123_comment_found) return TRUE; if (!path) return FALSE; - command = g_strdup_printf("%s -w \"%s\"", OGG123_BINARY_COMMENT, path); + argc = 4; + work = comments; + while (work && work->next) { + if (work->data) + argc += 2; + work = work->next; + work = work->next; + } + if ((argv = g_malloc(argc * sizeof(argv[0]))) == NULL) + { + printf("Failed to allocate memory to run %s\n", + OGG123_BINARY_COMMENT); + return FALSE; + } + + argc = 0; + argv[argc++] = OGG123_BINARY_COMMENT; + argv[argc++] = "-w"; + argv[argc++] = (char *)path; work = comments; while (work && work->next) @@@@ -272,26 +352,21 @@@@ gint ogg123_comment_set(const gchar *pat if (key && strlen(key) > 0 && value && strlen(value) > 0) { - tmp = g_strdup_printf("%s -t \"%s=%s\"", command, key, value); - g_free(command); - command = tmp; + argv[argc++] = "-t"; + argv[argc++] = g_strdup_printf("%s=%s", key, value); } work = work->next; work = work->next; } - tmp = g_strdup_printf("%s 2>&1", command); - g_free(command); - command = tmp; + argv[argc++] = NULL; - f = popen(command, "r"); - if (!f) + if (ogg123_pipe_open(argv, &child_pid, child_pipe) == FALSE + || (f = fdopen(child_pipe[0], "r")) == NULL) { - printf("Failed to run \"%s\"\n", command); - g_free(command); + printf("Failed to run \"%s\"\n", argv[0]); return FALSE; } - g_free(command); errlist = NULL; while (fgets(buf, sizeof(buf), f) != NULL) @@@@ -302,7 +377,10 @@@@ gint ogg123_comment_set(const gchar *pat } } - pclose(f); + close(child_pipe[0]); + for (i = 4; i < argc; i += 2) + g_free(argv[i]); + g_free(argv); if (errlist) { @@@@ -472,30 +550,24 @@@@ static gint parse_time(const gchar *text return (m * 60 + s); } -static void parse_bitrate(const gchar *text) +static gint parse_bitrate(const gchar *text) { static time_t old_t = 0; time_t new_t; - const gchar *ptr; gint force = FALSE; + int new_rate; - ptr = strstr(text, "Bitrate: "); - if (ptr) + if (sscanf(text, "(%d.%*d kbps)", &new_rate) != 1) + return FALSE; + if (input_bitrate != 0) { - gint new_rate; - - ptr += 9; - new_rate = (gint)strtol(ptr, NULL, 10); - if (input_bitrate != 0) - { - /* show a trend, ugly but it makes the rate change more smoothly */ - input_bitrate = ((input_bitrate * 4) + new_rate) / 5; - } - else - { - input_bitrate = new_rate; - force = TRUE; - } + /* show a trend, ugly but it makes the rate change more smoothly */ + input_bitrate = ((input_bitrate * 4) + (gint)new_rate) / 5; + } + else + { + input_bitrate = (gint)new_rate; + force = TRUE; } /* we only update once per second */ @@@@ -505,12 +577,14 @@@@ static void parse_bitrate(const gchar *t module_playback_data_changed(); old_t = new_t; } + return TRUE; } static gint ogg123_input_parse(const gchar *buffer) { if (debug_mode > 1) printf("ogg123 output:\"%s\"\n", buffer); +/* Time: 00:03.92 [04:48.17] of 04:52.09 (140.9 kbps) Output Buffer 75.0% */ if (strncmp(buffer, "Time: ", 6) == 0) { const gchar *ptr; @@@@ -527,7 +601,9 @@@@ static gint ogg123_input_parse(const gch if (strlen(ptr) < 8) return FALSE; seconds_remaining = parse_time(ptr); frames_remaining = seconds_remaining; - parse_bitrate(ptr); + ptr = strchr(ptr, '('); + if (!ptr) return FALSE; + if (parse_bitrate(ptr) == FALSE) return FALSE; } else if (strncmp(buffer, "Bitstream is", 12) == 0) { @@@@ -648,7 +724,6 @@@@ static void ogg123_input_read_reset(void static gint ogg123_child_run(SongData *sd, gint position) { - pid_t frk_pid; char cmd_arguments[OGG123_MAX_COMMANDS][512]; char *cmd_ptr[OGG123_MAX_COMMANDS]; int cmd_cnt = 0; @@@@ -720,48 +795,11 @@@@ static gint ogg123_child_run(SongData *s cmd_ptr[cmd_cnt] = NULL; cmd_cnt++; - /* Create the pipe. */ - if (pipe(ogg123_pipe)) - { - fprintf (stderr, _("Pipe failed.\n")); - return FALSE; - } - - if (debug_mode) printf("opening: %s\n", sd->path); - - /* Create the child process. */ - frk_pid = fork (); - if (frk_pid == (pid_t) 0) - { - /* This is the child process. */ - dup2(ogg123_pipe[1], 2); - close(ogg123_pipe[0]); - - execvp(exec_bin, cmd_ptr); - printf(_("unable to run %s (in the path?)\n"), exec_bin); - _exit(1); - } - else if (frk_pid < (pid_t) 0) - { - /* The fork failed. */ - fprintf (stderr, _("Fork failed.\n")); - close(ogg123_pipe[0]); - close(ogg123_pipe[1]); - pid = 0; - ogg123_child_pid = -1; + pid = 0; + if (ogg123_pipe_open(cmd_ptr, &ogg123_child_pid, ogg123_pipe) == FALSE) return FALSE; - } - else - { - /* This is the parent process. */ - ogg123_child_pid = (int) frk_pid; - pid = ogg123_child_pid; - close(ogg123_pipe[1]); - ogg123_pipe[1] = -1; - } - - if (debug_mode) printf("ogg123 pid = %d\n", ogg123_child_pid); + pid = ogg123_child_pid; ogg123_input_read_reset(); ogg123_control_read_id = gdk_input_add (ogg123_pipe[0], GDK_INPUT_READ, ogg123_input_read_cb, NULL); @@@@ -769,6 +807,7 @@@@ static gint ogg123_child_run(SongData *s return TRUE; } + /* *---------------------------------------------------------------------------- * module callback funcs @@@@ -793,7 +832,7 @@@@ static gint ogg123_data_set(SongData *sd if (info) { sd->length = info->length; - sd->bit_rate = info->bitrate_nominal; + sd->bit_rate = info->bitrate_average / 1000; sd->channels = info->channels; sd->bit_depth = 16; /* these two correct ? */ sd->khz_rate = 44; @ 1.9 log @fix minor memory leak in ogg123_comment_set() introduced in previous @ text @d1 1 a1 1 $NetBSD: patch-ac,v 1.8 2002/03/25 05:44:48 lukem Exp $ @ 1.8 log @Add back patch-ac containing various ogg123 playback fixes (different from the last set), making ogg playback useful: - implement ogg123_pipe_open() which opens a pipe and runs the command supplied in the char **, returning the child pid and fd array from pipe(2). based on code from ogg123_child_run(). - replace popen() with ogg123_pipe_open() in ogg123_info_get(), ogg123_comment_get(), and ogg123_comment_set(). now info actually works for file names which contain wacky shell characters (where surrounding the file name with quotes just Isn't Enough) - parse_bitrate(): current bitrate in ogg123 output is now "(NNN.MM kbps)", so look for that rather than "Bitrate: NNNN" - when setting the initial bit_rate for a song, use "bitrate_average / 1000" rather than "bitrate_nominal", since bit_rate is in kbps and bitrate_* is in bps and bitrate_average is more appropriate that bitrate_nominal. @ text @d1 1 a1 1 $NetBSD$ d4 1 a4 1 +++ src/io_ogg123.c Mon Mar 25 16:32:41 2002 d157 1 a157 1 + int argc; d221 1 a221 1 @@@@ -302,7 +377,8 @@@@ gint ogg123_comment_set(const gchar *pat d227 2 d233 1 a233 1 @@@@ -472,30 +548,24 @@@@ static gint parse_time(const gchar *text d276 1 a276 1 @@@@ -505,12 +575,14 @@@@ static void parse_bitrate(const gchar *t d291 1 a291 1 @@@@ -527,7 +599,9 @@@@ static gint ogg123_input_parse(const gch d302 1 a302 1 @@@@ -648,7 +722,6 @@@@ static void ogg123_input_read_reset(void d310 1 a310 1 @@@@ -720,48 +793,11 @@@@ static gint ogg123_child_run(SongData *s d362 1 a362 1 @@@@ -769,6 +805,7 @@@@ static gint ogg123_child_run(SongData *s d370 1 a370 1 @@@@ -793,7 +830,7 @@@@ static gint ogg123_data_set(SongData *sd @ 1.7 log @ Changes: - Added --geometry command line option. - Updated French translation. - Playlist now scrolls with drag and drop. - Adding directory contents to a playlist now sorts the contents first. * Fixed ogg filenames with spaces. * Made the M3U file reading actually work. * Minor other fixes. Close pkg/15435 @ text @d1 1 a1 1 $NetBSD: patch-ac,v 1.6 2002/01/16 07:59:54 lukem Exp $ d3 74 a76 3 --- src/io_ogg123.c.orig Thu Jan 3 19:46:03 2002 +++ src/io_ogg123.c @@@@ -105,7 +105,7 @@@@ d79 3 d83 5 a87 4 - command = g_strdup_printf("%s %s", OGG123_BINARY_INFO, path); + command = g_strdup_printf("%s '%s'", OGG123_BINARY_INFO, path); f = popen(command, "r"); if (!f) d89 28 a116 1 @@@@ -183,7 +183,7 @@@@ d119 17 d137 1 a137 4 - command = g_strdup_printf("%s -l %s", OGG123_BINARY_COMMENT, path); + command = g_strdup_printf("%s -l '%s'", OGG123_BINARY_COMMENT, path); f = popen(command, "r"); if (!f) d139 23 a161 1 @@@@ -259,7 +259,7 @@@@ d165 20 a184 2 - command = g_strdup_printf("%s -w %s", OGG123_BINARY_COMMENT, path); + command = g_strdup_printf("%s -w '%s'", OGG123_BINARY_COMMENT, path); d188 189 @ 1.6 log @Wrap path name arguments to popen in single quotes, to fix getting info from filenames containing spaces, etc. (It's still borken for filenames with single quotes). XXX: Arguably, io_ogg123.c should be converted to not use popen(3) and use a pipe mechanism similar to io_mpg123.c, but that's more effort than I'm interested in doing right now. @ text @d1 1 a1 1 $NetBSD$ @ 1.5 log @remove patches obsoleted by rev 0.10.0 (hi hubert! :) @ text @d1 1 a1 1 $NetBSD: patch-ac,v 1.4 2001/08/24 08:27:43 lukem Exp $ d3 23 a25 67 --- src/io_ogg123.c.orig Fri Feb 16 13:53:18 2001 +++ src/io_ogg123.c Fri Aug 24 17:28:58 2001 @@@@ -35,6 +35,7 @@@@ gint ogg123_enabled = FALSE; gint ogg123_device = 0; gchar *ogg123_device_options = NULL; +gchar *ogg123_extra_options = NULL; /* internal stuff */ static SongData *ogg123_current_sd = NULL; @@@@ -52,10 +53,15 @@@@ static int ogg123_pipe[2]; static const gchar *ogg123_output_devices[] = { +#ifdef __NetBSD__ + "sun", +#endif "oss", "esd", "irix", +#ifndef __NetBSD__ "solaris", +#endif "wav", NULL }; @@@@ -332,11 +338,13 @@@@ static void ogg123_input_read_cb(gpointe *----------------------------------------------------------------------------- */ +#define OGG123_MAX_COMMANDS 32 + static gint ogg123_child_run(SongData *sd, gint position) { pid_t frk_pid; - char cmd_arguments[16][512]; - char *cmd_ptr[16]; + char cmd_arguments[OGG123_MAX_COMMANDS][512]; + char *cmd_ptr[OGG123_MAX_COMMANDS]; int cmd_cnt = 0; gchar *exec_bin = OGG123_BINARY; @@@@ -370,6 +378,26 @@@@ static gint ogg123_child_run(SongData *s sprintf(cmd_arguments[cmd_cnt], "--device-option=%s", ogg123_device_options); cmd_ptr[cmd_cnt] = cmd_arguments[cmd_cnt]; cmd_cnt++; + } + + if (ogg123_extra_options && + strlen(ogg123_extra_options) > 0 && + cmd_cnt + 2 < OGG123_MAX_COMMANDS) + { + gchar **vector; + gint i; + + vector = g_strsplit(ogg123_extra_options, " ", OGG123_MAX_COMMANDS - 2 - cmd_cnt); + i = 0; + + while(vector && vector[i] != NULL) + { + strcpy(cmd_arguments[cmd_cnt], vector[i]); + cmd_ptr[cmd_cnt] = cmd_arguments[cmd_cnt]; + cmd_cnt++; + i++; + } + g_strfreev(vector); } d27 5 a31 1 strcpy(cmd_arguments[cmd_cnt], sd->path); @ 1.4 log @add extra preference to the "Output" -> "ogg123" tab: "User options:" as per the mpg123 tab. this allows setting ogg123 options such as "--buffer 5000". XXX: i haven't patched any of the localisation stuff for this because i have NFC how to do it. @ text @d1 1 a1 1 $NetBSD$ @ 1.3 log @Update gqmpeg to 0.8.3nb1, to play Ogg Vorbis properly. Patch sent in PR 12470 by Rui-Xiang Guo @ text @d3 11 a13 3 --- src/io_ogg123.c.orig Fri Feb 16 03:53:18 2001 +++ src/io_ogg123.c @@@@ -52,10 +52,15 @@@@ d29 43 @ 1.2 log @Update to V0.6.3. Changes: This release adds support for the newly released mpg123 0.59r. New features include mpg123's --aggresive support (for higher priority, see README), freeamp support, and NetBSD native sound mixer support. This release also fixes ipc on NetBSD, crashes in g_hook_next_valid(), and more, leading to a more robust program. @ text @d1 5 a5 10 --- ipc.c.orig Mon Jun 14 00:47:56 1999 +++ ipc.c Mon Jun 14 00:49:37 1999 @@@@ -219,6 +219,8 @@@@ printf("unknown ipc command: `%s'\n", i_buf); } } + if (feof(ipc_file_id) != 0) + rewind (ipc_file_id); return TRUE; } d7 14 @ 1.1 log @Fix ipc handling, thanks to Simon Burge . (I'm still not sure this isn't a bug in NetBSD, though...) @ text @@