craftyjs/Crafty — pull request #628 by jamespic (2013-11-27 22:51:02+00:00)
Title: Chrome workaround and bug in setChannels

A couple of patches.

One for a bug in setChannels (we unnecessarily increase the size of an array, without populating it - as a consequence, getOpenChannel finds undefined where it was expecting a channel).

Another is a workaround for a bug in Chrome (https://code.google.com/p/chromium/issues/detail?id=280417). Audio objects sometimes don't fire "ended" events for short sounds, so we leak channels. The patch allows us to re-use channels that haven't been marked as inactive, but are ended and over their repeat count.