Commit 35090794 authored by Marina Ciocea's avatar Marina Ciocea Committed by Commit Bot

Add UI thread KeyboardMicRegistration implementation.

Used by AudioInputStreamBroker (introduced in dependent CL) instead of
AudioInputDeviceManager::KeyboardMicRegistration implementation, in order to avoid thread jumps and
to keep broker interface simple.

AudioInputDeviceManager::KeyboardMicRegistration will be removed after switching to audio service
input streams.

Bug: 828868
Change-Id: I41aac3e01faeb0d4d47f98726bc069640fb346e3
Reviewed-on: https://chromium-review.googlesource.com/1044216
Commit-Queue: Marina Ciocea <marinaciocea@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarMax Morin <maxmorin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556390}
parent 81dc8c20
......@@ -1739,6 +1739,8 @@ jumbo_source_set("browser") {
# ChromeOS also defines linux but their memory-monitors conflict.
if (is_chromeos) {
sources += [
"media/keyboard_mic_registration.cc",
"media/keyboard_mic_registration.h",
"memory/memory_monitor_chromeos.cc",
"memory/memory_monitor_chromeos.h",
"tracing/cros_tracing_agent.cc",
......
......@@ -19,6 +19,10 @@
#include "services/viz/public/interfaces/compositing/compositing_mode_watcher.mojom.h"
#include "ui/base/ui_features.h"
#if defined(OS_CHROMEOS)
#include "content/browser/media/keyboard_mic_registration.h"
#endif
#if defined(USE_AURA)
namespace aura {
class Env;
......@@ -166,6 +170,13 @@ class CONTENT_EXPORT BrowserMainLoop {
media::UserInputMonitor* user_input_monitor() const {
return user_input_monitor_.get();
}
#if defined(OS_CHROMEOS)
KeyboardMicRegistration* keyboard_mic_registration() {
return &keyboard_mic_registration_;
}
#endif
discardable_memory::DiscardableSharedMemoryManager*
discardable_shared_memory_manager() const {
return discardable_shared_memory_manager_.get();
......@@ -344,6 +355,10 @@ class CONTENT_EXPORT BrowserMainLoop {
scoped_refptr<base::DeferredSequencedTaskRunner> audio_service_runner_;
std::unique_ptr<media::AudioSystem> audio_system_;
#if defined(OS_CHROMEOS)
KeyboardMicRegistration keyboard_mic_registration_;
#endif
std::unique_ptr<midi::MidiService> midi_service_;
// Must be deleted on the IO thread.
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/media/keyboard_mic_registration.h"
#include "chromeos/audio/cras_audio_handler.h"
#include "content/public/browser/browser_thread.h"
namespace content {
KeyboardMicRegistration::KeyboardMicRegistration() = default;
KeyboardMicRegistration::~KeyboardMicRegistration() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK_EQ(0, register_count_);
}
void KeyboardMicRegistration::Register() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (++register_count_ == 1)
chromeos::CrasAudioHandler::Get()->SetKeyboardMicActive(true);
}
void KeyboardMicRegistration::Deregister() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (--register_count_ == 0)
chromeos::CrasAudioHandler::Get()->SetKeyboardMicActive(false);
}
} // namespace content
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_MEDIA_KEYBOARD_MIC_REGISTRATION_H_
#define CONTENT_BROWSER_MEDIA_KEYBOARD_MIC_REGISTRATION_H_
#include "base/macros.h"
namespace content {
// Chrome OS keyboard mic stream registration. Used on UI thread only and owned
// by BrowserMainLoop; instance must be obtained through
// BrowserMainLoop::keyboard_mic_registration().
class KeyboardMicRegistration {
public:
KeyboardMicRegistration();
~KeyboardMicRegistration();
void Register();
void Deregister();
private:
int register_count_ = 0;
DISALLOW_COPY_AND_ASSIGN(KeyboardMicRegistration);
};
} // namespace content
#endif // CONTENT_BROWSER_MEDIA_KEYBOARD_MIC_REGISTRATION_H_
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