Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Issue 2624403002: Refactor AudioInputController and related interfaces. (Closed)

Created:
3 years, 11 months ago by tommi (sloooow) - chröme
Modified:
3 years, 11 months ago
CC:
chromium-reviews, posciak+watch_chromium.org, jam, ossu-chromium, feature-media-reviews_chromium.org, darin-cc_chromium.org, asvitkine+watch_chromium.org, xjz+watch_chromium.org, miu+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Refactor AudioInputController and related interfaces. * Remove special callback code (OnData callback) for Speech and instead use the callback interface that's already supplied. * Made methods and variables private to keep test code separate and force use of ForTesting methods. * Removed state_ and lock_ variables from AudioInputController and removed the need for acquiring said lock in the audio callback. * Moved inheritance of AudioInputCallback into a subclass. * An instance of the callback subclass only exists while the callback is active. This makes the threading model clearer and allows us to avoid using locks and atomic operations. * Made several member variable const, as their value must never change. * Made supplying a handler_ non-optional as well as sync_writer_. This also simplifies the code quite a bit. * Changed the way we report UMA stats. We don't use a reference counter anymore or atomic operations. I suspect that we've been getting incorrect stats reported due to issues with how we were previously doing this (in addition to slowing down the audio path). * Added a new UMA stat to track how often we get errors reported from the audio layer during capture. BUG=681150, 681152 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/2624403002 Cr-Commit-Position: refs/heads/master@{#443925} Committed: https://chromium.googlesource.com/chromium/src/+/ce9a2515fc22794d7beb2268eaae525279a0c3b1

Patch Set 1 #

Total comments: 41

Patch Set 2 : Address comments #

Total comments: 2

Patch Set 3 : Update the other speech_recognition_browsertest.cc #

Patch Set 4 : Update comments #

Total comments: 6

Patch Set 5 : Don't report errors that occur after (or rather while) closing the stream #

Total comments: 2

Patch Set 6 : Remove superfluous DCHECK #

Patch Set 7 : Use a weak pointer factory when posting from other threads than the main thread. #

Patch Set 8 : Rebase #

Total comments: 14

Patch Set 9 : Address comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+430 lines, -323 lines) Patch
M content/browser/renderer_host/media/audio_input_renderer_host.h View 1 2 chunks +1 line, -3 lines 0 comments Download
M content/browser/renderer_host/media/audio_input_renderer_host.cc View 1 2 3 4 5 6 7 2 chunks +0 lines, -6 lines 0 comments Download
M content/browser/renderer_host/media/audio_input_renderer_host_unittest.cc View 1 2 3 4 5 6 7 3 chunks +6 lines, -5 lines 0 comments Download
M content/browser/speech/speech_recognition_browsertest.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
M content/browser/speech/speech_recognizer_impl.h View 2 chunks +8 lines, -2 lines 0 comments Download
M content/browser/speech/speech_recognizer_impl.cc View 3 chunks +7 lines, -3 lines 0 comments Download
M content/browser/speech/speech_recognizer_impl_unittest.cc View 9 chunks +17 lines, -11 lines 0 comments Download
M media/audio/audio_input_controller.h View 1 2 3 4 5 6 7 8 11 chunks +60 lines, -57 lines 0 comments Download
M media/audio/audio_input_controller.cc View 1 2 3 4 5 6 7 8 20 chunks +232 lines, -194 lines 0 comments Download
M media/audio/audio_input_controller_unittest.cc View 1 2 3 4 5 6 8 chunks +73 lines, -31 lines 0 comments Download
M media/audio/audio_io.h View 1 1 chunk +4 lines, -2 lines 0 comments Download
M media/audio/test_audio_input_controller_factory.h View 1 2 2 chunks +5 lines, -1 line 0 comments Download
M media/audio/test_audio_input_controller_factory.cc View 1 2 3 4 5 6 7 3 chunks +8 lines, -7 lines 0 comments Download
M tools/metrics/histograms/histograms.xml View 1 2 3 4 5 6 7 1 chunk +8 lines, -0 lines 0 comments Download

Messages

Total messages: 71 (29 generated)
tommi (sloooow) - chröme
Max and Olga - can you take a look please?
3 years, 11 months ago (2017-01-12 00:28:35 UTC) #4
Max Morin
lgtm! Nice cleanup. https://codereview.chromium.org/2624403002/diff/1/media/audio/audio_input_controller.cc File media/audio/audio_input_controller.cc (right): https://codereview.chromium.org/2624403002/diff/1/media/audio/audio_input_controller.cc#newcode411 media/audio/audio_input_controller.cc:411: DCHECK(!audio_callback_); DoRecord might be called multiple ...
3 years, 11 months ago (2017-01-12 09:31:11 UTC) #8
o1ka
That's a very handy change for our audio process work! Seems a bit racy as ...
3 years, 11 months ago (2017-01-12 12:07:39 UTC) #9
tommi (sloooow) - chröme
Address comments
3 years, 11 months ago (2017-01-12 14:19:58 UTC) #10
tommi (sloooow) - chröme
+Henrik - can you take a look over the comments? There are a couple of ...
3 years, 11 months ago (2017-01-12 14:21:01 UTC) #12
henrika (OOO until Aug 14)
Superb stuff Tommi ;-) Added some more details trying to answer the outstanding questions. Sorry ...
3 years, 11 months ago (2017-01-12 15:16:14 UTC) #13
Max Morin
https://codereview.chromium.org/2624403002/diff/1/media/audio/audio_input_controller.cc File media/audio/audio_input_controller.cc (right): https://codereview.chromium.org/2624403002/diff/1/media/audio/audio_input_controller.cc#newcode411 media/audio/audio_input_controller.cc:411: DCHECK(!audio_callback_); On 2017/01/12 14:21:00, tommi (chrömium) wrote: > On ...
3 years, 11 months ago (2017-01-12 15:17:12 UTC) #14
o1ka
Thank you and lgtm! https://codereview.chromium.org/2624403002/diff/1/media/audio/audio_input_controller.cc File media/audio/audio_input_controller.cc (right): https://codereview.chromium.org/2624403002/diff/1/media/audio/audio_input_controller.cc#newcode93 media/audio/audio_input_controller.cc:93: bool error_during_callback() const { return ...
3 years, 11 months ago (2017-01-12 17:27:16 UTC) #15
tommi (sloooow) - chröme
Update the other speech_recognition_browsertest.cc
3 years, 11 months ago (2017-01-12 18:42:27 UTC) #16
tommi (sloooow) - chröme
+holte for histograms.xml
3 years, 11 months ago (2017-01-12 18:43:43 UTC) #20
tommi (sloooow) - chröme
Update comments
3 years, 11 months ago (2017-01-12 18:56:08 UTC) #21
tommi (sloooow) - chröme
olka, maxmorin - I missed fixing the test in speech_recognition_browsertest.cc previously. So there are now ...
3 years, 11 months ago (2017-01-12 18:58:20 UTC) #22
henrika (OOO until Aug 14)
FYI, my comments earlier felt a bit fuzzy. Basically, all the logging (power level, mic ...
3 years, 11 months ago (2017-01-12 19:47:25 UTC) #23
henrika (OOO until Aug 14)
LGTM
3 years, 11 months ago (2017-01-12 19:47:47 UTC) #24
tommi (sloooow) - chröme
On 2017/01/12 19:47:25, henrika wrote: > FYI, my comments earlier felt a bit fuzzy. Basically, ...
3 years, 11 months ago (2017-01-12 20:04:16 UTC) #25
Steven Holte
histograms lgtm
3 years, 11 months ago (2017-01-12 21:16:43 UTC) #26
Max Morin
still lgtm
3 years, 11 months ago (2017-01-13 09:55:21 UTC) #31
o1ka
The failures on Mac seem to be related to the CL as well, don't they? ...
3 years, 11 months ago (2017-01-13 10:07:07 UTC) #32
tommi (sloooow) - chröme
On 2017/01/13 10:07:07, o1ka wrote: > The failures on Mac seem to be related to ...
3 years, 11 months ago (2017-01-13 10:31:29 UTC) #33
tommi (sloooow) - chröme
https://codereview.chromium.org/2624403002/diff/60001/media/audio/audio_input_controller.h File media/audio/audio_input_controller.h (right): https://codereview.chromium.org/2624403002/diff/60001/media/audio/audio_input_controller.h#newcode273 media/audio/audio_input_controller.h:273: EventHandler* GetHandlerForTesting() const { return handler_; } On 2017/01/13 ...
3 years, 11 months ago (2017-01-13 10:31:51 UTC) #34
o1ka
lgtm if mac failures are unrelated. https://codereview.chromium.org/2624403002/diff/60001/media/audio/audio_input_controller.h File media/audio/audio_input_controller.h (right): https://codereview.chromium.org/2624403002/diff/60001/media/audio/audio_input_controller.h#newcode273 media/audio/audio_input_controller.h:273: EventHandler* GetHandlerForTesting() const ...
3 years, 11 months ago (2017-01-13 10:38:00 UTC) #35
tommi (sloooow) - chröme
Don't report errors that occur after (or rather while) closing the stream
3 years, 11 months ago (2017-01-13 11:47:37 UTC) #36
tommi (sloooow) - chröme
I found and fixed the error that was happening on the mac bot. The issue ...
3 years, 11 months ago (2017-01-13 11:51:54 UTC) #39
tommi (sloooow) - chröme
Remove superfluous DCHECK
3 years, 11 months ago (2017-01-13 11:54:21 UTC) #40
tommi (sloooow) - chröme
https://codereview.chromium.org/2624403002/diff/60001/media/audio/audio_input_controller.cc File media/audio/audio_input_controller.cc (right): https://codereview.chromium.org/2624403002/diff/60001/media/audio/audio_input_controller.cc#newcode414 media/audio/audio_input_controller.cc:414: DCHECK(!audio_callback_); On 2017/01/13 10:07:07, o1ka wrote: > No need, ...
3 years, 11 months ago (2017-01-13 11:54:33 UTC) #41
o1ka
On 2017/01/13 11:51:54, tommi (chrømium) wrote: > I found and fixed the error that was ...
3 years, 11 months ago (2017-01-13 12:14:24 UTC) #42
tommi (sloooow) - chröme
On 2017/01/13 12:14:24, o1ka wrote: > On 2017/01/13 11:51:54, tommi (chrømium) wrote: > > I ...
3 years, 11 months ago (2017-01-13 12:25:48 UTC) #43
tommi (sloooow) - chröme
Use a weak pointer factory when posting from other threads than the main thread.
3 years, 11 months ago (2017-01-13 16:20:04 UTC) #44
tommi (sloooow) - chröme
OK, so in the latest patch set, I changed it so that we avoid adding ...
3 years, 11 months ago (2017-01-13 16:31:45 UTC) #47
tommi (sloooow) - chröme
Rebase
3 years, 11 months ago (2017-01-13 21:38:24 UTC) #51
Max Morin
still lgtm. https://codereview.chromium.org/2624403002/diff/80001/media/audio/audio_input_controller.cc File media/audio/audio_input_controller.cc (right): https://codereview.chromium.org/2624403002/diff/80001/media/audio/audio_input_controller.cc#newcode485 media/audio/audio_input_controller.cc:485: return; Is it possible to add a ...
3 years, 11 months ago (2017-01-16 10:02:14 UTC) #56
o1ka
I like the approach, maybe we can simplify object responsibilities a bit? (would like to ...
3 years, 11 months ago (2017-01-16 10:23:31 UTC) #57
tommi (sloooow) - chröme
https://codereview.chromium.org/2624403002/diff/80001/media/audio/audio_input_controller.cc File media/audio/audio_input_controller.cc (right): https://codereview.chromium.org/2624403002/diff/80001/media/audio/audio_input_controller.cc#newcode485 media/audio/audio_input_controller.cc:485: return; On 2017/01/16 10:02:14, Max Morin wrote: > Is ...
3 years, 11 months ago (2017-01-16 12:34:31 UTC) #58
tommi (sloooow) - chröme
> > What if AIC::Callback will own |sync_writer|? > > I considered that but didn't ...
3 years, 11 months ago (2017-01-16 12:43:29 UTC) #59
o1ka
lgtm % a couple of questions. https://codereview.chromium.org/2624403002/diff/140001/media/audio/audio_input_controller.cc File media/audio/audio_input_controller.cc (right): https://codereview.chromium.org/2624403002/diff/140001/media/audio/audio_input_controller.cc#newcode87 media/audio/audio_input_controller.cc:87: class AudioInputController::AudioCallback Could ...
3 years, 11 months ago (2017-01-16 15:04:52 UTC) #60
o1ka
https://codereview.chromium.org/2624403002/diff/140001/media/audio/audio_input_controller.cc File media/audio/audio_input_controller.cc (right): https://codereview.chromium.org/2624403002/diff/140001/media/audio/audio_input_controller.cc#newcode489 media/audio/audio_input_controller.cc:489: weak_ptr_factory_.InvalidateWeakPtrs(); On 2017/01/16 15:04:52, o1ka wrote: > We can ...
3 years, 11 months ago (2017-01-16 15:08:51 UTC) #61
o1ka
All in all, very nice improvement! Thank you!!
3 years, 11 months ago (2017-01-16 15:32:13 UTC) #62
tommi (sloooow) - chröme
Address comments
3 years, 11 months ago (2017-01-16 17:02:03 UTC) #63
tommi (sloooow) - chröme
https://codereview.chromium.org/2624403002/diff/140001/media/audio/audio_input_controller.cc File media/audio/audio_input_controller.cc (right): https://codereview.chromium.org/2624403002/diff/140001/media/audio/audio_input_controller.cc#newcode87 media/audio/audio_input_controller.cc:87: class AudioInputController::AudioCallback On 2017/01/16 15:04:52, o1ka wrote: > Could ...
3 years, 11 months ago (2017-01-16 17:02:33 UTC) #64
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2624403002/160001
3 years, 11 months ago (2017-01-16 17:03:14 UTC) #67
o1ka
On 2017/01/16 15:32:13, o1ka wrote: > All in all, very nice improvement! Thank you!! cc: ...
3 years, 11 months ago (2017-01-16 18:19:36 UTC) #68
commit-bot: I haz the power
3 years, 11 months ago (2017-01-16 18:35:59 UTC) #71
Message was sent while issue was closed.
Committed patchset #9 (id:160001) as
https://chromium.googlesource.com/chromium/src/+/ce9a2515fc22794d7beb2268eaae...

Powered by Google App Engine
This is Rietveld 408576698