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

using SDL_getenv_unsafe (renamed of SDL_getenv) until we decide if th… #633

Closed
wants to merge 1 commit into from

Conversation

l-t-m-f
Copy link

@l-t-m-f l-t-m-f commented Sep 14, 2024

This is a fix since SDL_getenv has been removed with the arrival of a new thread-safe API. For now I have thus replaced usages of the old name in the SDL_mixer extension by the new name SDL_getenv_unsafe.

I am too unfamiliar with the library to implement the new multi-threaded API for now. I am slowly getting by bearings with this library.

Thank you,

@sezero
Copy link
Contributor

sezero commented Sep 14, 2024

I guess the proper patch to use current SDL3 apis should be like the following. CC: @slouken

diff --git a/examples/playmus.c b/examples/playmus.c
index 97a67b4..4812b99 100644
--- a/examples/playmus.c
+++ b/examples/playmus.c
@@ -205,7 +205,7 @@ int main(int argc, char *argv[])
     Mix_VolumeMusic(audio_volume);
 
     /* Set the external music player, if any */
-    Mix_SetMusicCMD(SDL_getenv("MUSIC_CMD"));
+    Mix_SetMusicCMD(SDL_GetEnvironmentVariable(SDL_GetEnvironment(), "MUSIC_CMD"));
 
     while (argv[i]) {
         next_track = 0;
diff --git a/src/codecs/music_timidity.c b/src/codecs/music_timidity.c
index 726a7f9..cdbc8a0 100644
--- a/src/codecs/music_timidity.c
+++ b/src/codecs/music_timidity.c
@@ -59,7 +59,7 @@ static int TIMIDITY_Open(const SDL_AudioSpec *spec)
 
     (void) spec;
 
-    cfg = SDL_getenv("TIMIDITY_CFG");
+    cfg = SDL_GetEnvironmentVariable(SDL_GetEnvironment(), "TIMIDITY_CFG");
     if(!cfg) cfg = Mix_GetTimidityCfg();
     if (cfg) {
         return Timidity_Init(cfg); /* env or user override: no other tries */
diff --git a/src/effects_internal.c b/src/effects_internal.c
index a1d81f7..f110867 100644
--- a/src/effects_internal.c
+++ b/src/effects_internal.c
@@ -37,7 +37,7 @@ int _Mix_effects_max_speed = 0;
 
 void _Mix_InitEffects(void)
 {
-    _Mix_effects_max_speed = (SDL_getenv(MIX_EFFECTSMAXSPEED) != NULL);
+    _Mix_effects_max_speed = (SDL_GetEnvironmentVariable(SDL_GetEnvironment(), MIX_EFFECTSMAXSPEED) != NULL);
 }
 
 void _Mix_DeinitEffects(void)
diff --git a/src/music.c b/src/music.c
index ed42ea0..1efd381 100644
--- a/src/music.c
+++ b/src/music.c
@@ -1495,7 +1495,7 @@ SDL_bool Mix_SetSoundFonts(const char *paths)
 
 const char* Mix_GetSoundFonts(void)
 {
-    const char *env_paths = SDL_getenv("SDL_SOUNDFONTS");
+    const char *env_paths = SDL_GetEnvironmentVariable(SDL_GetEnvironment(), "SDL_SOUNDFONTS");
     SDL_bool force_env_paths = SDL_GetHintBoolean("SDL_FORCE_SOUNDFONTS", SDL_FALSE);
     if (force_env_paths && (!env_paths || !*env_paths)) {
         force_env_paths = SDL_FALSE;

@slouken
Copy link
Collaborator

slouken commented Sep 14, 2024

I guess the proper patch to use current SDL3 apis should be like the following. CC: @slouken

Yep, this looks good.

@sezero
Copy link
Contributor

sezero commented Sep 14, 2024

I guess the proper patch to use current SDL3 apis should be like the following. CC: @slouken

Yep, this looks good.

OK, I'll be updating SDL_mixer and SDL_image. Leaving sdl2-compat to you.

@l-t-m-f
Copy link
Author

l-t-m-f commented Sep 14, 2024

Thank you sezero I understand how to new call should be used.

@sezero sezero closed this in 3d8376d Sep 14, 2024
@sezero
Copy link
Contributor

sezero commented Sep 14, 2024

OK, main (SDL3) branches of SDL_mixer and SDL_image are patched now.

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.

3 participants