Make CircBuf are lock-free, threadsafe buffer. (We don't actually

take advantage of this yet.)
This commit is contained in:
Glenn Maynard
2004-03-16 03:06:10 +00:00
parent ab50b4c426
commit eb86c76b9f
2 changed files with 188 additions and 39 deletions
+3 -3
View File
@@ -203,7 +203,7 @@ void RageSound::Update(float delta)
/* Return the number of bytes available in the input buffer. */
int RageSound::Bytes_Available() const
{
return databuf.size();
return databuf.num_readable();
}
@@ -277,7 +277,7 @@ int RageSound::FillBuf(int bytes)
while(bytes > 0)
{
if(read_block_size > databuf.capacity() - databuf.size())
if(read_block_size > databuf.num_writable())
break; /* full */
char inbuf[10240];
@@ -347,7 +347,7 @@ int RageSound::GetData(char *buffer, int size)
} else {
/* Feed data out of our streaming buffer. */
ASSERT(Sample);
got = min(int(databuf.size()), size);
got = min(int(databuf.num_readable()), size);
if(buffer)
databuf.read(buffer, got);
}