Selaa lähdekoodia

Remove/Rename SDL_FreeWAV() to SDL_free()

Sylvain 2 vuotta sitten
vanhempi
commit
3fb0c8b54a

+ 1 - 0
WhatsNew.txt

@@ -16,6 +16,7 @@ General:
     * RW_SEEK_END -> SDL_RW_SEEK_END
     * RW_SEEK_SET -> SDL_RW_SEEK_SET
 * The following functions have been renamed:
+    * SDL_FreeWAV => SDL_free
 * Removed the following functions from the API, see docs/README-migration.md for details:
     * SDL_CalculateGammaRamp()
     * SDL_CreateRGBSurface()

+ 5 - 0
docs/README-migration.md

@@ -40,6 +40,11 @@ begin_code.h and close_code.h in the public headers have been renamed to SDL_beg
 
 The vi format comments have been removed from source code. Vim users can use the [editorconfig plugin](https://github.com/editorconfig/editorconfig-vim) to automatically set tab spacing for the SDL coding style.
 
+## SDL_audio.h
+
+The following functions have been renamed:
+* SDL_FreeWAV => SDL_free
+
 ## SDL_cpuinfo.h
 
 - SDL_Has3DNow() has been removed; there is no replacement.

+ 3 - 20
include/SDL3/SDL_audio.h

@@ -808,7 +808,7 @@ extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev,
  * data in the buffer. The `samples` member is set to a sane default and all
  * others are set to zero.
  *
- * It's necessary to use SDL_FreeWAV() to free the audio data returned in
+ * It's necessary to use SDL_free() to free the audio data returned in
  * `audio_buf` when it is no longer used.
  *
  * Because of the underspecification of the .WAV format, there are many
@@ -860,11 +860,11 @@ extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev,
  *          more information.
  *
  *          When the application is done with the data returned in
- *          `audio_buf`, it should call SDL_FreeWAV() to dispose of it.
+ *          `audio_buf`, it should call SDL_free() to dispose of it.
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_FreeWAV
+ * \sa SDL_free
  * \sa SDL_LoadWAV
  */
 extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src,
@@ -880,23 +880,6 @@ extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src,
 #define SDL_LoadWAV(file, spec, audio_buf, audio_len) \
     SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len)
 
-/**
- * Free data previously allocated with SDL_LoadWAV() or SDL_LoadWAV_RW().
- *
- * After a WAVE file has been opened with SDL_LoadWAV() or SDL_LoadWAV_RW()
- * its data can eventually be freed with SDL_FreeWAV(). It is safe to call
- * this function with a NULL pointer.
- *
- * \param audio_buf a pointer to the buffer created by SDL_LoadWAV() or
- *                  SDL_LoadWAV_RW()
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_LoadWAV
- * \sa SDL_LoadWAV_RW
- */
-extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 * audio_buf);
-
 /**
  * Initialize an SDL_AudioCVT structure for conversion.
  *

+ 6 - 0
include/SDL3/SDL_oldnames.h

@@ -39,6 +39,9 @@
  */
 #ifdef SDL_ENABLE_OLD_NAMES
 
+/* ##SDL_audio.h */
+#define SDL_FreeWAV SDL_free
+
 /* ##SDL_keycode.h */
 #define KMOD_ALT SDL_KMOD_ALT
 #define KMOD_CAPS SDL_KMOD_CAPS
@@ -74,6 +77,9 @@
 
 #else /* !SDL_ENABLE_OLD_NAMES */
 
+/* ##SDL_audio.h */
+#define SDL_FreeWAV SDL_FreeWAV_renamed_SDL_free
+
 /* ##SDL_keycode.h */
 #define KMOD_ALT KMOD_ALT_renamed_SDL_KMOD_ALT
 #define KMOD_CAPS KMOD_CAPS_renamed_SDL_KMOD_CAPS

+ 0 - 8
src/audio/SDL_wave.c

@@ -2124,11 +2124,3 @@ SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_b
 
     return spec;
 }
-
-/* Since the WAV memory is allocated in the shared library, it must also
-   be freed here.  (Necessary under Win32, VC++)
- */
-void SDL_FreeWAV(Uint8 *audio_buf)
-{
-    SDL_free(audio_buf);
-}

+ 0 - 1
src/dynapi/SDL_dynapi.sym

@@ -48,7 +48,6 @@ SDL3_0.0.0 {
     SDL_PauseAudio;
     SDL_PauseAudioDevice;
     SDL_LoadWAV_RW;
-    SDL_FreeWAV;
     SDL_BuildAudioCVT;
     SDL_ConvertAudio;
     SDL_NewAudioStream;

+ 0 - 1
src/dynapi/SDL_dynapi_overrides.h

@@ -82,7 +82,6 @@
 #define SDL_PauseAudio SDL_PauseAudio_REAL
 #define SDL_PauseAudioDevice SDL_PauseAudioDevice_REAL
 #define SDL_LoadWAV_RW SDL_LoadWAV_RW_REAL
-#define SDL_FreeWAV SDL_FreeWAV_REAL
 #define SDL_BuildAudioCVT SDL_BuildAudioCVT_REAL
 #define SDL_ConvertAudio SDL_ConvertAudio_REAL
 #define SDL_MixAudio SDL_MixAudio_REAL

+ 0 - 1
src/dynapi/SDL_dynapi_procs.h

@@ -109,7 +109,6 @@ SDL_DYNAPI_PROC(SDL_AudioStatus,SDL_GetAudioDeviceStatus,(SDL_AudioDeviceID a),(
 SDL_DYNAPI_PROC(void,SDL_PauseAudio,(int a),(a),)
 SDL_DYNAPI_PROC(void,SDL_PauseAudioDevice,(SDL_AudioDeviceID a, int b),(a,b),)
 SDL_DYNAPI_PROC(SDL_AudioSpec*,SDL_LoadWAV_RW,(SDL_RWops *a, int b, SDL_AudioSpec *c, Uint8 **d, Uint32 *e),(a,b,c,d,e),return)
-SDL_DYNAPI_PROC(void,SDL_FreeWAV,(Uint8 *a),(a),)
 SDL_DYNAPI_PROC(int,SDL_BuildAudioCVT,(SDL_AudioCVT *a, SDL_AudioFormat b, Uint8 c, int d, SDL_AudioFormat e, Uint8 f, int g),(a,b,c,d,e,f,g),return)
 SDL_DYNAPI_PROC(int,SDL_ConvertAudio,(SDL_AudioCVT *a),(a),return)
 SDL_DYNAPI_PROC(void,SDL_MixAudio,(Uint8 *a, const Uint8 *b, Uint32 c, int d),(a,b,c,d),)

+ 2 - 2
test/loopwave.c

@@ -59,7 +59,7 @@ open_audio()
     device = SDL_OpenAudioDevice(NULL, SDL_FALSE, &wave.spec, NULL, 0);
     if (!device) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError());
-        SDL_FreeWAV(wave.sound);
+        SDL_free(wave.sound);
         quit(2);
     }
 
@@ -171,7 +171,7 @@ int main(int argc, char *argv[])
 
     /* Clean up on signal */
     close_audio();
-    SDL_FreeWAV(wave.sound);
+    SDL_free(wave.sound);
     SDL_free(filename);
     SDL_Quit();
     return 0;

+ 2 - 2
test/loopwavequeue.c

@@ -112,7 +112,7 @@ int main(int argc, char *argv[])
     /* Initialize fillerup() variables */
     if (SDL_OpenAudio(&wave.spec, NULL) < 0) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError());
-        SDL_FreeWAV(wave.sound);
+        SDL_free(wave.sound);
         quit(2);
     }
 
@@ -139,7 +139,7 @@ int main(int argc, char *argv[])
 
     /* Clean up on signal */
     SDL_CloseAudio();
-    SDL_FreeWAV(wave.sound);
+    SDL_free(wave.sound);
     SDL_free(filename);
     SDL_Quit();
     return 0;

+ 1 - 1
test/testaudiohotplug.c

@@ -194,7 +194,7 @@ int main(int argc, char *argv[])
     /* Clean up on signal */
     /* Quit audio first, then free WAV. This prevents access violations in the audio threads. */
     SDL_QuitSubSystem(SDL_INIT_AUDIO);
-    SDL_FreeWAV(sound);
+    SDL_free(sound);
     SDL_free(filename);
     SDL_Quit();
     return 0;

+ 2 - 2
test/testmultiaudio.c

@@ -62,7 +62,7 @@ void loop()
 #endif
         SDL_PauseAudioDevice(cbd[0].dev, 1);
         SDL_CloseAudioDevice(cbd[0].dev);
-        SDL_FreeWAV(sound);
+        SDL_free(sound);
         SDL_Quit();
     }
 }
@@ -190,7 +190,7 @@ int main(int argc, char **argv)
                          SDL_GetError());
         } else {
             test_multi_audio(devcount);
-            SDL_FreeWAV(sound);
+            SDL_free(sound);
         }
 
         SDL_free(file);

+ 6 - 6
test/testresample.c

@@ -51,7 +51,7 @@ int main(int argc, char **argv)
     if (SDL_BuildAudioCVT(&cvt, spec.format, spec.channels, spec.freq,
                           spec.format, cvtchans, cvtfreq) == -1) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to build CVT: %s\n", SDL_GetError());
-        SDL_FreeWAV(data);
+        SDL_free(data);
         SDL_Quit();
         return 4;
     }
@@ -60,7 +60,7 @@ int main(int argc, char **argv)
     cvt.buf = (Uint8 *)SDL_malloc((size_t)len * cvt.len_mult);
     if (cvt.buf == NULL) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory.\n");
-        SDL_FreeWAV(data);
+        SDL_free(data);
         SDL_Quit();
         return 5;
     }
@@ -69,7 +69,7 @@ int main(int argc, char **argv)
     if (SDL_ConvertAudio(&cvt) == -1) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Conversion failed: %s\n", SDL_GetError());
         SDL_free(cvt.buf);
-        SDL_FreeWAV(data);
+        SDL_free(data);
         SDL_Quit();
         return 6;
     }
@@ -79,7 +79,7 @@ int main(int argc, char **argv)
     if (io == NULL) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fopen('%s') failed: %s\n", argv[2], SDL_GetError());
         SDL_free(cvt.buf);
-        SDL_FreeWAV(data);
+        SDL_free(data);
         SDL_Quit();
         return 7;
     }
@@ -106,13 +106,13 @@ int main(int argc, char **argv)
     if (SDL_RWclose(io) == -1) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fclose('%s') failed: %s\n", argv[2], SDL_GetError());
         SDL_free(cvt.buf);
-        SDL_FreeWAV(data);
+        SDL_free(data);
         SDL_Quit();
         return 8;
     } /* if */
 
     SDL_free(cvt.buf);
-    SDL_FreeWAV(data);
+    SDL_free(data);
     SDL_Quit();
     return 0;
 } /* main */