Skip to content

Commit bd3185b

Browse files
committed
include: Clarify lifetime of RWops in Mix_LoadMUS* calls with freesrc!=0.
Fixes #683.
1 parent 1ae3f41 commit bd3185b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

include/SDL_mixer.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -665,9 +665,11 @@ extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS(const char *file);
665665
* fly. Also, crucially, there are as many channels for chunks as the app can
666666
* allocate, but SDL_mixer only offers a single "music" channel.
667667
*
668-
* If `freesrc` is non-zero, the RWops will be closed before returning,
669-
* whether this function succeeds or not. SDL_mixer reads everything it needs
670-
* from the RWops during this call in any case.
668+
* If `freesrc` is non-zero, the RWops will be closed when SDL_mixer is done
669+
* with it, which will be before this function call returns if there is an
670+
* error, or perhaps much later if the music is streaming for some time. The
671+
* app should not attempt to use the RWops again, as it may become invalid
672+
* without warning.
671673
*
672674
* As a convenience, there is a function to read files from disk without
673675
* having to deal with SDL_RWops: `Mix_LoadMUS("filename.mp3")` will manage
@@ -725,9 +727,11 @@ extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS_RW(SDL_RWops *src, int freesrc);
725727
* - `MUS_OPUS` (Opus files)
726728
* - `MUS_WAVPACK` (WavPack files)
727729
*
728-
* If `freesrc` is non-zero, the RWops will be closed before returning,
729-
* whether this function succeeds or not. SDL_mixer reads everything it needs
730-
* from the RWops during this call in any case.
730+
* If `freesrc` is non-zero, the RWops will be closed when SDL_mixer is done
731+
* with it, which will be before this function call returns if there is an
732+
* error, or perhaps much later if the music is streaming for some time. The
733+
* app should not attempt to use the RWops again, as it may become invalid
734+
* without warning.
731735
*
732736
* As a convenience, there is a function to read files from disk without
733737
* having to deal with SDL_RWops: `Mix_LoadMUS("filename.mp3")` will manage

0 commit comments

Comments
 (0)