player: add zip implementation and improve rar implementation#101
player: add zip implementation and improve rar implementation#101myQwil wants to merge 4 commits intolibgme:masterfrom
Conversation
|
I'll try to take a look on this probably tomorrow, this week is pretty busy for me. |
This was with gcc4.9 If I enabled unrar, two --- a/player/Archive_Reader.cpp
+++ b/player/Archive_Reader.cpp
@@ -3,8 +3,8 @@
blargg_err_t const arc_eof = "Archive: End of file";
-#ifdef RARDLL
-
#include <string.h>
+#ifdef RARDLL
+
static const int erar_offset = 10;
static blargg_err_t const erar_handle = "Failed to instantiate RAR handle";As for rest of the errors, I guess you need some new version of libarchive?? If so, you should specify it in cmake'ry (my libarchive is 2.8.3) |
Or better, polish the code to ensure it will build with older version too to maintain compatibility with older distros environments (even some of supported LTS distro versions will have a similiar older version). |
|
That should hopefully take care of the unrecognized type and But it sounds like there are still some functions being used which either didn't exist before or had their name changed. Also, i'm using libarchive 3.7.7-1. |
8927766 to
1848cff
Compare
|
Don't know what to do with |
|
From what I can tell, a filtering feature hadn't been added yet by that version. I think we can just leave that function call out. "filter all" seems to be the default behavior anyway, and it still works on my end when I take it out. |
Ah, obviously, So, the following patch makes it build for me: diff --git a/player/Archive_Reader.cpp b/player/Archive_Reader.cpp
index 6423d18..a272523 100644
--- a/player/Archive_Reader.cpp
+++ b/player/Archive_Reader.cpp
@@ -102,6 +102,16 @@ static blargg_err_t const zerrs[] = {
};
#endif // HAVE_ZLIB_H
+#if (ARCHIVE_VERSION_NUMBER < 3000000)
+static inline int archive_read_free(struct archive *a) {
+ return archive_read_finish(a);
+}
+
+static inline int archive_read_support_filter_all(struct archive *a) {
+ return archive_read_support_compression_all(a);
+}
+#endif
+
blargg_err_t Zip_Reader::open_zip( const char* path ) {
if ( !(zip = archive_read_new()) )
return zip_err_struct; |
That'd be OK too, I guess.. (not tried though) |
|
Actually, I think you're right. Looks like "filter" was just a name change from "compression" |
|
Latest rev builds cleanly for me. |
player/Audio_Scope.h
Outdated
| #include "SDL.h" | ||
| #include "gme/gme.h" | ||
|
|
||
| #include <SDL_render.h> |
There was a problem hiding this comment.
Recommended include method for SDL2 headers is quotes instead of brackets: replace <SDL_xxx.h> with "SDL_xxx.h"
player/Music_Player.cpp
Outdated
| #include <string.h> | ||
| #include <ctype.h> | ||
| #include "SDL_rwops.h" | ||
| #include <SDL_rwops.h> |
player/Music_Player.cpp
Outdated
| // Sound output driver using SDL | ||
|
|
||
| #include "SDL.h" | ||
| #include <SDL_audio.h> |
player/Archive_Reader.h
Outdated
|
|
||
| // GME_4CHAR('a','b','c','d') = 'abcd' (four character integer constant) | ||
| #define GME_4CHAR( a, b, c, d ) \ | ||
| ((a&0xFF)*0x1000000L + (b&0xFF)*0x10000L + (c&0xFF)*0x100L + (d&0xFF)) |
There was a problem hiding this comment.
Now that you replaced long with uint32_t as the sinature type, you should remove L suffixes from the multipliers
(Possibly all long type usage should be replaced with fixed 32 bit types, e.g. int32_t as was suggested in #117, but that's another story...)
There was a problem hiding this comment.
i'll see if i can get rid of all the longs in player-related code
There was a problem hiding this comment.
i'll see if i can get rid of all the
longs in player-related code
It's not limited to player code, but that'd certainly be a start
And that shouldn't be in the way of merging this particular PR, either (Hint: @Wohlstand )
player/Archive_Reader.cpp
Outdated
|
|
||
| gme_err_t Zip_Reader::next( void* buf_ptr, arc_entry_t* entry ) | ||
| { | ||
| ssize_t res; |
There was a problem hiding this comment.
ssize_t may not be universally available, e.g. MSVC. (Although the CI MSVC runs seem to have succeeded...)
There was a problem hiding this comment.
what about ptrdiff_t?
There was a problem hiding this comment.
ptrdiff_t is available to many, yes.
5049952 to
0678df5
Compare
- better and more specific error handling - signatures placed in derived archive classes - add arc_entry_t to make fewer virtual funcs necessary - use std::unique_ptr so it always deletes on scope exit
Requires libarchive. Zlib is an optional requirement for decompressing individually gzipped files within a zip. The zip reader should still work somewhat without zlib, just not in as many scenarios.
changed to size_t for sizes of memory chunks. changed to uint32_t for counts, time durations, and sample rates. also changed ssize_t to the more widely supported ptrdiff_t
Improvements to rar reader:
arc_entry_tto reduce the amount of virtual functionsstd::unique_ptrso our reader always cleans up on scope exitThe zip implementation requires libarchive. Zlib is an optional requirement for decompressing individually gzipped files within a zip. The zip reader should still work somewhat without zlib, just not in as many scenarios.
EDIT: One more change was made. Some zips contain one multi-track file like .kss along with several .m3u's, so the reader now accounts for that scenario.