// Copyright 2012 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef SERVICES_AUDIO_INPUT_CONTROLLER_H_ #define SERVICES_AUDIO_INPUT_CONTROLLER_H_ #include <stddef.h> #include <stdint.h> #include <memory> #include <optional> #include <string> #include <string_view> #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" #include "base/task/single_thread_task_runner.h" #include "base/threading/thread_checker.h" #include "base/time/time.h" #include "base/timer/timer.h" #include "build/build_config.h" #include "media/base/audio_parameters.h" #include "media/base/audio_processing.h" #include "media/media_buildflags.h" #include "media/mojo/mojom/audio_processing.mojom.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/remote.h" #include "services/audio/stream_monitor.h" namespace media { class AecdumpRecordingManager; class AudioBus; class AudioInputStream; class AudioManager; class UserInputMonitor; struct AudioGlitchInfo; } // namespace media namespace audio { class AudioProcessorHandler; class AudioCallback; class DeviceOutputListener; class OutputTapper; class Snoopable; #if BUILDFLAG(CHROME_WIDE_ECHO_CANCELLATION) class ProcessingAudioFifo; #endif // Only do power monitoring for non-mobile platforms to save resources. #if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) #define AUDIO_POWER_MONITORING #endif // All public methods of InputController must be called from the audio thread. // // Audio data flow through InputController: // // * Without any audio processing: // InputController::|audio_callback_|::OnData() // -> InputController::OnData() // --> InputController::|sync_writer_|::Write() // // * With audio processing but no dedicated processing thread: // InputController::|audio_callback_|::OnData() // -> InputController::OnData() // --> InputController::|audio_processor_handler_|::ProcessCapturedAudio() // ---> InputController::DeliverProcessedAudio() // ----> InputController::|sync_writer_|::Write() // // * With audio processing and a dedicated processing thread: // Audio capture device thread: // InputController::|audio_callback_|::OnData() // -> InputController::OnData() // --> InputController::|processing_fifo_|::PushData() // Audio processing thread: // ---> InputController::|audio_processor_handler_|::ProcessCapturedAudio() // ----> InputController::DeliverProcessedAudio() // -----> InputController::|sync_writer_|::Write() // // - InputController::|audio_processor_handler_| changes format from the // AudioInputStream format to |params| provided to // InputController::Create(). // class InputController final : public StreamMonitor { … }; } // namespace audio #endif // SERVICES_AUDIO_INPUT_CONTROLLER_H_