nsAudioStream consumers expect Write to block when the backend audio buffer is full, and rely on this behaviour to put audio refill threads to sleep until buffer space becomes available.
nsRemotedAudio's Write does not block, and currently has no knowledge of how full the audio stream's buffers it is remoting to actually are.
I don't plan to work on this anytime soon. The NativeUI Fennec project for Android is single process, which means we can use sydneyaudio (and future audio APIs) directly without the remoted nsAudioStream.
So I don't forget: Oleg's media bridge patch in bug 598868 is useful for pointers on how to do non-main-thread IPC bridging, which would make fixing this bug much simpler by allowing Write() to be an synchronous inter-audio-thread call.
This would be quite easy to do. We might want this for b2g.
Created attachment 638266 [details] [diff] [review]
This is kind of a crummy fix, but we already use this technique to make Drain() blocking, so it's super simple to reuse it for Write.
I spun off bug 770753 for reworking the PAudio protocol to avoid shunting everything through the main threads of each process (which I mentioned in comment 2 in thus bug).
*** Bug 766824 has been marked as a duplicate of this bug. ***
*** Bug 768272 has been marked as a duplicate of this bug. ***