Navigation Menu

Skip to content

Commit

Permalink
Fix for properly streaming from the overflow buffer.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Oct 17, 2001
1 parent 4eaa16a commit c727004
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion playsound/playsound.c
Expand Up @@ -90,6 +90,7 @@ static volatile int done_flag = 0;
static void audio_callback(void *userdata, Uint8 *stream, int len)
{
static Uint8 overflow[16384]; /* this is a hack. */
static Uint8 *overflow_ptr;
static int overflowBytes = 0;
Sound_Sample *sample = (Sound_Sample *) userdata;
int bw = 0; /* bytes written to stream*/
Expand All @@ -98,7 +99,8 @@ static void audio_callback(void *userdata, Uint8 *stream, int len)
if (overflowBytes > 0)
{
bw = (overflowBytes < len) ? overflowBytes : len;
memcpy(stream, overflow, bw);
memcpy(stream, overflow_ptr, bw);
overflow_ptr += bw;
overflowBytes -= bw;
} /* if */

Expand All @@ -113,6 +115,7 @@ static void audio_callback(void *userdata, Uint8 *stream, int len)
memcpy(overflow,
((Uint8 *) sample->buffer) + (rc - overflowBytes),
overflowBytes);
overflow_ptr = overflow;
rc -= overflowBytes;
} /* if */

Expand Down

0 comments on commit c727004

Please sign in to comment.