forked from hex007/freej2me
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
media: Manager: Introduce a mediaCache
It's not often that J2ME games stutter in FreeJ2ME, but when they do, it's almost always because they're loading media streams during gameplay, and it's especially noticeable if said streams are MIDI while running under OpenJDK (the older it is, the worse it gets). Sonic Jump (Siemens 132x176 version) is one such example, every SFX is loaded during runtime, and the game doesn't store any, so as soon as a different SFX from the last comes up, the game stutters. This turns the old "MaxMidiStreams" setting into more of a "MediaCacheSize", where it limits the amount of players of any kind that can be kept in memory at the same time without reloading any. This is achieved through a hashmap that evaluates an incoming stream's MD5 against the ones already cached, and if it exists, out media Manager simply returns the cached player instead of creating a new one, vastly improving performance on apps that do constant player allocations. As a bonus, this actually helps DOOM II RPG, as its pool of unique SFX and BGM is rather small (something around 16, despite all being MIDI), which means we can probably increase the default value for this cache without worrying about memory, as duplicate streams won't be a thing anymore since they'll evaluate to the same MD5... unless we start dealing with a game that generates those on the fly, of course. But that's something for when Tone playback is implemented, and it might not even need to go through here anyway.
- Loading branch information
1 parent
845d06e
commit 7ad3824
Showing
6 changed files
with
160 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.