Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Xiph.Org
Vorbis tools
Commits
b97535a3
Commit
b97535a3
authored
Jun 24, 2003
by
Ralph Giles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch to fixed number of arguments on separate debug macros. Ugly, but actually portable.
svn path=/trunk/vorbis-tools/; revision=4999
parent
17e3b7f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
16 deletions
+19
-16
ogg123/buffer.c
ogg123/buffer.c
+19
-16
No files found.
ogg123/buffer.c
View file @
b97535a3
...
...
@@ -11,7 +11,7 @@
* *
********************************************************************
last mod: $Id: buffer.c,v 1.2
0
2003/0
5/03 14:24:33 volsung
Exp $
last mod: $Id: buffer.c,v 1.2
1
2003/0
6/24 11:39:37 giles
Exp $
********************************************************************/
...
...
@@ -34,20 +34,23 @@
#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
;
#define DEBUG(x, y...) { fprintf (debugfile, "%d: " x "\n", getpid(), ## y); }
#define DEBUG(x) { fprintf (debugfile, "%d: " x "\n", getpid()); }
#define DEBUG1(x, y) { fprintf (debugfile, "%d: " x "\n", getpid(), y); }
#define DEBUG2(x, y, z) { fprintf (debugfile, "%d: " x "\n", getpid(), y, z); }
#else
#define DEBUG(x, y...)
#define DEBUG(x)
#define DEBUG1(x, y)
#define DEBUG2(x, y, z)
#endif
/* Macros that support debugging of threading structures */
#define LOCK_MUTEX(mutex) { DEBUG("Locking mutex %s.", #mutex); pthread_mutex_lock (&(mutex)); }
#define UNLOCK_MUTEX(mutex) { DEBUG("Unlocking mutex %s", #mutex); pthread_mutex_unlock(&(mutex)); }
#define COND_WAIT(cond, mutex) { DEBUG("Unlocking %s and waiting on %s", #mutex, #cond); pthread_cond_wait(&(cond), &(mutex)); }
#define COND_SIGNAL(cond) { DEBUG("Signalling %s", #cond); pthread_cond_signal(&(cond)); }
#define LOCK_MUTEX(mutex) { DEBUG
1
("Locking mutex %s.", #mutex); pthread_mutex_lock (&(mutex)); }
#define UNLOCK_MUTEX(mutex) { DEBUG
1
("Unlocking mutex %s", #mutex); pthread_mutex_unlock(&(mutex)); }
#define COND_WAIT(cond, mutex) { DEBUG
2
("Unlocking %s and waiting on %s", #mutex, #cond); pthread_cond_wait(&(cond), &(mutex)); }
#define COND_SIGNAL(cond) { DEBUG
1
("Signalling %s", #cond); pthread_cond_signal(&(cond)); }
extern
signal_request_t
sig_request
;
/* Need access to global cancel flag */
...
...
@@ -238,7 +241,7 @@ void *buffer_thread_func (void *arg)
/* No need to lock mutex here because the other thread will
NEVER reduce the number of bytes stored in the buffer */
DEBUG
(
"Sending %d bytes to the audio device"
,
write_amount
);
DEBUG
1
(
"Sending %d bytes to the audio device"
,
write_amount
);
write_amount
=
buf
->
write_func
(
buf
->
buffer
+
buf
->
start
,
write_amount
,
/* Only set EOS if this is the last chunk */
write_amount
==
buf
->
curfill
?
buf
->
eos
:
0
,
...
...
@@ -249,7 +252,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"
,
buf
->
curfill
);
DEBUG
1
(
"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 */
...
...
@@ -276,7 +279,7 @@ void submit_data_chunk (buf_t *buf, char *data, size_t size)
long
buf_write_pos
;
/* offset of first available write location */
size_t
write_size
;
DEBUG
(
"Enter submit_data_chunk, size %d"
,
size
);
DEBUG
1
(
"Enter submit_data_chunk, size %d"
,
size
);
pthread_cleanup_push
(
buffer_mutex_unlock
,
buf
);
...
...
@@ -301,7 +304,7 @@ void submit_data_chunk (buf_t *buf, char *data, size_t size)
data
+=
write_size
;
size
-=
write_size
;
buf
->
position_end
+=
write_size
;
DEBUG
(
"writing chunk into buffer, curfill = %ld"
,
buf
->
curfill
);
DEBUG
1
(
"writing chunk into buffer, curfill = %ld"
,
buf
->
curfill
);
}
else
{
...
...
@@ -370,7 +373,7 @@ buf_t *buffer_create (long size, long prebuffer,
#endif
/* Initialize the buffer structure. */
DEBUG
(
"buffer_create, size = %ld"
,
size
);
DEBUG
1
(
"buffer_create, size = %ld"
,
size
);
memset
(
buf
,
0
,
sizeof
(
*
buf
));
...
...
@@ -555,7 +558,7 @@ size_t buffer_get_data (buf_t *buf, char *data, long nbytes)
/* 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
);
DEBUG
1
(
"Copying %d bytes from the buffer"
,
write_amount
);
memcpy
(
data
,
buf
->
buffer
+
buf
->
start
,
write_amount
);
LOCK_MUTEX
(
buf
->
mutex
);
...
...
@@ -563,7 +566,7 @@ size_t buffer_get_data (buf_t *buf, char *data, long nbytes)
data
+=
write_amount
;
nbytes
-=
write_amount
;
buf
->
start
=
(
buf
->
start
+
write_amount
)
%
buf
->
size
;
DEBUG
(
"Updated buffer fill, curfill = %ld"
,
buf
->
curfill
);
DEBUG
1
(
"Updated buffer fill, curfill = %ld"
,
buf
->
curfill
);
/* Signal a waiting decoder thread that they can put more
audio into the buffer */
...
...
@@ -738,7 +741,7 @@ void buffer_wait_for_empty (buf_t *buf)
while
(
!
empty
)
{
if
(
buf
->
curfill
>
0
)
{
DEBUG
(
"Buffer curfill = %ld, going back to sleep."
,
buf
->
curfill
);
DEBUG
1
(
"Buffer curfill = %ld, going back to sleep."
,
buf
->
curfill
);
COND_WAIT
(
buf
->
write_cond
,
buf
->
mutex
);
}
else
empty
=
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment