Browse Source

make WASAPI instantiation errors non-fatal for older Windows

tags/5.1.0
JP Cimalando 7 years ago
parent
commit
2f4e77da2a
1 changed files with 6 additions and 4 deletions
  1. +6
    -4
      RtAudio.cpp

+ 6
- 4
RtAudio.cpp View File

@@ -3899,10 +3899,9 @@ RtApiWasapi::RtApiWasapi()
CLSCTX_ALL, __uuidof( IMMDeviceEnumerator ),
( void** ) &deviceEnumerator_ );

if ( FAILED( hr ) ) {
errorText_ = "RtApiWasapi::RtApiWasapi: Unable to instantiate device enumerator";
error( RtAudioError::DRIVER_ERROR );
}
// If this runs on an old Windows, it will fail. Ignore and proceed.
if ( FAILED( hr ) )
deviceEnumerator_ = NULL;
}

//-----------------------------------------------------------------------------
@@ -3929,6 +3928,9 @@ unsigned int RtApiWasapi::getDeviceCount( void )
IMMDeviceCollection* captureDevices = NULL;
IMMDeviceCollection* renderDevices = NULL;

if ( !deviceEnumerator_ )
return 0;

// Count capture devices
errorText_.clear();
HRESULT hr = deviceEnumerator_->EnumAudioEndpoints( eCapture, DEVICE_STATE_ACTIVE, &captureDevices );


Loading…
Cancel
Save