Commit 5c061177 authored by En-Shuo Hsu's avatar En-Shuo Hsu Committed by Commit Bot

Set the HOTWORD effect as a general effect

We used to treat the HOTWORD as a flag to enable DSP hardware hotwording for
Google Assistant. For scenario that we pin capture stream on internal
mic for board without usable DSP hotwording, we used not to enable it. With this
CL, we'll always enable the flag and rely on the passed in device_id to
determine if it is a DSP hotwording or not. It also sets the stream type to
SpeechRecognition to enable use case specific tuning on CRAS.

This change will depend on CRAS to also treat the mask flag as general HOTWORD.
Corresponding change is chromium:1994813 which needs to be fixed before this.

BUG=chromium:1020969
TEST=Build, deploy and check if CRAS creates the corresponding stream.

Change-Id: I4faeeeccfa11c409a7bfcc177d31c7223837b4b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1997003
Commit-Queue: En-Shuo Hsu <enshuo@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#731855}
parent 5e0d4c49
......@@ -451,10 +451,13 @@ void AudioInputImpl::RecreateAudioInputStream(bool use_dsp) {
GetChannelLayout(g_current_format), g_current_format.sample_rate,
g_current_format.sample_rate / 10 /* buffer size for 100 ms */);
if (use_dsp && !hotword_device_id_.empty()) {
param.set_effects(media::AudioParameters::PlatformEffectsMask::HOTWORD);
// Set the HOTWORD mask so CRAS knows the device is used for HOTWORD purpose
// and is able to conduct the tuning specifically for the scenario. Whether
// the HOTWORD is conducted by a hotword device or other devices like internal
// mic will be determined by the device_id_ passed to CRAS.
param.set_effects(media::AudioParameters::PlatformEffectsMask::HOTWORD);
if (use_dsp && !hotword_device_id_.empty())
device_id_ = hotword_device_id_;
}
mojo::PendingRemote<audio::mojom::StreamFactory> stream_factory;
client_->RequestAudioStreamFactory(
......
......@@ -186,9 +186,12 @@ void CrasInputStream::Start(AudioInputCallback* callback) {
return;
}
CRAS_STREAM_TYPE type = CRAS_STREAM_TYPE_DEFAULT;
uint32_t flags = 0;
if (params_.effects() & AudioParameters::PlatformEffectsMask::HOTWORD)
if (params_.effects() & AudioParameters::PlatformEffectsMask::HOTWORD) {
flags = HOTWORD_STREAM;
type = CRAS_STREAM_TYPE_SPEECH_RECOGNITION;
}
unsigned int frames_per_packet = params_.frames_per_buffer();
cras_stream_params* stream_params = cras_client_stream_params_create(
......@@ -196,12 +199,8 @@ void CrasInputStream::Start(AudioInputCallback* callback) {
frames_per_packet, // Total latency.
frames_per_packet, // Call back when this many ready.
frames_per_packet, // Minimum Callback level ignored for capture streams.
CRAS_STREAM_TYPE_DEFAULT,
flags,
this,
CrasInputStream::SamplesReady,
CrasInputStream::StreamError,
audio_format);
type, flags, this, CrasInputStream::SamplesReady,
CrasInputStream::StreamError, audio_format);
if (!stream_params) {
DLOG(WARNING) << "Error setting up stream parameters.";
callback_->OnError();
......
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