Skip to content

Commit

Permalink
Prevent crash if UWP WASAPI devices aren't found
Browse files Browse the repository at this point in the history
  • Loading branch information
FrayxRulez committed Sep 9, 2018
1 parent b2ac10e commit f643b02
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions os/windows/AudioInputWASAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ void AudioInputWASAPI::ActuallySetCurrentDevice(std::string deviceID){
CHECK_RES(res, "device->Activate");
#else
Platform::String^ defaultDevID=Windows::Media::Devices::MediaDevice::GetDefaultAudioCaptureId(Windows::Media::Devices::AudioDeviceRole::Communications);
if(defaultDevID == nullptr){
LOGE("Didn't find capture device; failing");
failed=true;
return;
}

HRESULT res1, res2;
IAudioClient2* audioClient2=WindowsSandboxUtils::ActivateAudioDevice(defaultDevID->Data(), &res1, &res2);
CHECK_RES(res1, "activate1");
Expand Down
6 changes: 6 additions & 0 deletions os/windows/AudioOutputWASAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@ void AudioOutputWASAPI::ActuallySetCurrentDevice(std::string deviceID){
CHECK_RES(res, "device->Activate");
#else
Platform::String^ defaultDevID=Windows::Media::Devices::MediaDevice::GetDefaultAudioRenderId(Windows::Media::Devices::AudioDeviceRole::Communications);
if(defaultDevID==nullptr){
LOGE("Didn't find playback device; failing");
failed=true;
return;
}

HRESULT res1, res2;
IAudioClient2* audioClient2=WindowsSandboxUtils::ActivateAudioDevice(defaultDevID->Data(), &res1, &res2);
CHECK_RES(res1, "activate1");
Expand Down

0 comments on commit f643b02

Please sign in to comment.