[xiph-cvs] cvs commit: vorbis-tools/ogg123 buffer.c ogg123.c
Stan Seibert
volsung at xiph.org
Tue Dec 11 20:29:37 PST 2001
volsung 01/12/11 20:29:37
Modified: ogg123 Tag: volsung_kc_20011011 buffer.c ogg123.c
Log:
Fixed some small bugs in the buffer code.
Revision Changes Path
No revision
No revision
1.7.2.23.2.8 +17 -18 vorbis-tools/ogg123/buffer.c
Index: buffer.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/buffer.c,v
retrieving revision 1.7.2.23.2.7
retrieving revision 1.7.2.23.2.8
diff -u -r1.7.2.23.2.7 -r1.7.2.23.2.8
--- buffer.c 2001/12/11 05:29:08 1.7.2.23.2.7
+++ buffer.c 2001/12/12 04:29:35 1.7.2.23.2.8
@@ -11,19 +11,11 @@
* *
********************************************************************
- last mod: $Id: buffer.c,v 1.7.2.23.2.7 2001/12/11 05:29:08 volsung Exp $
+ last mod: $Id: buffer.c,v 1.7.2.23.2.8 2001/12/12 04:29:35 volsung Exp $
********************************************************************/
-/* buffer.c
- * buffering code for ogg123. This is Unix-specific. Other OSes anyone?
- *
- * Thanks to Lee McLouchlin's buffer(1) for inspiration; no code from
- * that program is used in this buffer.
- */
-#define _GNU_SOURCE
-
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/time.h>
@@ -39,7 +31,6 @@
#define MIN3(x,y,z) MIN(x,MIN(y,z))
#define MIN4(w,x,y,z) MIN( MIN(w,x), MIN(y,z) )
-
/* Special debugging code. THIS IS NOT PORTABLE! */
#ifdef DEBUG_BUFFER
FILE *debugfile;
@@ -215,14 +206,20 @@
DEBUG("Ready to play");
- /* Figure out how much we can play in the buffer */
+ UNLOCK_MUTEX(buf->mutex);
+
+ /* Don't need to lock buffer while running actions since position
+ won't change. We clear out any actions before we compute the
+ dequeue size so we don't consider actions that need to
+ run right now. */
+ execute_actions(buf, &buf->actions, buf->position);
+
+ LOCK_MUTEX(buf->mutex);
+
+ /* Need to be locked while we check things. */
write_amount = compute_dequeue_size(buf, buf->audio_chunk_size);
UNLOCK_MUTEX(buf->mutex);
-
- /* Don't need to lock buffer while running acitons since position
- won't change */
- 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 */
@@ -237,7 +234,8 @@
buf->curfill -= write_amount;
buf->position += write_amount;
buf->start = (buf->start + write_amount) % buf->size;
- DEBUG("Updated buffer fill, curfill = %ld", buf->curfill);
+ DEBUG("Updated buffer fill, curfill = %ld, position = %ld", buf->curfill,
+ buf->position);
/* If we've essentially emptied the buffer and prebuffering is enabled,
we need to do another prebuffering session */
@@ -371,6 +369,7 @@
audio_chunk_size = size / 2;
buf->audio_chunk_size = audio_chunk_size;
+
buf->prebuffer_size = prebuffer;
buf->size = size;
@@ -577,7 +576,7 @@
LOCK_MUTEX(buf->mutex);
/* Stick after the last item in the buffer */
- action->position = buf->position;
+ action->position = buf->position_end;
in_order_add_action(&buf->actions, action, INSERT);
@@ -595,7 +594,7 @@
LOCK_MUTEX(buf->mutex);
/* Stick after the last item in the buffer */
- action->position = buf->position;
+ action->position = buf->position_end;
in_order_add_action(&buf->actions, action, APPEND);
1.39.2.30.2.17 +2 -2 vorbis-tools/ogg123/ogg123.c
Index: ogg123.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.c,v
retrieving revision 1.39.2.30.2.16
retrieving revision 1.39.2.30.2.17
diff -u -r1.39.2.30.2.16 -r1.39.2.30.2.17
--- ogg123.c 2001/12/11 18:46:23 1.39.2.30.2.16
+++ ogg123.c 2001/12/12 04:29:35 1.39.2.30.2.17
@@ -14,7 +14,7 @@
* *
********************************************************************
- last mod: $Id: ogg123.c,v 1.39.2.30.2.16 2001/12/11 18:46:23 volsung Exp $
+ last mod: $Id: ogg123.c,v 1.39.2.30.2.17 2001/12/12 04:29:35 volsung Exp $
********************************************************************/
@@ -207,7 +207,7 @@
/* Setup buffer */
if (options.buffer_size > 0) {
audio_buffer = buffer_create(options.buffer_size,
- options.buffer_size * options.prebuffer,
+ options.buffer_size * options.prebuffer / 100,
audio_play_callback, &audio_play_arg,
AUDIO_CHUNK_SIZE);
if (audio_buffer == NULL) {
--- >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