Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated for the SDL3 RW -> IO changes #598

Merged
merged 1 commit into from
Mar 18, 2024
Merged

Conversation

slouken
Copy link
Collaborator

@slouken slouken commented Mar 18, 2024

Fixes #597

@slouken slouken requested a review from sezero March 18, 2024 20:04
@sezero
Copy link
Contributor

sezero commented Mar 18, 2024

All CreateFromRW needs changing to CreateFromIO

music_wavpack.c has freesrc2 along with freesrc: freesrc2 needs changing to closeio2

music_flac.c has typos / copy/paste mistakes:

../src/codecs/music_flac.c: In function ‘flac_read_music_cb’:
../src/codecs/music_flac.c:201:22: error: dereferencing pointer to incomplete type ‘SDL_IOStream’ {aka ‘struct SDL_IOStream’}
  201 |         if (data->src->status == SDL_IOOPS_STATUS_READY ||
      |                      ^~
../src/codecs/music_flac.c:201:34: error: ‘SDL_IOOPS_STATUS_READY’ undeclared (first use in this function); did you mean ‘SDL_IO_STATUS_READY’?
  201 |         if (data->src->status == SDL_IOOPS_STATUS_READY ||
      |                                  ^~~~~~~~~~~~~~~~~~~~~~
      |                                  SDL_IO_STATUS_READY
../src/codecs/music_flac.c:201:34: note: each undeclared identifier is reported only once for each function it appears in
../src/codecs/music_flac.c:202:34: error: ‘SDL_IOOPS_STATUS_NOT_READY’ undeclared (first use in this function); did you mean ‘SDL_IO_STATUS_NOT_READY’?
  202 |             data->src->status == SDL_IOOPS_STATUS_NOT_READY) {
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                  SDL_IO_STATUS_NOT_READY
../src/codecs/music_flac.c:204:41: error: ‘SDL_IOOPS_STATUS_EOF’ undeclared (first use in this function); did you mean ‘SDL_IO_STATUS_EOF’?
  204 |         } else if (data->src->status == SDL_IOOPS_STATUS_EOF) {
      |                                         ^~~~~~~~~~~~~~~~~~~~
      |                                         SDL_IO_STATUS_EOF
../src/codecs/music_flac.c:212:1: error: control reaches end of non-void function [-Werror=return-type]
  212 | }
      | ^

stb_vorbis.h has helper procedure names with rwops

native_midi_haiku.cpp not updated

native_midi_macosx.c has freesrc which needs changing to closeio and has procedure names with _RW

There may be more..

@slouken
Copy link
Collaborator Author

slouken commented Mar 18, 2024

Thanks for the review. I fixed the things you found and did one last look around and I think you caught everything. It looks like CI is succeeding, can you take one last look as a sanity check?

@sezero
Copy link
Contributor

sezero commented Mar 18, 2024

Final nits below. (If you have a better cmdline switch replacement for -rwops of playmus, be my guest)

diff --git a/examples/playmus.c b/examples/playmus.c
index aebf9e5..0f66317 100644
--- a/examples/playmus.c
+++ b/examples/playmus.c
@@ -65,3 +65,3 @@ static void Usage(char *argv0)
 {
-    SDL_Log("Usage: %s [-i] [-l] [-8] [-f32] [-r rate] [-c channels] [-b buffers] [-v N] [-rwops] <musicfile>\n", argv0);
+    SDL_Log("Usage: %s [-i] [-l] [-8] [-f32] [-r rate] [-c channels] [-b buffers] [-v N] [-iostr] <musicfile>\n", argv0);
 }
@@ -117,3 +117,3 @@ int main(int argc, char *argv[])
     int interactive = 0;
-    int rwops = 0;
+    int iostr = 0;
     int i;
@@ -167,4 +167,4 @@ int main(int argc, char *argv[])
         } else
-        if (SDL_strcmp(argv[i], "-rwops") == 0) {
-            rwops = 1;
+        if (SDL_strcmp(argv[i], "-iostr") == 0) {
+            iostr = 1;
         } else {
@@ -213,3 +213,3 @@ int main(int argc, char *argv[])
         /* Load the requested music file */
-        if (rwops) {
+        if (iostr) {
             music = Mix_LoadMUS_IO(SDL_IOFromFile(argv[i], "rb"), SDL_TRUE);
diff --git a/include/SDL3_mixer/SDL_mixer.h b/include/SDL3_mixer/SDL_mixer.h
index b7ece3e..9989d20 100644
--- a/include/SDL3_mixer/SDL_mixer.h
+++ b/include/SDL3_mixer/SDL_mixer.h
@@ -402,5 +402,5 @@ extern DECLSPEC int SDLCALL Mix_AllocateChannels(int numchans);
  *
- * If `closeio` is SDL_TRUE, the RWops will be closed before returning,
+ * If `closeio` is SDL_TRUE, the IOStream will be closed before returning,
  * whether this function succeeds or not. SDL_mixer reads everything it needs
- * from the RWops during this call in any case.
+ * from the IOStream during this call in any case.
  *
@@ -451,3 +451,3 @@ extern DECLSPEC Mix_Chunk * SDLCALL Mix_LoadWAV_IO(SDL_IOStream *src, SDL_bool c
  * Note that before SDL_mixer 3.0.0, this function was a macro that called
- * Mix_LoadWAV_IO(), creating a RWops and setting `closeio` to SDL_TRUE. This
+ * Mix_LoadWAV_IO(), creating a IOStream and setting `closeio` to SDL_TRUE. This
  * macro has since been promoted to a proper API function. Older binaries
@@ -515,5 +515,5 @@ extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS(const char *file);
  *
- * If `closeio` is SDL_TRUE, the RWops will be closed before returning,
+ * If `closeio` is SDL_TRUE, the IOStream will be closed before returning,
  * whether this function succeeds or not. SDL_mixer reads everything it needs
- * from the RWops during this call in any case.
+ * from the IOStream during this call in any case.
  *
@@ -575,5 +575,5 @@ extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS_IO(SDL_IOStream *src, SDL_bool c
  *
- * If `closeio` is SDL_TRUE, the RWops will be closed before returning,
+ * If `closeio` is SDL_TRUE, the IOStream will be closed before returning,
  * whether this function succeeds or not. SDL_mixer reads everything it needs
- * from the RWops during this call in any case.
+ * from the IOStream during this call in any case.
  *

@slouken slouken merged commit e8fa3dc into libsdl-org:main Mar 18, 2024
5 checks passed
@slouken slouken deleted the update branch March 18, 2024 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace SDL_RWops with SDL_IOStream for SDL3
2 participants