Loading audio/image resource from compressed file #204
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
This is a draft of allowing user package the audio/image files into a compressed file for each bms package. The original idea was proposed in upstream. As the statement points out, by implementing this user can much disk spaces and probably benefits the bms package distributors.
I have tried implementing this idea before but was stuck at how to cooperate with gdx & handling compressed file errors. At current stage I have made this feature able to use but extremely slow. See below for more details.
How it shapes like?
Take an arbitrary bms package on my disk for example, before it looks like:
This pr allows it package all the ogg files into a single archive:
Implementation details
The main structure of the implementation is very straightforward: previously, beatoraja encapsulated the actual audio load step in
AudioCache::getfunction, whereAudioCacheitself is a resource pool. Therefore, in this implementation, I extended it to firstly check if the audio file currently it wants to load is present in theresource.7zarchive file, if so, load it from archive file, otherwise, loading it from disk.However, there're two major issues about the actual file load process:
The first problem causes the code have to load the archive file on disk each time loading an audio file. The second problem directly kills th mutli-threading strategy that has already been coded in raja: makes me to lock it exclusively without choice. These two problems may can be solved together by forcing user to use zip format which may support random entry access.
Therefore, in current implementation, a 7z file is eagerly loaded into memory rather than accessing entries when needed.
Compatibility
This is the most concerning part of this pr. While this feature is good, it saves disk space, it makes packaging more simpler. However, this is an one-way street if upstream doesn't have this feature. Imaging a user want to play on vanilla raja temporarily? No it cannot be done¯_(°ペ)_/¯
Other messages
This implementation forces the archive file's name to be
resource.7z, this is on purpose. Loading arbitrary compress files are just not a good idea.