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

Issue 1166483002: Stop enqueueing data to output audio device if consecutive empty buffers are received (Closed)

Created:
5 years, 6 months ago by qinmin
Modified:
5 years, 6 months ago
CC:
chromium-reviews, feature-media-reviews_chromium.org, avayvod+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Stop enqueueing data to output audio device if consecutive empty buffers are received The current android implementation of WebAudio is not power friendly. It holds the AudioMix wakelock, and causes a lot of battery consumption even if tab is backgrounded. When an AudioContext is created, WebAudio will start enqueueing data to the output device. This happens even when no data is decoded or no audio buffer is appended. This CL let the OpenSLES player enter an idle mode when consecutive empty buffers are received. In the idle mode, the player will no longer enqueue data to the output device. It regularly check the received data and exits the idle mode if non-empty data are encountered. The intervals to check the data is calculated by the consumption time of the last received audio. This may introduce some drifting issues, but that's not as serious as the power consumption issue. BUG=470153

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+210 lines, -14 lines) Patch
M media/audio/android/audio_android_unittest.cc View 2 chunks +58 lines, -0 lines 0 comments Download
M media/audio/android/opensles_output.h View 4 chunks +48 lines, -2 lines 0 comments Download
M media/audio/android/opensles_output.cc View 11 chunks +83 lines, -12 lines 0 comments Download
M media/base/audio_bus.h View 1 chunk +3 lines, -0 lines 0 comments Download
M media/base/audio_bus.cc View 1 chunk +14 lines, -0 lines 0 comments Download
M media/base/audio_bus_unittest.cc View 4 chunks +4 lines, -0 lines 0 comments Download

Messages

Total messages: 14 (1 generated)
qinmin
PTAL
5 years, 6 months ago (2015-05-28 23:55:18 UTC) #2
DaleCurtis
I don't think this is the right layer to fix this at; it adds a ...
5 years, 6 months ago (2015-05-29 00:26:16 UTC) #3
qinmin
On 2015/05/29 00:26:16, DaleCurtis wrote: > I don't think this is the right layer to ...
5 years, 6 months ago (2015-05-29 04:28:38 UTC) #4
henrika (OOO until Aug 14)
I must agree with Dale here. If the goal is to come up with a ...
5 years, 6 months ago (2015-05-29 07:40:03 UTC) #5
qinmin
On 2015/05/29 07:40:03, henrika wrote: > I must agree with Dale here. If the goal ...
5 years, 6 months ago (2015-05-29 15:03:55 UTC) #6
henrika (OOO until Aug 14)
I would then argue that the WebAudio API is broken on Android and should be ...
5 years, 6 months ago (2015-05-29 15:21:00 UTC) #7
Raymond Toy
On 2015/05/29 15:21:00, henrika wrote: > I would then argue that the WebAudio API is ...
5 years, 6 months ago (2015-05-29 15:29:46 UTC) #8
henrika (OOO until Aug 14)
My point is that it feels as if this CL attacks the issue from the ...
5 years, 6 months ago (2015-05-29 15:48:45 UTC) #9
qinmin
On 2015/05/29 15:48:45, henrika wrote: > My point is that it feels as if this ...
5 years, 6 months ago (2015-05-29 18:11:29 UTC) #10
qinmin
On 2015/05/29 18:11:29, qinmin(OOO_till_6-5) wrote: > On 2015/05/29 15:48:45, henrika wrote: > > My point ...
5 years, 6 months ago (2015-05-29 18:15:42 UTC) #11
DaleCurtis
Even p0 this is the wrong place, we can put a block in WebAudio under ...
5 years, 6 months ago (2015-05-29 18:16:58 UTC) #12
henrika (OOO until Aug 14)
Agree with Dale. Adding this functionality to the native layer is not the right approach. ...
5 years, 6 months ago (2015-05-31 08:19:15 UTC) #13
qinmin
5 years, 6 months ago (2015-05-31 19:10:49 UTC) #14
On 2015/05/31 08:19:15, henrika wrote:
> Agree with Dale. Adding this functionality to the native layer is not the
right
> approach. It hides the actual problem and will make it difficult to maintain
and
> resolve issues related to audio playout on Android for other APIs.
> 
> In addition, adding more complexity to the callback handler is not a good idea
> since callback handlers are called from internal non-application thread(s)
which
> are not attached to the Dalvik virtual machine. And because these internal
> threads are critical to the integrity of the OpenSL ES implementation, a
> callback handler should not block or perform excessive work.

Unlike desktop platforms, I don't this starvation will have any adverse impact
on the integrity of OpenSL ES implementations.
And this is documented in the OpenSL ES document. The starvation state is
expected by OpenSL ES.
"When the player is in the SL_PLAYSTATE_PLAYING state, which is controlled by
the SLPlayItf interface [see section 8.32], adding buffers will implicitly start
playback. In the case of starvation due to insufficient buffers in the queue,
the playing of audio data stops. The player remains in the SL_PLAYSTATE_PLAYING
state. Upon queuing of additional buffers, the playing of audio data resumes.
Note that starvation of queued buffers causes audible gaps in the audio data
stream. In the case where the player is not in the playing state, addition of
buffers does not start audio playback."

Powered by Google App Engine
This is Rietveld 408576698