Skip to content

Commit

Permalink
Small fix to paex_record_file.c
Browse files Browse the repository at this point in the history
git-svn-id: http://subversion.assembla.com/svn/portaudio/portaudio/trunk@1853 0f58301d-fd10-0410-b4af-bbb618454e57
  • Loading branch information
robiwano committed Jul 9, 2012
1 parent e402840 commit 2b96ab0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/paex_record_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ static int playCallback( const void *inputBuffer, void *outputBuffer,
{
paTestData *data = (paTestData*)userData;
ring_buffer_size_t elementsToPlay = PaUtil_GetRingBufferReadAvailable(&data->ringBuffer);
ring_buffer_size_t elementsToRead = min(elementsToPlay, (ring_buffer_size_t)framesPerBuffer);
ring_buffer_size_t elementsToRead = min(elementsToPlay, (ring_buffer_size_t)(framesPerBuffer * NUM_CHANNELS));
SAMPLE* wptr = (SAMPLE*)outputBuffer;

(void) inputBuffer; /* Prevent unused variable warnings. */
Expand All @@ -272,14 +272,14 @@ static int playCallback( const void *inputBuffer, void *outputBuffer,
if ((ring_buffer_size_t)framesPerBuffer > elementsToRead)
{
int i;
const int samplesToClear = (framesPerBuffer - elementsToRead) * NUM_CHANNELS;
const int samplesToClear = framesPerBuffer * NUM_CHANNELS - elementsToRead;
for (i = 0; i < samplesToClear; ++i)
{
*wptr++ = 0;
}
}

data->frameIndex += PaUtil_ReadRingBuffer(&data->ringBuffer, wptr, elementsToRead * NUM_CHANNELS);
data->frameIndex += PaUtil_ReadRingBuffer(&data->ringBuffer, wptr, elementsToRead);

return data->threadSyncFlag ? paComplete : paContinue;
}
Expand Down

0 comments on commit 2b96ab0

Please sign in to comment.