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

Issue 7661017: Refactor AudioInputDevice to remove race conditions and allow more flexible calling sequences. (Closed)

Created:
9 years, 4 months ago by henrika (OOO until Aug 14)
Modified:
9 years, 4 months ago
CC:
chromium-reviews, hclam+watch_chromium.org, ddorwin+watch_chromium.org, fischman+watch_chromium.org, jam, acolwell+watch_chromium.org, annacc+watch_chromium.org, joi+watch-content_chromium.org, ajwong+watch_chromium.org, vrk (LEFT CHROMIUM)
Visibility:
Public.

Description

Refactor AudioInputDevice to remove race conditions and allow more flexible calling sequences. It also ensures that the AudioInputDevice can be destroyed during an active audio session without crashing. This CL is a summary of http://codereview.chromium.org/7497025, i.e., it removes potential race conditions but in a more "lightweight" manner. BUG=none TEST=trybots Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=98198

Patch Set 1 #

Total comments: 10

Patch Set 2 : Adds wait timeout #

Patch Set 3 : Fixes spelling error #

Patch Set 4 : Fixes potential resource leak due to removed delegate before LowLatencyStreamCreated #

Patch Set 5 : Added TODO comment in AudioInputDevice #

Patch Set 6 : Removed Stop call in destructor. Added DCHECK instead. #

Total comments: 2

Patch Set 7 : Improved comments and added CHECK() macro in destructor #

Total comments: 17

Patch Set 8 : Minor changes based on review by Andrew #

Unified diffs Side-by-side diffs Delta from patch set Stats (+85 lines, -33 lines) Patch
M content/renderer/media/audio_input_device.h View 1 2 3 4 5 6 7 7 chunks +19 lines, -6 lines 0 comments Download
M content/renderer/media/audio_input_device.cc View 1 2 3 4 5 6 7 6 chunks +56 lines, -21 lines 0 comments Download
M content/renderer/media/audio_input_message_filter.cc View 1 2 3 4 5 6 7 2 chunks +7 lines, -4 lines 0 comments Download
M content/renderer/media/webrtc_audio_device_impl.cc View 1 2 3 4 5 6 7 1 chunk +3 lines, -2 lines 0 comments Download

Messages

Total messages: 22 (0 generated)
henrika (OOO until Aug 14)
This CL is an attempt to summarize all the proposed modifications of the AudioInputDevice. As ...
9 years, 4 months ago (2011-08-16 15:34:00 UTC) #1
wjia(left Chromium)
What's the likelihood to handle asynchronous event coming from browser process, such as "error"? On ...
9 years, 4 months ago (2011-08-17 00:30:46 UTC) #2
tommi (sloooow) - chröme
great! lgtm http://codereview.chromium.org/7661017/diff/1/content/renderer/media/audio_input_device.cc File content/renderer/media/audio_input_device.cc (right): http://codereview.chromium.org/7661017/diff/1/content/renderer/media/audio_input_device.cc#newcode92 content/renderer/media/audio_input_device.cc:92: void AudioInputDevice::InitializeOnIOThread(const AudioParameters& params) { DCHECK(MessageLoop::current() == ...
9 years, 4 months ago (2011-08-17 08:35:17 UTC) #3
tommi (sloooow) - chröme
On 2011/08/17 00:30:46, wjia wrote: > What's the likelihood to handle asynchronous event coming from ...
9 years, 4 months ago (2011-08-17 08:49:35 UTC) #4
henrika_dont_use
First the question from Wei. Yes, we might have to receive messages like OnStateChanged etc. ...
9 years, 4 months ago (2011-08-17 15:12:46 UTC) #5
henrika (OOO until Aug 14)
http://codereview.chromium.org/7661017/diff/1/content/renderer/media/audio_input_device.cc File content/renderer/media/audio_input_device.cc (right): http://codereview.chromium.org/7661017/diff/1/content/renderer/media/audio_input_device.cc#newcode92 content/renderer/media/audio_input_device.cc:92: void AudioInputDevice::InitializeOnIOThread(const AudioParameters& params) { On 2011/08/17 08:35:18, tommi ...
9 years, 4 months ago (2011-08-17 15:34:13 UTC) #6
no longer working on chromium
LGTM On 2011/08/17 15:34:13, henrika1 wrote: > http://codereview.chromium.org/7661017/diff/1/content/renderer/media/audio_input_device.cc > File content/renderer/media/audio_input_device.cc (right): > > http://codereview.chromium.org/7661017/diff/1/content/renderer/media/audio_input_device.cc#newcode92 ...
9 years, 4 months ago (2011-08-18 12:44:34 UTC) #7
wjia(left Chromium)
On 2011/08/17 15:12:46, henrika wrote: > First the question from Wei. Yes, we might have ...
9 years, 4 months ago (2011-08-18 14:28:11 UTC) #8
tommi (sloooow) - chröme
lgtm++ imho this fix is only temporary if the existing code was meant to be ...
9 years, 4 months ago (2011-08-18 14:52:23 UTC) #9
henrika (OOO until Aug 14)
Now also fixes race condition (resource leak) in AudioInputMessageFilter. I am not sure what to ...
9 years, 4 months ago (2011-08-18 15:21:00 UTC) #10
wjia(left Chromium)
On 2011/08/18 15:21:00, henrika1 wrote: > Now also fixes race condition (resource leak) in AudioInputMessageFilter. ...
9 years, 4 months ago (2011-08-18 16:06:02 UTC) #11
henrika (OOO until Aug 14)
I assume (and hope) that e.g. Pepper will use this class, yes. However, I fail ...
9 years, 4 months ago (2011-08-18 19:37:45 UTC) #12
no longer working on chromium
Thanks Wei, I believe this is going to be a really good discussion for the ...
9 years, 4 months ago (2011-08-18 19:38:41 UTC) #13
henrika (OOO until Aug 14)
Wei, I have added the TODO comment. Waiting for LGTM from you as an owner. ...
9 years, 4 months ago (2011-08-19 09:20:51 UTC) #14
wjia(left Chromium)
lgtm for now. Please do follow-up refactoring sooner than later. http://codereview.chromium.org/7661017/diff/18001/content/renderer/media/audio_input_device.cc File content/renderer/media/audio_input_device.cc (right): http://codereview.chromium.org/7661017/diff/18001/content/renderer/media/audio_input_device.cc#newcode43 ...
9 years, 4 months ago (2011-08-19 18:19:10 UTC) #15
henrika (OOO until Aug 14)
Added reply on why Stop was removed from dtor. http://codereview.chromium.org/7661017/diff/18001/content/renderer/media/audio_input_device.cc File content/renderer/media/audio_input_device.cc (right): http://codereview.chromium.org/7661017/diff/18001/content/renderer/media/audio_input_device.cc#newcode43 content/renderer/media/audio_input_device.cc:43: ...
9 years, 4 months ago (2011-08-19 22:07:05 UTC) #16
Chris Rogers
Hi Henrik, this looks good just looking over this quickly. I agree that it would ...
9 years, 4 months ago (2011-08-22 19:07:26 UTC) #17
scherkus (not reviewing)
LGTM w/ nits and a few questions what's the ETA on refactoring code? http://codereview.chromium.org/7661017/diff/22001/content/renderer/media/audio_input_device.cc File ...
9 years, 4 months ago (2011-08-23 16:54:19 UTC) #18
scherkus (not reviewing)
I've got a question about the Mock*ResourceContext classes but rest is LGTM
9 years, 4 months ago (2011-08-23 17:00:46 UTC) #19
henrika (OOO until Aug 14)
Andrew, I really don't understand your last comment. Does it apply to this patch?
9 years, 4 months ago (2011-08-23 19:32:18 UTC) #20
scherkus (not reviewing)
On 2011/08/23 19:32:18, henrika1 wrote: > Andrew, I really don't understand your last comment. Does ...
9 years, 4 months ago (2011-08-23 19:32:59 UTC) #21
henrika (OOO until Aug 14)
9 years, 4 months ago (2011-08-24 15:03:55 UTC) #22
Updated the patch based on input from Andrew.

http://codereview.chromium.org/7661017/diff/22001/content/renderer/media/audi...
File content/renderer/media/audio_input_device.cc (right):

http://codereview.chromium.org/7661017/diff/22001/content/renderer/media/audi...
content/renderer/media/audio_input_device.cc:16: // we will stop waiting and
return false. It ensures that Stop can't block
On 2011/08/23 16:54:19, scherkus wrote:
> Stop -> Stop()

Done.

http://codereview.chromium.org/7661017/diff/22001/content/renderer/media/audi...
content/renderer/media/audio_input_device.cc:18: static const base::TimeDelta
kMaxTimeOutMs =
Thanks. Done.

http://codereview.chromium.org/7661017/diff/22001/content/renderer/media/audi...
content/renderer/media/audio_input_device.cc:74: // with OnLowLatencyCreated and
to ensure that Stop acts as a synchronous
On 2011/08/23 16:54:19, scherkus wrote:
> don't forget () suffix on function call names in comments

Done.

http://codereview.chromium.org/7661017/diff/22001/content/renderer/media/audi...
content/renderer/media/audio_input_device.cc:76: if
(completion.TimedWait(kMaxTimeOutMs)) {
The calling client will be calling from the main render thread . Would work with
any worker thread actually. The timeout is probably overkill since the main
thread loop should be done when Join is called, hence the delay should be very
low. I added the timeout just in case.

http://codereview.chromium.org/7661017/diff/22001/content/renderer/media/audi...
content/renderer/media/audio_input_device.cc:82: // Ensures that we can call
Stop multiple times.
Well, we just want to ensure that the design can deal with it if a client (that
we can't control) calls Stop, Stop. This is one way of ensuring that the second
call "does nothing" and then returns true. Without the audio_thread_.reset(NULL)
we can't call Start()....Stop(),Stop() without crashing since we will try to
join a thread multiple times.

http://codereview.chromium.org/7661017/diff/22001/content/renderer/media/audi...
content/renderer/media/audio_input_device.cc:86: DLOG(ERROR) << "Failed to shut
down audio input on IO thread";
Very good question. Classic comment: "should never happen". Will add to LOG().

http://codereview.chromium.org/7661017/diff/22001/content/renderer/media/audi...
content/renderer/media/audio_input_device.cc:155: VLOG(1) << __FUNCTION__ <<
"[stream_id=" << stream_id_ << "]";
On 2011/08/23 16:54:19, scherkus wrote:
> use OnLowLatencyCreated ?

Done.

http://codereview.chromium.org/7661017/diff/22001/content/renderer/media/audi...
File content/renderer/media/audio_input_device.h (right):

http://codereview.chromium.org/7661017/diff/22001/content/renderer/media/audi...
content/renderer/media/audio_input_device.h:49: // - Start is
asynchronous/non-blocking.
On 2011/08/23 16:54:19, scherkus wrote:
> () by function names

Done.

Powered by Google App Engine
This is Rietveld 408576698