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:
parent
cd024e3425
commit
bcf890f125
|
@ -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();
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue