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

Issue 1703473002: Make AudioOutputDevice restartable and reinitializable (Closed)

Created:
4 years, 10 months ago by Henrik Grunell
Modified:
3 years, 9 months ago
CC:
chromium-reviews, darin-cc_chromium.org, feature-media-reviews_chromium.org, jam, mcasas+watch_chromium.org, miu+watch_chromium.org, mkwst+moarreviews-renderer_chromium.org, mlamouri+watch-content_chromium.org, posciak+watch_chromium.org, vanellope-cl_google.com
Base URL:
https://chromium.googlesource.com/chromium/src.git@new_mixing
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Make AudioOutputDevice restartable and reinitializable. * Changing the render callbacks to pass through AOD, only clearing the callback in Stop() and moving stopping of the audio thread to the IO thread. This serializes Initialize(), Start() and Stop() while ensuring no callbacks after Stop(). It also removed the stopping hack flag. * Device authorization is not touched in this CL, meaning it will reauthorize each restart. Following this, it would probably be good to cache the device authorization. This requires mostly browser side changes. BUG=607916

Patch Set 1 #

Total comments: 19

Patch Set 2 : Minor CR fixes. #

Patch Set 3 : Changes from olka@, adding callback lock, removing stopping hack, rebase. #

Total comments: 3

Patch Set 4 : Fixes, cleaning, and updated unit test. #

Patch Set 5 : git cl format #

Total comments: 36

Patch Set 6 : Code review (olka@) #

Patch Set 7 : Fixed use after free - clearing ADT callback and protect it with lock. #

Patch Set 8 : Fixed comments in olka@'s CL. Updated some comments. #

Total comments: 28

Patch Set 9 : Code review (guidou@). #

Total comments: 18

Patch Set 10 : Code review (olka@) + added more unit test cases. #

Patch Set 11 : Cleaning. #

Patch Set 12 : Code review (tommi@). #

Patch Set 13 : Rebase. #

Patch Set 14 : Added missing include. #

Total comments: 28

Patch Set 15 : Code review (tommi@). #

Total comments: 14

Patch Set 16 : Code review (dalecurtis@). #

Patch Set 17 : No thread re-use. Also rebase. #

Total comments: 13

Patch Set 18 : Code review fixes (dalecurtis@). #

Patch Set 19 : Back to stopping hack. #

Total comments: 6

Patch Set 20 : Code review (dalecurtis@). #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+330 lines, -73 lines) Patch
M media/audio/audio_output_device.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 9 chunks +23 lines, -14 lines 0 comments Download
M media/audio/audio_output_device.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 14 chunks +68 lines, -41 lines 6 comments Download
M media/audio/audio_output_device_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 10 chunks +239 lines, -18 lines 0 comments Download

Messages

Total messages: 55 (13 generated)
Henrik Grunell
I'd like input on how to handle the synchronization in AudioDeviceThread. I wonder if it ...
4 years, 10 months ago (2016-02-16 11:05:59 UTC) #4
tommi (sloooow) - chröme
Took a quick look but we should probably discuss this f2f to get a clearer ...
4 years, 10 months ago (2016-02-16 11:25:29 UTC) #5
Henrik Grunell
Yes, let's talk in person. https://codereview.chromium.org/1703473002/diff/1/media/audio/audio_device_thread.cc File media/audio/audio_device_thread.cc (right): https://codereview.chromium.org/1703473002/diff/1/media/audio/audio_device_thread.cc#newcode125 media/audio/audio_device_thread.cc:125: base::AutoLock auto_lock(thread_lock_); On 2016/02/16 ...
4 years, 10 months ago (2016-02-16 12:47:20 UTC) #6
o1ka
Just a couple of comments in addition to our offline discussion. Let's check with Tommi ...
4 years, 10 months ago (2016-02-17 09:46:29 UTC) #7
Henrik Grunell
Here's the new approach for ensuring no callbacks after Stop() when making AudioOutputDevice restartable. Also ...
4 years, 7 months ago (2016-04-29 14:34:55 UTC) #9
Henrik Grunell
Ptal now. Some more unit tests will be added. https://codereview.chromium.org/1703473002/diff/40001/media/audio/audio_device_thread.h File media/audio/audio_device_thread.h (right): https://codereview.chromium.org/1703473002/diff/40001/media/audio/audio_device_thread.h#newcode99 media/audio/audio_device_thread.h:99: ...
4 years, 7 months ago (2016-05-03 13:34:55 UTC) #12
o1ka
Haven't found any "restartable" problems so far, need to take another look tomorrow. https://codereview.chromium.org/1703473002/diff/80001/media/audio/audio_device_thread.cc File ...
4 years, 7 months ago (2016-05-03 15:47:32 UTC) #13
Henrik Grunell
Patch set 6 addresses Olga's comments. Still todo: add more test cases. Also I'll go ...
4 years, 7 months ago (2016-05-04 09:05:12 UTC) #14
Henrik Grunell
Patch set 7 fixes a use-after-free error. Patch set 8 addresses comments in olka@'s CL, ...
4 years, 7 months ago (2016-05-09 12:15:43 UTC) #15
Guido Urdaneta
just a few minor comments. Have to do another round. https://codereview.chromium.org/1703473002/diff/140001/media/audio/audio_device_thread.cc File media/audio/audio_device_thread.cc (right): https://codereview.chromium.org/1703473002/diff/140001/media/audio/audio_device_thread.cc#newcode71 ...
4 years, 7 months ago (2016-05-09 13:15:50 UTC) #16
Henrik Grunell
https://codereview.chromium.org/1703473002/diff/140001/media/audio/audio_device_thread.cc File media/audio/audio_device_thread.cc (right): https://codereview.chromium.org/1703473002/diff/140001/media/audio/audio_device_thread.cc#newcode71 media/audio/audio_device_thread.cc:71: // Start(), Resume(), Pause() must be serialized; Stop() can ...
4 years, 7 months ago (2016-05-09 13:46:20 UTC) #17
o1ka
Nice, looking forward to updated tests. https://codereview.chromium.org/1703473002/diff/160001/media/audio/audio_device_thread.cc File media/audio/audio_device_thread.cc (left): https://codereview.chromium.org/1703473002/diff/160001/media/audio/audio_device_thread.cc#oldcode69 media/audio/audio_device_thread.cc:69: // AudioDeviceThread implementation ...
4 years, 7 months ago (2016-05-10 13:04:54 UTC) #18
Henrik Grunell
https://codereview.chromium.org/1703473002/diff/160001/media/audio/audio_device_thread.cc File media/audio/audio_device_thread.cc (left): https://codereview.chromium.org/1703473002/diff/160001/media/audio/audio_device_thread.cc#oldcode69 media/audio/audio_device_thread.cc:69: // AudioDeviceThread implementation On 2016/05/10 13:04:53, o1ka wrote: > ...
4 years, 7 months ago (2016-05-11 13:11:16 UTC) #19
tommi (sloooow) - chröme
just noticed that I have a few comments sitting in draft. Sending them out now ...
4 years, 7 months ago (2016-05-11 14:12:34 UTC) #20
Henrik Grunell
https://codereview.chromium.org/1703473002/diff/140001/media/audio/audio_device_thread.cc File media/audio/audio_device_thread.cc (right): https://codereview.chromium.org/1703473002/diff/140001/media/audio/audio_device_thread.cc#newcode59 media/audio/audio_device_thread.cc:59: enum State { kStatePaused, kStatePlaying, kStateStopped }; On 2016/05/11 ...
4 years, 7 months ago (2016-05-12 12:00:09 UTC) #21
Henrik Grunell
Tommi, can you take a good look at if there's concurrency issues? Since Olga also ...
4 years, 7 months ago (2016-05-12 12:02:25 UTC) #22
tommi (sloooow) - chröme
https://codereview.chromium.org/1703473002/diff/250001/media/audio/audio_device_thread.cc File media/audio/audio_device_thread.cc (right): https://codereview.chromium.org/1703473002/diff/250001/media/audio/audio_device_thread.cc#newcode40 media/audio/audio_device_thread.cc:40: // called to actually start running it. Can we ...
4 years, 7 months ago (2016-05-14 11:06:28 UTC) #23
Henrik Grunell
https://codereview.chromium.org/1703473002/diff/250001/media/audio/audio_device_thread.cc File media/audio/audio_device_thread.cc (right): https://codereview.chromium.org/1703473002/diff/250001/media/audio/audio_device_thread.cc#newcode40 media/audio/audio_device_thread.cc:40: // called to actually start running it. On 2016/05/14 ...
4 years, 7 months ago (2016-05-16 14:37:36 UTC) #24
Henrik Grunell
Ping Tommi.
4 years, 7 months ago (2016-05-17 13:05:01 UTC) #25
tommi (sloooow) - chröme
lgtm. Would be good to do a follow up change soon that removes the extra ...
4 years, 7 months ago (2016-05-17 14:09:13 UTC) #26
DaleCurtis
https://codereview.chromium.org/1703473002/diff/270001/media/audio/audio_device_thread.cc File media/audio/audio_device_thread.cc (right): https://codereview.chromium.org/1703473002/diff/270001/media/audio/audio_device_thread.cc#newcode60 media/audio/audio_device_thread.cc:60: enum State { STATE_SUSPENDED, STATE_PLAYING, STATE_STOPPED }; Instead of ...
4 years, 7 months ago (2016-05-17 17:54:36 UTC) #28
Henrik Grunell
Addressed Dale's comments. https://codereview.chromium.org/1703473002/diff/270001/media/audio/audio_device_thread.cc File media/audio/audio_device_thread.cc (right): https://codereview.chromium.org/1703473002/diff/270001/media/audio/audio_device_thread.cc#newcode60 media/audio/audio_device_thread.cc:60: enum State { STATE_SUSPENDED, STATE_PLAYING, STATE_STOPPED ...
4 years, 7 months ago (2016-05-18 12:21:32 UTC) #30
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1703473002/290001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1703473002/290001
4 years, 7 months ago (2016-05-18 12:25:45 UTC) #32
Henrik Grunell
On 2016/05/17 14:09:13, tommi-chrömium wrote: > lgtm. Would be good to do a follow up ...
4 years, 7 months ago (2016-05-18 12:33:39 UTC) #33
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
4 years, 7 months ago (2016-05-18 13:44:26 UTC) #35
DaleCurtis
https://codereview.chromium.org/1703473002/diff/270001/media/audio/audio_device_thread.cc File media/audio/audio_device_thread.cc (right): https://codereview.chromium.org/1703473002/diff/270001/media/audio/audio_device_thread.cc#newcode248 media/audio/audio_device_thread.cc:248: while (state_ == STATE_SUSPENDED) { On 2016/05/18 at 12:21:32, ...
4 years, 7 months ago (2016-05-18 17:20:43 UTC) #36
Henrik Grunell
https://codereview.chromium.org/1703473002/diff/270001/media/audio/audio_device_thread.cc File media/audio/audio_device_thread.cc (right): https://codereview.chromium.org/1703473002/diff/270001/media/audio/audio_device_thread.cc#newcode248 media/audio/audio_device_thread.cc:248: while (state_ == STATE_SUSPENDED) { On 2016/05/18 17:20:43, DaleCurtis ...
4 years, 7 months ago (2016-05-19 13:03:11 UTC) #37
DaleCurtis
https://codereview.chromium.org/1703473002/diff/270001/media/audio/audio_device_thread.cc File media/audio/audio_device_thread.cc (right): https://codereview.chromium.org/1703473002/diff/270001/media/audio/audio_device_thread.cc#newcode248 media/audio/audio_device_thread.cc:248: while (state_ == STATE_SUSPENDED) { On 2016/05/19 at 13:03:11, ...
4 years, 7 months ago (2016-05-19 20:41:00 UTC) #38
Henrik Grunell
https://codereview.chromium.org/1703473002/diff/270001/media/audio/audio_device_thread.cc File media/audio/audio_device_thread.cc (right): https://codereview.chromium.org/1703473002/diff/270001/media/audio/audio_device_thread.cc#newcode248 media/audio/audio_device_thread.cc:248: while (state_ == STATE_SUSPENDED) { On 2016/05/19 20:41:00, DaleCurtis ...
4 years, 7 months ago (2016-05-23 11:41:58 UTC) #39
Henrik Grunell
Removed the thread re-use. This CL will be followed by a CL that instead changes ...
4 years, 6 months ago (2016-06-09 15:43:29 UTC) #40
DaleCurtis
https://codereview.chromium.org/1703473002/diff/310001/media/audio/audio_output_device.cc File media/audio/audio_output_device.cc (right): https://codereview.chromium.org/1703473002/diff/310001/media/audio/audio_output_device.cc#newcode115 media/audio/audio_output_device.cc:115: DCHECK(audio_thread_.IsStopped()); This won't be true with the code you ...
4 years, 6 months ago (2016-06-09 22:37:27 UTC) #42
Henrik Grunell
Trying to answer the questions, and added a thread checker. https://codereview.chromium.org/1703473002/diff/310001/media/audio/audio_output_device.cc File media/audio/audio_output_device.cc (right): https://codereview.chromium.org/1703473002/diff/310001/media/audio/audio_output_device.cc#newcode115 ...
4 years, 6 months ago (2016-06-13 13:43:43 UTC) #43
DaleCurtis
It's not clear why you're extending RenderCallback in this class. I understand you need to ...
4 years, 6 months ago (2016-06-13 18:52:32 UTC) #44
Henrik Grunell
Ah right, you mean the Callback wrapper Process(). Yep, that makes sense to deal with ...
4 years, 6 months ago (2016-06-13 20:12:20 UTC) #45
DaleCurtis
On 2016/06/13 at 20:12:20, grunell wrote: > Ah right, you mean the Callback wrapper Process(). ...
4 years, 6 months ago (2016-06-13 20:39:11 UTC) #46
Henrik Grunell
On 2016/06/13 20:39:11, DaleCurtis wrote: > On 2016/06/13 at 20:12:20, grunell wrote: > > Ah ...
4 years, 6 months ago (2016-06-13 20:47:49 UTC) #47
Henrik Grunell
And now back to stopping hack... So, I haven't found any issues with this. Please ...
4 years, 6 months ago (2016-06-15 13:15:17 UTC) #49
DaleCurtis
I think there is even more you can revert out of this patch set to ...
4 years, 6 months ago (2016-06-15 16:51:42 UTC) #51
Henrik Grunell
https://codereview.chromium.org/1703473002/diff/390001/media/audio/audio_output_device.cc File media/audio/audio_output_device.cc (right): https://codereview.chromium.org/1703473002/diff/390001/media/audio/audio_output_device.cc#newcode85 media/audio/audio_output_device.cc:85: thread_checker_.DetachFromThread(); On 2016/06/15 16:51:41, DaleCurtis wrote: > Needs a ...
4 years, 6 months ago (2016-06-16 12:39:42 UTC) #52
DaleCurtis
https://codereview.chromium.org/1703473002/diff/410001/media/audio/audio_output_device.cc File media/audio/audio_output_device.cc (right): https://codereview.chromium.org/1703473002/diff/410001/media/audio/audio_output_device.cc#newcode95 media/audio/audio_output_device.cc:95: { Drop the lock? DCHECK(!thread.started()) ? https://codereview.chromium.org/1703473002/diff/410001/media/audio/audio_output_device.cc#newcode284 media/audio/audio_output_device.cc:284: base::AutoLock ...
4 years, 6 months ago (2016-06-16 16:39:14 UTC) #53
Henrik Grunell
https://codereview.chromium.org/1703473002/diff/410001/media/audio/audio_output_device.cc File media/audio/audio_output_device.cc (right): https://codereview.chromium.org/1703473002/diff/410001/media/audio/audio_output_device.cc#newcode95 media/audio/audio_output_device.cc:95: { On 2016/06/16 16:39:14, DaleCurtis wrote: > Drop the ...
4 years, 6 months ago (2016-06-16 20:23:00 UTC) #54
DaleCurtis
4 years, 6 months ago (2016-06-16 22:00:54 UTC) #55
Your CL inspired me to do this https://codereview.chromium.org/2076793002 --
which might clean some things up for you in this one.

https://codereview.chromium.org/1703473002/diff/410001/media/audio/audio_outp...
File media/audio/audio_output_device.cc (right):

https://codereview.chromium.org/1703473002/diff/410001/media/audio/audio_outp...
media/audio/audio_output_device.cc:142: void AudioOutputDevice::Pause() {
Note: This is called from the Render thread by RendererWebAudioDeviceImpl. So
you should probably say something explicit about the fact that it's okay to call
Play()/Pause() from any thread, but Start()/Stop() must be called from the same
thread...

https://codereview.chromium.org/1703473002/diff/410001/media/audio/audio_outp...
media/audio/audio_output_device.cc:284: base::AutoLock auto_lock_(lock_);
On 2016/06/16 at 20:23:00, Henrik Grunell wrote:
> On 2016/06/16 16:39:14, DaleCurtis wrote:
> > I'm worried this can deadlock now. You're waiting for the render thread to
stop,
> > but something on the render thread might be waiting for the lock.
> 
> This lock is never grabbed on the audio render thread. Only the control
(typically main render) thread and IO thread. Do you find a concrete case? I'll
add a thread check in ReportRenderError, and maybe change name. It should only
be called on IO thread.

No, I had forgotten we're not using your old patch that added a lock there.

Powered by Google App Engine
This is Rietveld 408576698