summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2020-10-30 10:58:05 +0100
committerPeter Varga <pvarga@inf.u-szeged.hu>2020-11-03 10:28:54 +0100
commit0a45a566f195c738d1561c691e7a767bd36bf9d7 (patch)
tree37cc80a2e6c7607471436cf4274a1fc867dae86f
parentfcbf5e18c921ccad494387da60b36df5c34f1c8f (diff)
Do not set audio device for desktop capture if audio loopback is unsupported
Desktop audio capture requires loopback device. If creation of the loopback device fails, it aborts the screen capture too. Chromium does not support audio loopback on Linux and macOS: https://crbug.com/223639 This is still the case in Chrome 88. The fix is based on: https://codereview.chromium.org/24153018 Change-Id: Ifb13bce3b79193203c0bf52e1f2a1b3936e017c7 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--src/core/media_capture_devices_dispatcher.cpp13
-rw-r--r--src/core/media_capture_devices_dispatcher.h2
2 files changed, 12 insertions, 3 deletions
diff --git a/src/core/media_capture_devices_dispatcher.cpp b/src/core/media_capture_devices_dispatcher.cpp
index 693cfa2e3..ac74c509c 100644
--- a/src/core/media_capture_devices_dispatcher.cpp
+++ b/src/core/media_capture_devices_dispatcher.cpp
@@ -272,7 +272,8 @@ void MediaCaptureDevicesDispatcher::handleMediaAccessPermissionResponse(content:
break;
}
} else if (desktopVideoRequested) {
- getDevicesForDesktopCapture(&devices, getDefaultScreenId(), desktopAudioRequested,
+ bool captureAudio = desktopAudioRequested && m_loopbackAudioSupported;
+ getDevicesForDesktopCapture(&devices, getDefaultScreenId(), captureAudio,
request.video_type, request.audio_type);
}
}
@@ -309,6 +310,10 @@ MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher()
// content::NOTIFICATION_WEB_CONTENTS_DESTROYED, and that will result in
// possible use after free.
DCHECK_CURRENTLY_ON(BrowserThread::UI);
+#if defined(OS_WIN)
+ // Currently loopback audio capture is supported only on Windows.
+ m_loopbackAudioSupported = true;
+#endif
m_notificationsRegistrar.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
content::NotificationService::AllSources());
}
@@ -383,9 +388,11 @@ void MediaCaptureDevicesDispatcher::processDesktopCaptureAccessRequest(content::
}
// Audio is only supported for screen capture streams.
- bool capture_audio = (mediaId.type == content::DesktopMediaID::TYPE_SCREEN && request.audio_type == MediaStreamType::GUM_DESKTOP_AUDIO_CAPTURE);
+ bool audioRequested = request.audio_type == MediaStreamType::GUM_DESKTOP_AUDIO_CAPTURE;
+ bool audioSupported = (mediaId.type == content::DesktopMediaID::TYPE_SCREEN && m_loopbackAudioSupported);
+ bool captureAudio = (audioRequested && audioSupported);
- getDevicesForDesktopCapture(&devices, mediaId, capture_audio, request.video_type, request.audio_type);
+ getDevicesForDesktopCapture(&devices, mediaId, captureAudio, request.video_type, request.audio_type);
if (devices.empty())
std::move(callback).Run(devices, MediaStreamRequestResult::INVALID_STATE,
diff --git a/src/core/media_capture_devices_dispatcher.h b/src/core/media_capture_devices_dispatcher.h
index 6a67a53e9..17cb5d5c9 100644
--- a/src/core/media_capture_devices_dispatcher.h
+++ b/src/core/media_capture_devices_dispatcher.h
@@ -127,6 +127,8 @@ private:
content::NotificationRegistrar m_notificationsRegistrar;
+ bool m_loopbackAudioSupported = false;
+
DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesDispatcher);
};