Closed Bug 723428 Opened 12 years ago Closed 7 years ago

Audio cannot play() repetitively with short interval

Categories

(Core :: Audio/Video: Playback, defect)

Other
Gonk (Firefox OS)
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: timdream, Unassigned)

Details

Attachments

(1 file)

Attached file Testcase
See attachment.

I am working with audio feedback of the Gaia Keyboard, and the backspace key feedback needs to be fired every 100ms.

The resulted sound output does not play every 100ms, instead with much larger gaps feel close to 1 sec as the play() in between gets ignored.

Console warning generated:

W/AudioFlinger( 6835): write blocked for 105 msecs, 1 delayed writes, thread 0x61ac0
This is a bug, but you can work around with audio.cloneNode(false).play(); That should work fine, and is better practice in any case since you don't have to worry about your repeat interval being shorter than your audio clip.
(In reply to Ralph Giles (:rillian) from comment #1)
> This is a bug, but you can work around with audio.cloneNode(false).play();
> That should work fine, and is better practice in any case since you don't
> have to worry about your repeat interval being shorter than your audio clip.

Yeah that works. Thanks. I wonder why it failed the work the first time I tried it.

The audio is indeed shorter than the interval in fact. That's not the cause though.
You're probably getting stung by long drain times in e10s/Gonk/Android. Drain time is the duration of time between pushing the last audio sample to the audio hardware, and the audio hardware/software layer reporting that the audio has finished playing. On e10s, we just guess that, and sleep() for the estimated drain duration [1]. We're already do a sleep in the content/media code to work around drain bugs [2] and doing another sleep again in the e10s/Gonk/Android backends means the end time will lag on some platforms. Plus if you call play() before the drain has finished, the media will still be considered playing, so won't re-start playing anyway.


[1] http://mxr.mozilla.org/mozilla-central/source/media/libsydneyaudio/src/sydney_audio_gonk.cpp#380 
[2] http://mxr.mozilla.org/mozilla-central/source/content/media/nsBuiltinDecoderStateMachine.cpp#894
Component: Audio/Video → Audio/Video: Playback
I wonder if we should just close this as WONTFIX and ask people with the use case to use Web Audio API. FWIW, that's what Firefox OS Keyboard ended up using.
Flags: needinfo?(ajones)
Status: NEW → RESOLVED
Closed: 7 years ago
Flags: needinfo?(ajones)
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: