Chromium Code Reviews| Index: media/audio/cras/cras_input.cc |
| diff --git a/media/audio/cras/cras_input.cc b/media/audio/cras/cras_input.cc |
| index 0b8644603f8996e670b988c282a1b234e4062ee0..1c98c929c1534adf03ee994706f9aac52e61311b 100644 |
| --- a/media/audio/cras/cras_input.cc |
| +++ b/media/audio/cras/cras_input.cc |
| @@ -183,6 +183,19 @@ void CrasInputStream::Start(AudioInputCallback* callback) { |
| // the callback. |
| bytes_per_frame_ = cras_client_format_bytes_per_frame(audio_format); |
| + // For a hotword hardware stream, only wait for a single callback. |
| + // Replace the existing callback with the HotwordSampleReady one that should |
| + // only run once. |
| + if (params_.effects() & |
| + AudioParameters::PlatformEffectsMask::HARDWARE_INPUT) { |
| + if (cras_client_add_hotword_callback(client_, audio_format, |
| + CrasInputStream::HotwordSampleReady)) { |
| + DLOG(WARNING) << "Failed to add the hotword callback."; |
| + callback_->OnError(this); |
| + callback_ = NULL; |
| + } |
| + } |
| + |
|
dgreid
2014/09/17 21:16:23
This can go above the creation of stream_params, a
rpetterson
2014/09/17 21:32:00
I've moved it and wrapped it in an else sinc ei as
dgreid
2014/09/17 21:36:33
Yes put that in the else as well, there is no need
rpetterson
2014/09/17 21:40:20
Done.
|
| // Adding the stream will start the audio callbacks. |
| if (cras_client_add_stream(client_, &stream_id_, stream_params)) { |
| DLOG(WARNING) << "Failed to add the stream."; |
| @@ -224,6 +237,18 @@ int CrasInputStream::SamplesReady(cras_client* client, |
| return frames; |
| } |
| +// Static callback asking for a single sample. Run on high priority thread. |
| +int CrasInputStream::HotwordSampleReady(cras_client* client, |
| + cras_audio_format* fmt, |
| + uint8* hotword_phrase, |
| + size_t frames, |
| + const timespec* sample_ts, |
| + void* arg) { |
| + CrasInputStream* me = static_cast<CrasInputStream*>(arg); |
| + me->ReadAudio(frames, single_sample, sample_ts); |
|
dgreid
2014/09/17 21:16:23
this can be as much as two seconds of audio. Does
rpetterson
2014/09/17 21:32:00
Question for Dale.
DaleCurtis
2014/09/17 22:29:22
Yes, this needs to be converted to match the param
rpetterson
2014/09/22 22:24:40
During construction of the stream? Which parameter
DaleCurtis
2014/09/22 23:49:44
As mentioned, the parameters passed in during cons
dgreid
2014/12/10 00:23:34
It might be better to do it here, call ReadAudio r
rpetterson
2014/12/10 00:37:43
I'm unclear here. What do I need to change?
dgreid
2014/12/10 00:54:49
ignore that comment. it must have been a draft fr
|
| + return frames; |
| +} |
| + |
| // Static callback for stream errors. |
| int CrasInputStream::StreamError(cras_client* client, |
| cras_stream_id_t stream_id, |