Skip to content

Commit

Permalink
Refactor AudioInputController and split stat by stream type.
Browse files Browse the repository at this point in the history
Clean up confusing usage of "low latency". Remove a factory function since there were two similar ones.

Before this CL, "low latency" could either refer to requesting a low latency stream type from the AudioManager or that the stream was requested over IPC, which was confusing. Now, it always refers to the kind of stream requested. This also means that the streams for which Media.AudioInputControllerSessionSilenceReport is reported changes.

The Media.AudioInputControllerCaptureStartupSuccess stat is split into three separate stats: Media.{{High,Low}Latency,Virtual}AudioCaptureStartupSuccess, where Virtual refers to stream types obtained by redirecting output streams rather than going through the platform audio system (such as tab capture).

BUG=600536
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2665163002
Cr-Commit-Position: refs/heads/master@{#447973}
  • Loading branch information
maxmorin authored and Commit bot committed Feb 3, 2017
1 parent 49a6b5d commit 3500cac
Show file tree
Hide file tree
Showing 11 changed files with 266 additions and 212 deletions.
11 changes: 3 additions & 8 deletions content/browser/renderer_host/media/audio_input_renderer_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,9 @@ void AudioInputRendererHost::DoCreateStream(
if (entry->controller.get() && type == MEDIA_DESKTOP_AUDIO_CAPTURE)
IncrementDesktopCaptureCounter(TAB_AUDIO_CAPTURER_CREATED);
} else {
// We call CreateLowLatency regardless of the value of
// |audio_params.format|. Low latency can currently mean different things in
// different parts of the stack.
// TODO(grunell): Clean up the low latency terminology so that it's less
// confusing.
entry->controller = media::AudioInputController::CreateLowLatency(
audio_manager_, this, audio_params, device_id, entry->writer.get(),
std::move(debug_writer), user_input_monitor_,
entry->controller = media::AudioInputController::Create(
audio_manager_, this, entry->writer.get(), user_input_monitor_,
std::move(debug_writer), audio_params, device_id,
config.automatic_gain_control);
oss << ", AGC=" << config.automatic_gain_control;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,14 @@ class MockAudioInputController : public AudioInputController {
AudioInputController::SyncWriter* writer,
media::AudioManager* audio_manager,
AudioInputController::EventHandler* event_handler,
media::UserInputMonitor* user_input_monitor)
media::UserInputMonitor* user_input_monitor,
StreamType type)
: AudioInputController(std::move(task_runner),
event_handler,
writer,
/*debug_writer*/ nullptr,
user_input_monitor,
/*agc*/ false) {
type) {
GetTaskRunnerForTesting()->PostTask(
FROM_HERE,
base::Bind(&AudioInputController::EventHandler::OnCreated,
Expand Down Expand Up @@ -230,11 +231,12 @@ class MockControllerFactory : public AudioInputController::Factory {
media::AudioManager* audio_manager,
AudioInputController::EventHandler* event_handler,
media::AudioParameters params,
media::UserInputMonitor* user_input_monitor) override {
media::UserInputMonitor* user_input_monitor,
AudioInputController::StreamType type) override {
ControllerCreated();
scoped_refptr<MockController> controller =
new MockController(std::move(task_runner), sync_writer, audio_manager,
event_handler, user_input_monitor);
event_handler, user_input_monitor, type);
controller_list_.push_back(controller);
return controller.get();
}
Expand Down
6 changes: 5 additions & 1 deletion content/browser/speech/speech_recognizer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <stdint.h>

#include <algorithm>

#include "base/bind.h"
#include "base/macros.h"
#include "base/time/time.h"
Expand All @@ -14,6 +16,7 @@
#include "content/browser/media/media_internals.h"
#include "content/browser/speech/audio_buffer.h"
#include "content/public/browser/speech_recognition_event_listener.h"
#include "media/audio/audio_file_writer.h"
#include "media/base/audio_converter.h"

#if defined(OS_WIN)
Expand Down Expand Up @@ -589,7 +592,8 @@ SpeechRecognizerImpl::StartRecording(const FSMEventArgs&) {
new OnDataConverter(input_parameters, output_parameters));

audio_controller_ = AudioInputController::Create(
audio_manager, this, this, input_parameters, device_id_, NULL);
audio_manager, this, this, nullptr, nullptr, input_parameters, device_id_,
/*agc_is_enabled*/ false);

if (!audio_controller_.get()) {
return Abort(
Expand Down
1 change: 1 addition & 0 deletions content/browser/speech/speech_recognizer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_H_

#include <memory>
#include <string>

#include "base/macros.h"
#include "content/browser/speech/endpointer/endpointer.h"
Expand Down
6 changes: 5 additions & 1 deletion media/audio/audio_file_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

#include <memory>

namespace base {
class FilePath;
}

namespace media {

class AudioBus;
Expand Down Expand Up @@ -36,6 +40,6 @@ class AudioFileWriter {
virtual bool WillWrite() = 0;
};

} // namspace media
} // namespace media

#endif // MEDIA_AUDIO_AUDIO_FILE_WRITER_H_
Loading

0 comments on commit 3500cac

Please sign in to comment.