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

Issue 8440002: Low-latency AudioOutputStream implementation based on WASAPI for Windows. (Closed)

Created:
9 years, 1 month ago by henrika (OOO until Aug 14)
Modified:
9 years, 1 month ago
CC:
chromium-reviews, hclam+watch_chromium.org, ddorwin+watch_chromium.org, fischman+watch_chromium.org, jam, Paweł Hajdan Jr., acolwell+watch_chromium.org, annacc+watch_chromium.org, dpranke-watch+content_chromium.org, joi+watch-content_chromium.org, darin-cc_chromium.org, ajwong+watch_chromium.org, vrk (LEFT CHROMIUM), scherkus (not reviewing), ihf+watch_chromium.org, Raymond Toy (Google)
Visibility:
Public.

Description

Low-latency AudioOutputStream implementation based on WASAPI for Windows. BUG=none TEST=audio_low_latency_output_win_unittest.cc Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=110282

Patch Set 1 #

Total comments: 2

Patch Set 2 : Modified buffer handling and improved unit test #

Total comments: 79

Patch Set 3 : Modifications based on review by Niklas and Raymond #

Patch Set 4 : Modifications based on review by Tommi and Pawel #

Patch Set 5 : Now writes test log-file to FILE_EXE path instead #

Patch Set 6 : Changes based on review by Tommi #

Patch Set 7 : Improved comments about thread handling #

Total comments: 2

Patch Set 8 : Minor fix in unit test #

Total comments: 6

Patch Set 9 : Takes input from Andrew into account #

Patch Set 10 : nits #

Patch Set 11 : Modified buffer sizes to match WebAudio for all sample rates #

Patch Set 12 : rebased #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1513 lines, -117 lines) Patch
M content/renderer/media/webrtc_audio_device_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 23 chunks +125 lines, -96 lines 0 comments Download
M media/audio/audio_util.cc View 1 2 3 4 5 6 7 8 9 10 11 4 chunks +32 lines, -11 lines 0 comments Download
A media/audio/win/audio_low_latency_output_win.h View 1 2 3 4 5 6 1 chunk +206 lines, -0 lines 0 comments Download
A media/audio/win/audio_low_latency_output_win.cc View 1 2 3 4 5 6 7 1 chunk +601 lines, -0 lines 0 comments Download
A media/audio/win/audio_low_latency_output_win_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +528 lines, -0 lines 0 comments Download
M media/audio/win/audio_manager_win.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -1 line 0 comments Download
M media/audio/win/audio_manager_win.cc View 1 2 3 4 5 6 7 8 9 10 11 4 chunks +13 lines, -5 lines 0 comments Download
M media/media.gyp View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +7 lines, -4 lines 0 comments Download
A media/test/data/speech_16b_stereo_44kHz.raw View Binary file 0 comments Download
A media/test/data/speech_16b_stereo_48kHz.raw View Binary file 0 comments Download

Messages

Total messages: 60 (0 generated)
henrika (OOO until Aug 14)
I have now uploaded an initial version of a low-latency audio output implementation based on ...
9 years, 1 month ago (2011-11-01 17:02:26 UTC) #1
Paweł Hajdan Jr.
Drive-by with a test comment. http://codereview.chromium.org/8440002/diff/1/media/audio/win/audio_low_latency_output_win_unittest.cc File media/audio/win/audio_low_latency_output_win_unittest.cc (right): http://codereview.chromium.org/8440002/diff/1/media/audio/win/audio_low_latency_output_win_unittest.cc#newcode358 media/audio/win/audio_low_latency_output_win_unittest.cc:358: base::PlatformThread::Sleep(2 * TestTimeouts::tiny_timeout_ms()); Please ...
9 years, 1 month ago (2011-11-02 09:36:58 UTC) #2
Chris Rogers
Hi Henrik, I'm really looking forward to trying this patch out. Thanks for working on ...
9 years, 1 month ago (2011-11-02 19:22:17 UTC) #3
Chris Rogers
+rtoy
9 years, 1 month ago (2011-11-02 19:23:23 UTC) #4
henrika (OOO until Aug 14)
Hi Chris, thanks for your input; now I understand better what you would like. I ...
9 years, 1 month ago (2011-11-02 19:42:42 UTC) #5
henrika (OOO until Aug 14)
I meant "ask for a hardware buffer size".
9 years, 1 month ago (2011-11-02 19:46:19 UTC) #6
Chris Rogers
Hi Henrik, now I remember - Ray wrote that code. Basically, what he's doing is ...
9 years, 1 month ago (2011-11-02 20:16:08 UTC) #7
henrika (OOO until Aug 14)
Got it, thanks. I will try to give definite answer on the buffer size after ...
9 years, 1 month ago (2011-11-02 22:27:20 UTC) #8
Chris Rogers
Henrik, thanks for the detailed response - some questions below: On 2011/11/02 22:27:20, henrika1 wrote: ...
9 years, 1 month ago (2011-11-03 00:00:47 UTC) #9
henrika (OOO until Aug 14)
http://codereview.chromium.org/8440002/diff/1/media/audio/win/audio_low_latency_output_win_unittest.cc File media/audio/win/audio_low_latency_output_win_unittest.cc (right): http://codereview.chromium.org/8440002/diff/1/media/audio/win/audio_low_latency_output_win_unittest.cc#newcode358 media/audio/win/audio_low_latency_output_win_unittest.cc:358: base::PlatformThread::Sleep(2 * TestTimeouts::tiny_timeout_ms()); Modified the design. Now waits for ...
9 years, 1 month ago (2011-11-03 15:03:34 UTC) #10
Raymond Toy (Google)
Henrik, I'm trying to build chrome with your patch now. I must be missing some ...
9 years, 1 month ago (2011-11-03 15:07:05 UTC) #11
henrika (OOO until Aug 14)
Ray, can you try to clean everything first and then rebuild. Also, please try the ...
9 years, 1 month ago (2011-11-03 15:18:08 UTC) #12
Niklas Enbom
http://codereview.chromium.org/8440002/diff/7001/media/audio/win/audio_low_latency_output_win.cc File media/audio/win/audio_low_latency_output_win.cc (right): http://codereview.chromium.org/8440002/diff/7001/media/audio/win/audio_low_latency_output_win.cc#newcode136 media/audio/win/audio_low_latency_output_win.cc:136: render_thread_->Start(); Why start the thread already here? What if ...
9 years, 1 month ago (2011-11-03 15:32:08 UTC) #13
henrika (OOO until Aug 14)
I have now modified the unit test and the buffer handling. This link: https://docs.google.com/a/google.com/open?id=0BzQCvp_q8wgiYWFjZmNlYTAtM2E0YS00NTNkLTkzNjQtYmZjNDJlOTkxODUw contains ...
9 years, 1 month ago (2011-11-03 15:33:26 UTC) #14
henrika (OOO until Aug 14)
Just verified that this patch builds with revision 107928.
9 years, 1 month ago (2011-11-03 15:39:19 UTC) #15
Niklas Enbom
http://codereview.chromium.org/8440002/diff/7001/media/audio/win/audio_low_latency_output_win.cc File media/audio/win/audio_low_latency_output_win.cc (right): http://codereview.chromium.org/8440002/diff/7001/media/audio/win/audio_low_latency_output_win.cc#newcode387 media/audio/win/audio_low_latency_output_win.cc:387: (packet_size_bytes_ - num_filled_bytes)); Why, since silence is better than ...
9 years, 1 month ago (2011-11-03 15:46:46 UTC) #16
Raymond Toy (Google)
http://codereview.chromium.org/8440002/diff/7001/media/audio/win/audio_low_latency_output_win.cc File media/audio/win/audio_low_latency_output_win.cc (right): http://codereview.chromium.org/8440002/diff/7001/media/audio/win/audio_low_latency_output_win.cc#newcode50 media/audio/win/audio_low_latency_output_win.cc:50: packet_size_frames_ = params.GetPacketSize() / format_.nBlockAlign; Is it possible for ...
9 years, 1 month ago (2011-11-03 22:49:56 UTC) #17
Raymond Toy (Google)
On Thu, Nov 3, 2011 at 8:18 AM, <henrika@chromium.org> wrote: > Ray, > > can ...
9 years, 1 month ago (2011-11-04 02:43:33 UTC) #18
henrika_dont_use
I would recommend that you start with the new unit test to ensure that the ...
9 years, 1 month ago (2011-11-04 08:50:09 UTC) #19
henrika (OOO until Aug 14)
Answered all comments and questions. Will upload modified patch on Monday since I don't want ...
9 years, 1 month ago (2011-11-04 11:26:15 UTC) #20
Paweł Hajdan Jr.
Code I commented in the drive-by LGTM with comments. http://codereview.chromium.org/8440002/diff/7001/media/audio/win/audio_low_latency_output_win_unittest.cc File media/audio/win/audio_low_latency_output_win_unittest.cc (right): http://codereview.chromium.org/8440002/diff/7001/media/audio/win/audio_low_latency_output_win_unittest.cc#newcode67 media/audio/win/audio_low_latency_output_win_unittest.cc:67: ...
9 years, 1 month ago (2011-11-04 11:32:11 UTC) #21
Raymond Toy (Google)
http://codereview.chromium.org/8440002/diff/7001/media/audio/win/audio_low_latency_output_win.cc File media/audio/win/audio_low_latency_output_win.cc (right): http://codereview.chromium.org/8440002/diff/7001/media/audio/win/audio_low_latency_output_win.cc#newcode50 media/audio/win/audio_low_latency_output_win.cc:50: packet_size_frames_ = params.GetPacketSize() / format_.nBlockAlign; On 2011/11/04 11:26:15, henrika1 ...
9 years, 1 month ago (2011-11-04 16:58:02 UTC) #22
tommi (sloooow) - chröme
http://codereview.chromium.org/8440002/diff/7001/media/audio/audio_util.cc File media/audio/audio_util.cc (right): http://codereview.chromium.org/8440002/diff/7001/media/audio/audio_util.cc#newcode241 media/audio/audio_util.cc:241: double GetAudioHardwareSampleRate() { should we have a DCHECK here ...
9 years, 1 month ago (2011-11-07 11:47:03 UTC) #23
henrika (OOO until Aug 14)
http://codereview.chromium.org/8440002/diff/7001/media/audio/win/audio_low_latency_output_win.cc File media/audio/win/audio_low_latency_output_win.cc (right): http://codereview.chromium.org/8440002/diff/7001/media/audio/win/audio_low_latency_output_win.cc#newcode387 media/audio/win/audio_low_latency_output_win.cc:387: (packet_size_bytes_ - num_filled_bytes)); Modified the comment. http://codereview.chromium.org/8440002/diff/7001/media/audio/win/audio_low_latency_output_win.cc#newcode452 media/audio/win/audio_low_latency_output_win.cc:452: return ...
9 years, 1 month ago (2011-11-07 12:37:40 UTC) #24
henrika (OOO until Aug 14)
Comments and changes based on review by Tommi and Pawel. http://codereview.chromium.org/8440002/diff/7001/media/audio/win/audio_low_latency_output_win_unittest.cc File media/audio/win/audio_low_latency_output_win_unittest.cc (right): http://codereview.chromium.org/8440002/diff/7001/media/audio/win/audio_low_latency_output_win_unittest.cc#newcode67 ...
9 years, 1 month ago (2011-11-07 14:09:45 UTC) #25
henrika (OOO until Aug 14)
Status: - Need review from Chris and Andrew. - Need final OK from Niklas, Raymond ...
9 years, 1 month ago (2011-11-07 15:12:11 UTC) #26
Niklas Enbom
I've only looked at the overall structure and usage of WASAPI. lgtm On 2011/11/07 15:12:11, ...
9 years, 1 month ago (2011-11-07 15:19:17 UTC) #27
tommi (sloooow) - chröme
LGTM with the ask to take another quick look at my previous set of comments ...
9 years, 1 month ago (2011-11-07 17:37:17 UTC) #28
Chris Rogers
Henrik, we're still testing your patch with Web Audio, so please don't land this until ...
9 years, 1 month ago (2011-11-07 18:31:08 UTC) #29
henrika_dont_use
I had no intentions to land before OK from you guys. Main thing is that ...
9 years, 1 month ago (2011-11-07 18:52:21 UTC) #30
Raymond Toy (Google)
On Thu, Nov 3, 2011 at 7:43 PM, Raymond Toy <rtoy@google.com> wrote: > > > ...
9 years, 1 month ago (2011-11-07 19:05:26 UTC) #31
henrika_dont_use
> > Henrik, you had said some webaudio demos crash the current code. Can you ...
9 years, 1 month ago (2011-11-07 19:16:41 UTC) #32
henrika (OOO until Aug 14)
Added in Patch Set #6. http://codereview.chromium.org/8440002/diff/7001/media/audio/audio_util.cc File media/audio/audio_util.cc (right): http://codereview.chromium.org/8440002/diff/7001/media/audio/audio_util.cc#newcode241 media/audio/audio_util.cc:241: double GetAudioHardwareSampleRate() { Not ...
9 years, 1 month ago (2011-11-08 12:18:37 UTC) #33
tommi (sloooow) - chröme
Excellent work! I don't see any issues with the code as is but will wait ...
9 years, 1 month ago (2011-11-08 12:46:16 UTC) #34
henrika (OOO until Aug 14)
I don't see any issues with the code as is but will wait with my ...
9 years, 1 month ago (2011-11-08 14:52:06 UTC) #35
henrika (OOO until Aug 14)
http://codereview.chromium.org/8440002/diff/35001/media/audio/win/audio_low_latency_output_win_unittest.cc File media/audio/win/audio_low_latency_output_win_unittest.cc (right): http://codereview.chromium.org/8440002/diff/35001/media/audio/win/audio_low_latency_output_win_unittest.cc#newcode87 media/audio/win/audio_low_latency_output_win_unittest.cc:87: CHECK(PathService::Get(base::DIR_EXE, &file_name)); On 2011/11/08 12:46:17, tommi wrote: > I ...
9 years, 1 month ago (2011-11-08 14:52:16 UTC) #36
scherkus (not reviewing)
LGTM w/ nits http://codereview.chromium.org/8440002/diff/31005/media/audio/audio_util.cc File media/audio/audio_util.cc (right): http://codereview.chromium.org/8440002/diff/31005/media/audio/audio_util.cc#newcode250 media/audio/audio_util.cc:250: } else { nit: no need ...
9 years, 1 month ago (2011-11-08 23:52:21 UTC) #37
henrika (OOO until Aug 14)
http://codereview.chromium.org/8440002/diff/31005/media/audio/audio_util.cc File media/audio/audio_util.cc (right): http://codereview.chromium.org/8440002/diff/31005/media/audio/audio_util.cc#newcode250 media/audio/audio_util.cc:250: } else { On 2011/11/08 23:52:21, scherkus wrote: > ...
9 years, 1 month ago (2011-11-09 13:59:22 UTC) #38
tommi (sloooow) - chröme
lgtm
9 years, 1 month ago (2011-11-09 14:02:30 UTC) #39
henrika (OOO until Aug 14)
Chris and Ray: I need OK from you as well before I can submit.
9 years, 1 month ago (2011-11-09 14:04:29 UTC) #40
Raymond Toy (Google)
LGTM, except for one issue. Your current changes break webaudio because you use a buffer ...
9 years, 1 month ago (2011-11-09 17:10:41 UTC) #41
henrika_dont_use
If it is possible to adapt the WebAudio layer to take into account that shared ...
9 years, 1 month ago (2011-11-09 17:31:10 UTC) #42
Raymond Toy (Google)
It should handle both 441 and 960 and anything else up to some limit. 441 ...
9 years, 1 month ago (2011-11-09 17:36:41 UTC) #43
henrika_dont_use
Note that the real latency is not 10ms just because the buffer size is 10. ...
9 years, 1 month ago (2011-11-09 20:23:03 UTC) #44
Chris Rogers
Yes, that's what I thought as well. I tried this out on Ray's machine (with ...
9 years, 1 month ago (2011-11-09 20:28:46 UTC) #45
henrika_dont_use
Yes, compared with Wave the difference is substantial, especially with the existing implementation in Chrome. ...
9 years, 1 month ago (2011-11-09 21:46:15 UTC) #46
Raymond Toy (Google)
I've run through a bunch of webaudio listening tests, and I haven't found any audio ...
9 years, 1 month ago (2011-11-10 00:02:16 UTC) #47
henrika_dont_use
Ray, we should try to solve all potential issues now. I am not able to ...
9 years, 1 month ago (2011-11-10 11:27:36 UTC) #48
Chris Rogers
On 2011/11/10 11:27:36, henrika wrote: > Ray, > > we should try to solve all ...
9 years, 1 month ago (2011-11-10 19:04:03 UTC) #49
Raymond Toy (Google)
> > > Actually, I think 448 would work better for our FIFO buffering, since ...
9 years, 1 month ago (2011-11-10 19:51:32 UTC) #50
henrika_dont_use
On Thu, Nov 10, 2011 at 8:04 PM, <crogers@google.com> wrote: > On 2011/11/10 11:27:36, henrika ...
9 years, 1 month ago (2011-11-10 20:04:23 UTC) #51
Raymond Toy (Google)
On Thu, Nov 10, 2011 at 12:03 PM, Henrik Andreasson <henrika@google.com>wrote: > > I found ...
9 years, 1 month ago (2011-11-11 17:55:35 UTC) #52
henrika_dont_use
Great. Just in case, please provide the buffer size you want for 44.1, 48 and ...
9 years, 1 month ago (2011-11-11 18:41:02 UTC) #53
Raymond Toy (Google)
I think 448 for 441. is good. Your defaults for 48 and 96 should be ...
9 years, 1 month ago (2011-11-11 21:26:49 UTC) #54
henrika_dont_use
"I don't quite understand what 448 really means though. Does that mean wasapi just want ...
9 years, 1 month ago (2011-11-13 18:27:13 UTC) #55
henrika (OOO until Aug 14)
Patch #11 adds new buffer sizes. Chris, still need your OK. I will not commit ...
9 years, 1 month ago (2011-11-14 07:59:57 UTC) #56
Chris Rogers
Henrik, thanks for your patience. Ray's patch is essentially ready to go - just waiting ...
9 years, 1 month ago (2011-11-14 16:52:56 UTC) #57
henrika_dont_use
Great, please ping me as soon as I can submit. Thanks. On Mon, Nov 14, ...
9 years, 1 month ago (2011-11-14 18:04:38 UTC) #58
Raymond Toy (Google)
I'll be sure to let you know. Thank you so much for your patience! Ray ...
9 years, 1 month ago (2011-11-14 22:58:37 UTC) #59
Raymond Toy (Google)
9 years, 1 month ago (2011-11-14 23:02:53 UTC) #60
Thanks for the nice explanation.  I think I understand now.

Ray


On Sun, Nov 13, 2011 at 10:26 AM, Henrik Andreasson <henrika@google.com>wrote:

> "I don't quite understand what 448 really means though.  Does that mean
> wasapi just want 448 samples at a time, but will deliver those 448 samples
> to the hardware at a 44.1 kHz rate?  (So some kind of internal buffering is
> being done?)"
>
> Ray,
>
> I'll do my best to answer but I don't have a perfect answer. For exclusive
> mode WASAPI, I can picture the exact buffer handling but not for shared
> mode (which we must use since an exclusive app. can "take over" the
> complete audio path and "throw out" all others). In shared mode, some
> "magic" is involved and I can't explain exactly how it works. All we can do
> is to analyze how it works and adapt accordingly.
>
> I ask for the "smallest glitch-free buffer size the API can provide", and
> as a result I get 960 audio frames for 48kHz and 896 for 44.1 (don't ask me
> why). Also, the time granularity given to me is 10.1578 ms, i.e, events
> will be pulsed at this rate. If we have selected 448 as buffer size, each
> event will ask for exactly this size and the engine will run in a "clean"
> way. If we use 441 samples instead, a complex internal buffer scheme must
> be used since the API "runs at" 10.1578 ms and we ask for 10ms. It works
> but at some moments the complete internal 20ms buffer will run dry and we
> must ask for two 10ms packets in a row. That is when we see dTs of 0ms for
> 441 as buffer size.
>

Powered by Google App Engine
This is Rietveld 408576698