Closed Bug 100472 Opened 23 years ago Closed 23 years ago

nsSound should play sounds asynchronously, and cache rendered sounds

Categories

(Core :: XUL, defect)

PowerPC
Mac System 8.5
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: sfraser_bugs, Assigned: sfraser_bugs)

Details

(Keywords: perf)

Attachments

(1 file, 1 obsolete file)

On Mac, nsSound has very poor performance, for a number of reasons:
1. It doesn't do any cacheing, so *every* time we play a sound, we render it to a 
new QuickTime movie.
2. The movie is played synchronously, preventing the user from doing anything 
while the sound plays.
Keywords: perf
Note that this was fixed in Windows recently, and sound has always been async on 
Unix.
I'm working on this.
Assignee: beard → sfraser
Attached patch nsSound changes for async playback etc. (obsolete) (deleted) — Splinter Review
The attached patch greatly enhances nsSound on Mac, adding the following features 
(without interface changes):
1. Sounds are now played asynchronously
2. Rendered sounds (as QuickTime movies) are stored per-session in the necko 
memory cache.
3. Multiple different sounds can be played concurrently.
4. The same sound can be played several times concurrently.
5. Different sound formats are identified by sniffing the data (WAVE, uLaw, midi)
   or looking at the MIME type (MP3), and imported appropriately.

How it works:
nsSound has become more like a sound service; it just spawns URL loads, and deals 
with necko caching of rendered sounds. For each unique sound (keyed by URL) that 
is playing, we create an nsSoundRequest, which is what handles rendering to a 
movie, and creates a timer which calls MoviesTask(). nsSoundRequests get stuffed 
into the necko cache (memory cache only).

Additional code is necessary to deal with playing the same sound several times 
simultaneously. Because the sound is in a movie, and the movie contains playback 
state information, we have to clone the movie each additional time we need to 
play it while another copy is playing. Luckily, cloning a movie just copies data 
refs, so this is cheap.

We use a timer that fires every 250ms to call MoviesTask(); there is one timer 
per nsSoundRequest, that fires as long as any movie in that nsSoundRequest is 
playing.
Attachment #52764 - Attachment is obsolete: true
Attached patch Better nsSound patch (deleted) — Splinter Review
New patch removes printfs, and disposes of movies after they finish playing, 
rather than when the nsSoundRequest is deleted.

Reviews please.
Status: NEW → ASSIGNED
Comment on attachment 52819 [details] [diff] [review]
Better nsSound patch

r=pink
Attachment #52819 - Flags: review+
Comment on attachment 52819 [details] [diff] [review]
Better nsSound patch

sr=sspitzer
Attachment #52819 - Flags: superreview+
Checked in.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: