Changed the return of IAudioCapture::getCapturedAudio to return the size of the data copied to the output buffer instead of void.

This commit is contained in:
Joshua Jones 2009-08-26 01:43:45 +00:00
parent cd024e3425
commit bcf890f125
3 changed files with 7 additions and 3 deletions

View File

@ -69,7 +69,7 @@ namespace cAudio
\param outputBuffer: Pointer to an output array to copy audio data to.
\param outputBufferSize: Size of the output array in bytes
*/
virtual void getCapturedAudio(void* outputBuffer, unsigned int outputBufferSize);
virtual unsigned int getCapturedAudio(void* outputBuffer, unsigned int outputBufferSize);
//! Returns the current size of the internal audio buffer in bytes
virtual unsigned int getCurrentCapturedAudioSize();

View File

@ -110,14 +110,17 @@ namespace cAudio
Capturing = false;
}
void cAudioCapture::getCapturedAudio(void* outputBuffer, unsigned int outputBufferSize)
unsigned int cAudioCapture::getCapturedAudio(void* outputBuffer, unsigned int outputBufferSize)
{
if(outputBuffer && outputBufferSize > 0)
{
int sizeToCopy = (outputBufferSize >= CaptureBuffer.size()) ? CaptureBuffer.size() : outputBufferSize;
memcpy(outputBuffer, &CaptureBuffer[0], sizeToCopy);
CaptureBuffer.erase(CaptureBuffer.begin(), CaptureBuffer.begin()+sizeToCopy);
return sizeToCopy;
}
return 0;
}
unsigned int cAudioCapture::getCurrentCapturedAudioSize()

View File

@ -50,8 +50,9 @@ namespace cAudio
Once successfully retrieved, the captured audio will be deleted from the internal buffer.
\param outputBuffer: Pointer to an output array to copy audio data to.
\param outputBufferSize: Size of the output array in bytes
\return Size in bytes of the data actually copied to the output buffer.
*/
virtual void getCapturedAudio(void* outputBuffer, unsigned int outputBufferSize) = 0;
virtual unsigned int getCapturedAudio(void* outputBuffer, unsigned int outputBufferSize) = 0;
//! Returns the current size of the internal audio buffer in bytes
virtual unsigned int getCurrentCapturedAudioSize() = 0;