Commit 6a945960 authored by Jason Lin's avatar Jason Lin Committed by Chromium LUCI CQ

VmCameraMicManager calls ShouldUseCrosCameraService in thread pool

See the bug for details. This also changes the behavior a little bit
--- VmCameraMicManager now will subscribe to cras even if the camera
service is not available.

Fixed: 167491603
Change-Id: I7d6852cfe64badc0b8a791f91f24a3ffff150173
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2598532
Commit-Queue: Jason Lin <lxj@google.com>
Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#838802}
parent 8004081e
......@@ -79,6 +79,8 @@ VmCameraMicManager::VmCameraMicManager()
base::Unretained(this))) {}
void VmCameraMicManager::OnPrimaryUserSessionStarted(Profile* primary_profile) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
primary_profile_ = primary_profile;
crostini_vm_notification_observer_.Initialize(
primary_profile_, base::BindRepeating(OpenCrostiniSettings));
......@@ -90,14 +92,12 @@ void VmCameraMicManager::OnPrimaryUserSessionStarted(Profile* primary_profile) {
}
// Only do the subscription in real ChromeOS environment.
if (base::SysInfo::IsRunningOnChromeOS() &&
media::ShouldUseCrosCameraService()) {
auto* camera = media::CameraHalDispatcherImpl::GetInstance();
// OnActiveClientChange() will be called automatically after the
// subscription, so there is no need to get the current status here.
camera->AddActiveClientObserver(this);
OnCameraPrivacySwitchStatusChanged(
camera->AddCameraPrivacySwitchObserver(this));
if (base::SysInfo::IsRunningOnChromeOS()) {
base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, {base::MayBlock()},
base::BindOnce(media::ShouldUseCrosCameraService),
base::BindOnce(&VmCameraMicManager::MaybeSubscribeToCameraService,
base::Unretained(this)));
CrasAudioHandler::Get()->AddAudioObserver(this);
// Fetch the current value.
......@@ -113,6 +113,22 @@ void VmCameraMicManager::OnPrimaryUserSessionStarted(Profile* primary_profile) {
// we do not do clean up (e.g. deregister as observers) here.
VmCameraMicManager::~VmCameraMicManager() = default;
void VmCameraMicManager::MaybeSubscribeToCameraService(
bool should_use_cros_camera_service) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (!should_use_cros_camera_service) {
return;
}
auto* camera = media::CameraHalDispatcherImpl::GetInstance();
// OnActiveClientChange() will be called automatically after the
// subscription, so there is no need to get the current status here.
camera->AddActiveClientObserver(this);
OnCameraPrivacySwitchStatusChanged(
camera->AddCameraPrivacySwitchObserver(this));
}
void VmCameraMicManager::UpdateVmInfoAndNotifications(
VmType vm,
void (VmInfo::*updator)(bool),
......
......@@ -130,6 +130,8 @@ class VmCameraMicManager : public media::CameraActiveClientObserver,
base::WeakPtrFactory<VmNotificationObserver> weak_ptr_factory_{this};
};
void MaybeSubscribeToCameraService(bool should_use_cros_camera_service);
// media::CameraActiveClientObserver
void OnActiveClientChange(cros::mojom::CameraClientType type,
bool is_active) override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment