[xiph-cvs] cvs commit: vorbis-tools/ogg123 ogg123.c

Kenneth C. Arnold kcarnold at xiph.org
Tue Jun 19 11:58:27 PDT 2001



kcarnold    01/06/19 11:58:27

  Modified:    ogg123   ogg123.c
  Log:
  Fix verbose output, especially when input is not seekable. Found a bug
  in vorbisfile in the process.

Revision  Changes    Path
1.37      +25 -12    vorbis-tools/ogg123/ogg123.c

Index: ogg123.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- ogg123.c	2001/06/19 17:15:32	1.36
+++ ogg123.c	2001/06/19 18:58:27	1.37
@@ -14,7 +14,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: ogg123.c,v 1.36 2001/06/19 17:15:32 kcarnold Exp $
+ last mod: $Id: ogg123.c,v 1.37 2001/06/19 18:58:27 kcarnold Exp $
 
  ********************************************************************/
 
@@ -387,6 +387,7 @@
                 exit(1);
 
         if (opt.quiet < 1) {
+	    if (eos && opt.verbose) fprintf (stderr, "\n");
             for (i = 0; i < vc->comments; i++) {
                 char *cc = vc->user_comments[i];	/* current comment */
                 int i;
@@ -405,10 +406,11 @@
 
             fprintf(stderr, "\nBitstream is %d channel, %ldHz\n",
                     vi->channels, vi->rate);
-	    fprintf(stderr, "Encoded by: %s\n\n", vc->vendor);
+	    if (opt.verbose > 1)
+	      fprintf(stderr, "Encoded by: %s\n\n", vc->vendor);
         }
 
-	if (opt.verbose > 0) {
+	if (opt.verbose > 0 && ov_seekable(&vf)) {
             /* Seconds with double precision */
             u_time = ov_time_total(&vf, -1);
             t_min = (long) u_time / (long) 60;
@@ -467,15 +469,26 @@
                   devices_write(convbuffer, ret, opt.outdevices);
                 
                 if (opt.verbose > 0) {
-		    u_pos = ov_time_tell(&vf);
-		    c_min = (long) u_pos / (long) 60;
-		    c_sec = u_pos - 60 * c_min;
-		    r_min = (long) (u_time - u_pos) / (long) 60;
-		    r_sec = (u_time - u_pos) - 60 * r_min;
-		    fprintf(stderr,
-			    "\rTime: %02li:%05.2f [%02li:%05.2f] of %02li:%05.2f, Bitrate: %.1f   \r",
-			    c_min, c_sec, r_min, r_sec, t_min, t_sec,
-			    (float) ov_bitrate_instant(&vf) / 1000.0F);
+		    if (ov_seekable (&vf)) {
+		      u_pos = ov_time_tell(&vf);
+		      c_min = (long) u_pos / (long) 60;
+		      c_sec = u_pos - 60 * c_min;
+		      r_min = (long) (u_time - u_pos) / (long) 60;
+		      r_sec = (u_time - u_pos) - 60 * r_min;
+		      fprintf(stderr,
+			      "\rTime: %02li:%05.2f [%02li:%05.2f] of %02li:%05.2f, Bitrate: %.1f   \r",
+			      c_min, c_sec, r_min, r_sec, t_min, t_sec,
+			      (float) ov_bitrate_instant(&vf) / 1000.0F);
+		    } else {
+		      /* working around a bug in vorbisfile */
+		      u_pos = (double) ov_pcm_tell(&vf) / (double) vi->rate;
+		      c_min = (long) u_pos / (long) 60;
+		      c_sec = u_pos - 60 * c_min;
+		      fprintf(stderr,
+			      "\rTime: %02li:%05.2f, Bitrate: %.1f   \r",
+			      c_min, c_sec,
+			      (float) ov_bitrate_instant (&vf) / 1000.0F);
+		    }
                 }
             }
         }

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list