Commit bf38206b authored by Stan Seibert's avatar Stan Seibert

Status line tinkering, option changes, buffering fixes.

svn path=/trunk/vorbis-tools/; revision=2843
parent 8cc58035
......@@ -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 @@ void *buffer_thread_func (void *arg)
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,10 +383,13 @@ buf_t *buffer_create (long size, long prebuffer,
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;
buf->prebuffer_size = prebuffer;
......@@ -517,10 +521,10 @@ size_t buffer_get_data (buf_t *buf, char *data, long nbytes)
DEBUG("Obtaining lock on buffer");
/* Block until we can read something */
if (buf->curfill == 0) {
if (buf->eos)
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,12 +542,14 @@ size_t buffer_get_data (buf_t *buf, char *data, long nbytes)
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;
......
......@@ -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 @@ int parse_cmdline_options (int argc, char **argv,
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 @@ int parse_cmdline_options (int argc, char **argv,
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 @@ void cmdline_usage (void)
" -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"
......
......@@ -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 @@ data_source_t* http_open (char *source_string, ogg123_options_t *ogg123_opts)
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 */);
......
......@@ -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 @@ audio_play_arg_t audio_play_arg;
/* 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 @@ file_option_t file_opts[] = {
&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 signal_handler (int signo)
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;
......
......@@ -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 @@ typedef struct ogg123_options_t {
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 */
......
......@@ -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 @@ stat_format_t *stat_format_create ()
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) */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment