Skip to content

Commit b3c15f3

Browse files
committed
fix: validate COM initialization in audio device management #181
1 parent 1905c95 commit b3c15f3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

webrtc-jni/src/main/cpp/src/media/audio/windows/WindowsAudioDeviceManager.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ namespace jni
5959

6060
std::set<AudioDevicePtr> WindowsAudioDeviceManager::getAudioCaptureDevices()
6161
{
62+
if (!comInitializer.isInitialized()) {
63+
throw jni::Exception("Invalid COM thread model change (MTA->STA)");
64+
}
65+
6266
if (captureDevices.empty()) {
6367
enumerateDevices(eCapture);
6468
}
@@ -68,6 +72,10 @@ namespace jni
6872

6973
std::set<AudioDevicePtr> WindowsAudioDeviceManager::getAudioPlaybackDevices()
7074
{
75+
if (!comInitializer.isInitialized()) {
76+
throw jni::Exception("Invalid COM thread model change (MTA->STA)");
77+
}
78+
7179
if (playbackDevices.empty()) {
7280
enumerateDevices(eRender);
7381
}

0 commit comments

Comments
 (0)