diff -Naur vorbis-tools-1.0/ogg123/cmdline_options.c vorbis-tools-1.0-ml1/ogg123/cmdline_options.c --- vorbis-tools-1.0/ogg123/cmdline_options.c 2002-07-11 02:44:39.000000000 +0000 +++ vorbis-tools-1.0-ml1/ogg123/cmdline_options.c 2003-09-26 20:26:10.000000000 +0000 @@ -36,6 +36,7 @@ {"config", optional_argument, 0, 'c'}, {"device", required_argument, 0, 'd'}, {"file", required_argument, 0, 'f'}, + {"comment-file", required_argument, 0, 'g'}, {"skip", required_argument, 0, 'k'}, {"delay", required_argument, 0, 'l'}, {"device-option", required_argument, 0, 'o'}, @@ -63,7 +64,7 @@ audio_device_t *current; int ret; - while (-1 != (ret = getopt_long(argc, argv, "b:c::d:f:hl:k:o:p:qvVx:y:z@:", + while (-1 != (ret = getopt_long(argc, argv, "b:c::d:f:g:hl:k:o:p:qvVx:y:z@:", long_options, &option_index))) { switch (ret) { @@ -136,6 +137,11 @@ } break; + case 'g': + free(ogg123_opts->comment_output_file); + ogg123_opts->comment_output_file = strdup(optarg); + break; + case 'k': ogg123_opts->seekpos = atof(optarg); break; @@ -284,6 +290,8 @@ " man page for more info.\n" " -b n, --buffer n use an input buffer of 'n' kilobytes\n" " -p n, --prebuffer n load n%% of the input buffer before playing\n" + " -g, --comment-file=filename Store vorbiscomment for current metadata\n" + " in file specified\n" " -v, --verbose display progress and other status information\n" " -q, --quiet don't display anything (no title)\n" " -x n, --nth play every 'n'th block\n" @@ -293,4 +301,5 @@ "ogg123 will skip to the next song on SIGINT (Ctrl-C); two SIGINTs within\n" "s milliseconds make ogg123 terminate.\n" " -l, --delay=s set s [milliseconds] (default 500).\n")); + } diff -Naur vorbis-tools-1.0/ogg123/ogg123.1 vorbis-tools-1.0-ml1/ogg123/ogg123.1 --- vorbis-tools-1.0/ogg123/ogg123.1 2002-07-12 02:24:49.000000000 +0000 +++ vorbis-tools-1.0-ml1/ogg123/ogg123.1 2003-09-26 20:24:22.000000000 +0000 @@ -23,6 +23,9 @@ .B -b .I buffer_size ] [ +.B -g +.I filename +] [ .B -d .I driver [ @@ -64,6 +67,11 @@ .IP "-p n, --prebuffer n" Prebuffer 'n' percent of the input buffer. Playback won't begin until this prebuffer is complete. +.IP "-g filename, --comment-file=filename" +Write the vorbiscomment metadata of the current stream to the specified +file. Each time the metadata is updated, this file will be overwritten. The +path to this file should exist, but the file itself will be created if not +found, or overwritten if it is. .IP "-d device, --device device" Specify output device. See .B DEVICES diff -Naur vorbis-tools-1.0/ogg123/ogg123.c vorbis-tools-1.0-ml1/ogg123/ogg123.c --- vorbis-tools-1.0/ogg123/ogg123.c 2002-07-06 19:12:18.000000000 +0000 +++ vorbis-tools-1.0-ml1/ogg123/ogg123.c 2003-09-26 19:42:49.000000000 +0000 @@ -148,6 +148,8 @@ opts->status_freq = 10.0; opts->playlist = NULL; + + opts->comment_output_file = NULL; } diff -Naur vorbis-tools-1.0/ogg123/ogg123.h vorbis-tools-1.0-ml1/ogg123/ogg123.h --- vorbis-tools-1.0/ogg123/ogg123.h 2002-07-06 19:12:18.000000000 +0000 +++ vorbis-tools-1.0-ml1/ogg123/ogg123.h 2003-09-26 19:42:41.000000000 +0000 @@ -43,6 +43,8 @@ double status_freq; /* Number of status updates per second */ playlist_t *playlist; /* List of files to play */ + + char *comment_output_file; /* File to write current vorbiscomment to */ } ogg123_options_t; typedef struct signal_request_t { diff -Naur vorbis-tools-1.0/ogg123/oggvorbis_format.c vorbis-tools-1.0-ml1/ogg123/oggvorbis_format.c --- vorbis-tools-1.0/ogg123/oggvorbis_format.c 2002-07-19 10:31:53.000000000 +0000 +++ vorbis-tools-1.0-ml1/ogg123/oggvorbis_format.c 2003-09-26 20:08:03.000000000 +0000 @@ -36,6 +36,8 @@ int bos; /* At beginning of logical bitstream */ decoder_stats_t stats; + + char *commentfile; } ovf_private_t; /* Forward declarations */ @@ -63,6 +65,7 @@ char *lookup_comment_prettyprint (char *comment, int *offset); void print_stream_comments (decoder_t *decoder); void print_stream_info (decoder_t *decoder); +void store_stream_comments (decoder_t *decoder); /* ----------------------------------------------------------- */ @@ -102,6 +105,7 @@ private->stats.current_time = 0.0; private->stats.instant_bitrate = 0; private->stats.avg_bitrate = 0; + private->commentfile = ogg123_opts->comment_output_file; } else { fprintf(stderr, _("Error: Out of memory.\n")); exit(1); @@ -140,6 +144,7 @@ decoder->actual_fmt.channels = priv->vi->channels; print_stream_comments(decoder); + store_stream_comments(decoder); print_stream_info(decoder); priv->bos = 0; } @@ -419,3 +424,26 @@ _("Encoded by: %s"), priv->vc->vendor); } +void store_stream_comments (decoder_t *decoder) +{ + ovf_private_t *priv = decoder->private; + decoder_callbacks_t *cb = decoder->callbacks; + char *comment, *filename; + FILE *outfile; + int i; + + + if (cb == NULL || cb->printf_metadata == NULL) + return; + + filename = priv->commentfile; + if( (filename == NULL) || ((outfile=fopen(filename,"w")) == NULL) ){ + return; + } + + for (i = 0; i < priv->vc->comments; i++) { + comment = priv->vc->user_comments[i]; + fprintf(outfile, "%s\n", comment); + } + fclose(outfile); +}