summaryrefslogtreecommitdiff
path: root/RtAudio.cpp
diff options
context:
space:
mode:
authorMarcus Tomlinson <themarcustomlinson@gmail.com>2014-04-18 16:02:56 +0200
committerMarcus Tomlinson <themarcustomlinson@gmail.com>2014-04-18 16:02:56 +0200
commit8b7653b945cbe09610a6cd5902f439873db0d18e (patch)
tree956ad27a46481d42e20a23b2873b6e5caa96c428 /RtAudio.cpp
parent148caac0c11e150e13610075e8579aded608b12f (diff)
Fixed shutdown crash on certain sample rates
Diffstat (limited to 'RtAudio.cpp')
-rw-r--r--RtAudio.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/RtAudio.cpp b/RtAudio.cpp
index 3bd001a..44cf4ed 100644
--- a/RtAudio.cpp
+++ b/RtAudio.cpp
@@ -4626,7 +4626,8 @@ void RtApiWasapi::wasapiThread()
// convBuffer is used to store converted buffers between WASAPI and the user
char* convBuffer = NULL;
- unsigned int deviceBufferSize = 0;
+ unsigned int convBuffSize = 0;
+ unsigned int deviceBuffSize = 0;
errorText_.clear();
RtAudioError::Type errorType = RtAudioError::DRIVER_ERROR;
@@ -4801,18 +4802,22 @@ void RtApiWasapi::wasapiThread()
}
if ( stream_.mode == INPUT ) {
- deviceBufferSize = ( size_t ) ( stream_.bufferSize * captureSrRatio ) * stream_.nDeviceChannels[INPUT] * formatBytes( stream_.deviceFormat[INPUT] );
+ convBuffSize = ( size_t ) ( stream_.bufferSize * captureSrRatio ) * stream_.nDeviceChannels[INPUT] * formatBytes( stream_.deviceFormat[INPUT] );
+ deviceBuffSize = stream_.bufferSize * stream_.nDeviceChannels[INPUT] * formatBytes( stream_.deviceFormat[INPUT] );
}
else if ( stream_.mode == OUTPUT ) {
- deviceBufferSize = ( size_t ) ( stream_.bufferSize * renderSrRatio ) * stream_.nDeviceChannels[OUTPUT] * formatBytes( stream_.deviceFormat[OUTPUT] );
+ convBuffSize = ( size_t ) ( stream_.bufferSize * renderSrRatio ) * stream_.nDeviceChannels[OUTPUT] * formatBytes( stream_.deviceFormat[OUTPUT] );
+ deviceBuffSize = stream_.bufferSize * stream_.nDeviceChannels[OUTPUT] * formatBytes( stream_.deviceFormat[OUTPUT] );
}
else if ( stream_.mode == DUPLEX ) {
- deviceBufferSize = std::max( ( size_t ) ( stream_.bufferSize * captureSrRatio ) * stream_.nDeviceChannels[INPUT] * formatBytes( stream_.deviceFormat[INPUT] ),
- ( size_t ) ( stream_.bufferSize * renderSrRatio ) * stream_.nDeviceChannels[OUTPUT] * formatBytes( stream_.deviceFormat[OUTPUT] ) );
+ convBuffSize = std::max( ( size_t ) ( stream_.bufferSize * captureSrRatio ) * stream_.nDeviceChannels[INPUT] * formatBytes( stream_.deviceFormat[INPUT] ),
+ ( size_t ) ( stream_.bufferSize * renderSrRatio ) * stream_.nDeviceChannels[OUTPUT] * formatBytes( stream_.deviceFormat[OUTPUT] ) );
+ deviceBuffSize = std::max( stream_.bufferSize * stream_.nDeviceChannels[INPUT] * formatBytes( stream_.deviceFormat[INPUT] ),
+ stream_.bufferSize * stream_.nDeviceChannels[OUTPUT] * formatBytes( stream_.deviceFormat[OUTPUT] ) );
}
- convBuffer = ( char* ) malloc( deviceBufferSize );
- stream_.deviceBuffer = ( char* ) malloc( deviceBufferSize );
+ convBuffer = ( char* ) malloc( convBuffSize );
+ stream_.deviceBuffer = ( char* ) malloc( deviceBuffSize );
if ( !convBuffer || !stream_.deviceBuffer ) {
errorType = RtAudioError::MEMORY_ERROR;
errorText_ = "RtApiWasapi::wasapiThread: Error allocating device buffer memory.";