mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-28 14:08:28 +00:00
rwops: Reworked RWops for SDL3.
- SDL_RWops is now an opaque struct. - SDL_AllocRW is gone. If an app is creating a custom RWops, they pass the function pointers to SDL_CreateRW(), which are stored internally. - SDL_RWclose is gone, there is only SDL_DestroyRW(), which calls the implementation's `->close` method before freeing other things. - There is only one path to create and use RWops now, so we don't have to worry about whether `->close` will call SDL_DestroyRW, or if this will risk any Properties not being released, etc. - SDL_RWFrom* still works as expected, for getting a RWops without having to supply your own implementation. Objects from these functions are also destroyed with SDL_DestroyRW. - Lots of other cleanup and SDL3ization of the library code.
This commit is contained in:
@@ -1629,7 +1629,7 @@ static int WaveReadFormat(WaveFile *file)
|
||||
return -1;
|
||||
}
|
||||
} else if (format->encoding == PCM_CODE) {
|
||||
SDL_RWclose(fmtsrc);
|
||||
SDL_DestroyRW(fmtsrc);
|
||||
return SDL_SetError("Missing wBitsPerSample field in WAVE fmt chunk");
|
||||
}
|
||||
|
||||
@@ -1649,7 +1649,7 @@ static int WaveReadFormat(WaveFile *file)
|
||||
|
||||
/* Extensible header must be at least 22 bytes. */
|
||||
if (fmtlen < 40 || format->extsize < 22) {
|
||||
SDL_RWclose(fmtsrc);
|
||||
SDL_DestroyRW(fmtsrc);
|
||||
return SDL_SetError("Extensible WAVE header too small");
|
||||
}
|
||||
|
||||
@@ -1661,7 +1661,7 @@ static int WaveReadFormat(WaveFile *file)
|
||||
format->encoding = WaveGetFormatGUIDEncoding(format);
|
||||
}
|
||||
|
||||
SDL_RWclose(fmtsrc);
|
||||
SDL_DestroyRW(fmtsrc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -2117,7 +2117,7 @@ int SDL_LoadWAV_RW(SDL_RWops *src, SDL_bool freesrc, SDL_AudioSpec *spec, Uint8
|
||||
SDL_free(file.decoderdata);
|
||||
done:
|
||||
if (freesrc && src) {
|
||||
SDL_RWclose(src);
|
||||
SDL_DestroyRW(src);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user