diff options
| author | garyscavone <garyscavone@users.noreply.github.com> | 2019-09-28 11:51:58 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-28 11:51:58 -0400 |
| commit | 57c2c9d7598a783a5167422cd744f4d3797141bb (patch) | |
| tree | 5c3894a4f0738304409a1ce0dbbaf3de9406a92c | |
| parent | 1cba5c90a35b0e79915dc46dd5525da2285a211b (diff) | |
| parent | 298396eca03c3027073f39760459f909b30cda9c (diff) | |
Add maxOutSampleCount to WasapiResampler::Convert()
| -rw-r--r-- | RtAudio.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/RtAudio.cpp b/RtAudio.cpp index dce61fe..82622ad 100644 --- a/RtAudio.cpp +++ b/RtAudio.cpp @@ -4073,7 +4073,7 @@ public: #endif } - void Convert( char* outBuffer, const char* inBuffer, unsigned int inSampleCount, unsigned int& outSampleCount ) + void Convert( char* outBuffer, const char* inBuffer, unsigned int inSampleCount, unsigned int& outSampleCount, int maxOutSampleCount = -1 ) { unsigned int inputBufferSize = _bytesPerSample * _channelCount * inSampleCount; if ( _sampleRatio == 1 ) @@ -4084,7 +4084,15 @@ public: return; } - unsigned int outputBufferSize = ( unsigned int ) ceilf( inputBufferSize * _sampleRatio ) + ( _bytesPerSample * _channelCount ); + unsigned int outputBufferSize = 0; + if ( maxOutSampleCount != -1 ) + { + outputBufferSize = _bytesPerSample * _channelCount * maxOutSampleCount; + } + else + { + outputBufferSize = ( unsigned int ) ceilf( inputBufferSize * _sampleRatio ) + ( _bytesPerSample * _channelCount ); + } IMFMediaBuffer* rInBuffer; IMFSample* rInSample; @@ -5197,11 +5205,6 @@ void RtApiWasapi::wasapiThread() if ( captureAudioClient ) { int samplesToPull = ( unsigned int ) floorf( stream_.bufferSize * captureSrRatio ); - if ( captureSrRatio != 1 ) - { - // account for remainders - samplesToPull--; - } convBufferSize = 0; while ( convBufferSize < stream_.bufferSize ) @@ -5223,7 +5226,8 @@ void RtApiWasapi::wasapiThread() captureResampler->Convert( stream_.deviceBuffer + deviceBufferOffset, convBuffer, samplesToPull, - convSamples ); + convSamples, + convBufferSize == 0 ? -1 : stream_.bufferSize - convBufferSize ); convBufferSize += convSamples; samplesToPull = 1; // now pull one sample at a time until we have stream_.bufferSize samples |
