[xiph-cvs] cvs commit: vorbis-tools/ogg123 buffer.c cmdline_options.c http_transport.c ogg123.c ogg123.h status.c

Stan Seibert volsung at xiph.org
Tue Dec 18 20:59:18 PST 2001



volsung     01/12/18 20:59:18

  Modified:    ogg123   buffer.c cmdline_options.c http_transport.c
                        ogg123.c ogg123.h status.c
  Log:
  Status line tinkering, option changes, buffering fixes.

Revision  Changes    Path
1.11      +15 -9     vorbis-tools/ogg123/buffer.c

Index: buffer.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/buffer.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- buffer.c	2001/12/19 03:47:40	1.10
+++ buffer.c	2001/12/19 04:59:16	1.11
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: buffer.c,v 1.10 2001/12/19 03:47:40 volsung Exp $
+ last mod: $Id: buffer.c,v 1.11 2001/12/19 04:59:16 volsung Exp $
 
  ********************************************************************/
 
@@ -32,6 +32,8 @@
 #define MIN3(x,y,z)    MIN(x,MIN(y,z))
 #define MIN4(w,x,y,z)  MIN( MIN(w,x), MIN(y,z) )
 
+#define DEBUG_BUFFER
+
 /* Special debugging code.  THIS IS NOT PORTABLE! */
 #ifdef DEBUG_BUFFER
 FILE *debugfile;
@@ -248,8 +250,7 @@
     buf->curfill -= write_amount;
     buf->position += write_amount;
     buf->start = (buf->start + write_amount) % buf->size;
-    DEBUG("Updated buffer fill, curfill = %ld, position = %ld", buf->curfill,
-	  buf->position);
+    DEBUG("Updated buffer fill, curfill = %ld", buf->curfill);
 
     /* If we've essentially emptied the buffer and prebuffering is enabled,
        we need to do another prebuffering session */
@@ -382,9 +383,12 @@
   pthread_cond_init(&buf->write_cond, NULL);
   pthread_cond_init(&buf->playback_cond, NULL);
   
-  /* Correct for impossible chunk sizes */
+  /* Correct for impossible prebuffer and chunk sizes */
   if (audio_chunk_size > size || audio_chunk_size == 0)
     audio_chunk_size = size / 2;
+  
+  if (prebuffer > size)
+    prebuffer = prebuffer / 2;
 
   buf->audio_chunk_size = audio_chunk_size;
 
@@ -517,10 +521,10 @@
 
     DEBUG("Obtaining lock on buffer");
     /* Block until we can read something */
-    if (buf->curfill == 0) {
-      if (buf->eos)
-	break; /* No more data to read */
+    if (buf->curfill == 0 && buf->eos)
+      break; /* No more data to read */
       
+    if (buf->curfill == 0 && (buf->prebuffering && !buf->eos)) {
       DEBUG("Waiting for more data to copy.");
       COND_WAIT(buf->playback_cond, buf->mutex);
     }
@@ -538,13 +542,15 @@
        3. Do not run off the end of the buffer. */
     write_amount = compute_dequeue_size(buf, nbytes);
 
+    UNLOCK_MUTEX(buf->mutex);
     execute_actions(buf, &buf->actions, buf->position);
-    
+
     /* No need to lock mutex here because the other thread will
        NEVER reduce the number of bytes stored in the buffer */
     DEBUG("Copying %d bytes from the buffer", write_amount);
     memcpy(data, buf->buffer + buf->start, write_amount);
-    
+    LOCK_MUTEX(buf->mutex);
+
     buf->curfill -= write_amount;
     data += write_amount;
     nbytes -= write_amount;

1.3       +16 -9     vorbis-tools/ogg123/cmdline_options.c

Index: cmdline_options.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/cmdline_options.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- cmdline_options.c	2001/12/19 02:52:53	1.2
+++ cmdline_options.c	2001/12/19 04:59:16	1.3
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: cmdline_options.c,v 1.2 2001/12/19 02:52:53 volsung Exp $
+ last mod: $Id: cmdline_options.c,v 1.3 2001/12/19 04:59:16 volsung Exp $
 
  ********************************************************************/
 
@@ -24,6 +24,8 @@
 #include "cmdline_options.h"
 #include "status.h"
 
+#define MIN_INPUT_BUFFER_SIZE 8
+
 struct option long_options[] = {
   /* GNU standard options */
     {"help", no_argument, 0, 'h'},
@@ -67,7 +69,12 @@
         exit(1);
         
       case 'b':
-	ogg123_opts->buffer_size = atoi(optarg) * 1024;
+	ogg123_opts->input_buffer_size = atoi(optarg) * 1024;
+	if (ogg123_opts->input_buffer_size < MIN_INPUT_BUFFER_SIZE * 1024) {
+	  status_error("Input buffer size smaller than minimum size of %dkB.",
+		       MIN_INPUT_BUFFER_SIZE);
+	  ogg123_opts->input_buffer_size = MIN_INPUT_BUFFER_SIZE * 1024;
+	}
         break;
         
       case 'c':
@@ -143,13 +150,13 @@
           break;
           
         case 'p':
-	  ogg123_opts->prebuffer = atof (optarg);
-	  if (ogg123_opts->prebuffer < 0.0f || 
-	      ogg123_opts->prebuffer > 100.0f) {
+	  ogg123_opts->input_prebuffer = atof (optarg);
+	  if (ogg123_opts->input_prebuffer < 0.0f || 
+	      ogg123_opts->input_prebuffer > 100.0f) {
 
             status_error ("--- Prebuffer value invalid. Range is 0-100.\n");
-	    ogg123_opts->prebuffer = 
-	      ogg123_opts->prebuffer < 0.0f ? 0.0f : 100.0f;
+	    ogg123_opts->input_prebuffer = 
+	      ogg123_opts->input_prebuffer < 0.0f ? 0.0f : 100.0f;
           }
           break;
 
@@ -262,8 +269,8 @@
          "  -o, --device-option=k:v passes special option k with value\n"
          "      v to previously specified device (with -d).  See\n"
          "      man page for more info.\n"
-	 "  -b n, --buffer n  use a buffer of approximately 'n' kilobytes\n"
-	 "  -p n, --prebuffer n  prebuffer n%% of the buffer before playing\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"
          "  -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"

1.3       +4 -2      vorbis-tools/ogg123/http_transport.c

Index: http_transport.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/http_transport.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- http_transport.c	2001/12/19 02:52:53	1.2
+++ http_transport.c	2001/12/19 04:59:16	1.3
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
  
- last mod: $Id: http_transport.c,v 1.2 2001/12/19 02:52:53 volsung Exp $
+ last mod: $Id: http_transport.c,v 1.3 2001/12/19 04:59:16 volsung Exp $
  
 ********************************************************************/
 
@@ -161,7 +161,9 @@
     source->transport = &http_transport;
     source->private = private;
     
-    private->buf = buffer_create (INPUT_BUFFER_SIZE, 0, 
+    private->buf = buffer_create (ogg123_opts->input_buffer_size,
+				  ogg123_opts->input_buffer_size *
+				  ogg123_opts->input_prebuffer / 100.0, 
                                   NULL, NULL,  /* No write callback, using
                                                   buffer in pull mode. */
                                   0 /* Irrelevant */);

1.51      +5 -13     vorbis-tools/ogg123/ogg123.c

Index: ogg123.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- ogg123.c	2001/12/19 02:52:54	1.50
+++ ogg123.c	2001/12/19 04:59:16	1.51
@@ -14,7 +14,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: ogg123.c,v 1.50 2001/12/19 02:52:54 volsung Exp $
+ last mod: $Id: ogg123.c,v 1.51 2001/12/19 04:59:16 volsung Exp $
 
  ********************************************************************/
 
@@ -60,10 +60,6 @@
 /* This macro is used to create some dummy variables to hold default values
    for the options. */
 #define INIT(type, value) type type##_##value = value
-char char_n = 'n';
-float float_50f = 50.0f;
-float float_0f = 0.0f;
-INIT(int, 10000);
 INIT(int, 1);
 INIT(int, 0);
 
@@ -73,12 +69,6 @@
    &options.default_device, NULL},
   {0, "shuffle",        "shuffle playlist",      opt_type_bool,
    &options.shuffle,        &int_0},
-  {0, "verbose",        "verbosity level",       opt_type_int,
-   &options.verbosity,        &int_1},
-  {0, "outbuffer",      "out buffer size (kB)",  opt_type_int,
-   &options.buffer_size, &int_0},
-  {0, "outprebuffer",   "out prebuffer (%)",     opt_type_float,
-   &options.prebuffer,   &float_0f},
   {0, NULL,             NULL,                    0,               NULL,                NULL}
 };
 
@@ -134,14 +124,16 @@
 
 void options_init (ogg123_options_t *opts)
 {
-  opts->verbosity = 1;
+  opts->verbosity = 2;
   opts->shuffle = 0;
   opts->delay = 2;
   opts->nth = 1;
   opts->ntimes = 1;
   opts->seekpos = 0.0;
-  opts->buffer_size = 0;
+  opts->buffer_size = 0; //128 * 1024;
   opts->prebuffer = 0.0f;
+  opts->input_buffer_size = 32 * 1024;
+  opts->input_prebuffer = 50.0f;
   opts->default_device = NULL;
 
   opts->status_freq = 10.0;

1.11      +4 -1      vorbis-tools/ogg123/ogg123.h

Index: ogg123.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ogg123.h	2001/12/19 02:52:54	1.10
+++ ogg123.h	2001/12/19 04:59:17	1.11
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: ogg123.h,v 1.10 2001/12/19 02:52:54 volsung Exp $
+ last mod: $Id: ogg123.h,v 1.11 2001/12/19 04:59:17 volsung Exp $
 
  ********************************************************************/
 
@@ -32,6 +32,9 @@
 
   long buffer_size;           /* Size of audio buffer */
   float prebuffer;            /* Percent of buffer to fill before playing */
+  long input_buffer_size;     /* Size of input audio buffer */
+  float input_prebuffer;
+
   char *default_device;       /* Name of default driver to use */
 
   audio_device_t *devices;    /* Audio devices to use */

1.3       +2 -2      vorbis-tools/ogg123/status.c

Index: status.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/status.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- status.c	2001/12/19 02:52:54	1.2
+++ status.c	2001/12/19 04:59:17	1.3
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: status.c,v 1.2 2001/12/19 02:52:54 volsung Exp $
+ last mod: $Id: status.c,v 1.3 2001/12/19 04:59:17 volsung Exp $
 
  ********************************************************************/
 
@@ -238,7 +238,7 @@
   cur = stats + 4; /* instantaneous bitrate */
   cur->verbosity = 2;
   cur->enabled = 1;
-  cur->formatstr = "Bitrate: %5.1f";
+  cur->formatstr = " (%.1f kbps)";
   cur->type = stat_doublearg;
 
   cur = stats + 5; /* average bitrate (not yet implemented) */

--- >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