mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-01 17:37:39 +00:00
Fixed order and constness of parameters to SDL_ConvertAudioSamples()
This commit is contained in:
parent
fa599c7548
commit
5b77ad54c4
5 changed files with 23 additions and 23 deletions
|
@ -70,8 +70,8 @@ should be changed to:
|
||||||
```c
|
```c
|
||||||
Uint8 *dst_data = NULL;
|
Uint8 *dst_data = NULL;
|
||||||
int dst_len = 0;
|
int dst_len = 0;
|
||||||
if (SDL_ConvertAudioSamples(src_format, src_channels, src_rate, src_len, src_data
|
if (SDL_ConvertAudioSamples(src_format, src_channels, src_rate, src_data, src_len
|
||||||
dst_format, dst_channels, dst_rate, &dst_len, &dst_data) < 0) {
|
dst_format, dst_channels, dst_rate, &dst_data, &dst_len) < 0) {
|
||||||
/* error */
|
/* error */
|
||||||
}
|
}
|
||||||
do_something(dst_data, dst_len);
|
do_something(dst_data, dst_len);
|
||||||
|
|
|
@ -555,7 +555,7 @@ extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioDeviceStatus(SDL_AudioDevice
|
||||||
*
|
*
|
||||||
* \param dev a device opened by SDL_OpenAudioDevice()
|
* \param dev a device opened by SDL_OpenAudioDevice()
|
||||||
* \returns 0 on success or a negative error code on failure; call
|
* \returns 0 on success or a negative error code on failure; call
|
||||||
* SDL_GetError() for more information.
|
* SDL_GetError() for more information.
|
||||||
*
|
*
|
||||||
* \since This function is available since SDL 3.0.0.
|
* \since This function is available since SDL 3.0.0.
|
||||||
*
|
*
|
||||||
|
@ -580,7 +580,7 @@ extern DECLSPEC int SDLCALL SDL_PlayAudioDevice(SDL_AudioDeviceID dev);
|
||||||
*
|
*
|
||||||
* \param dev a device opened by SDL_OpenAudioDevice()
|
* \param dev a device opened by SDL_OpenAudioDevice()
|
||||||
* \returns 0 on success or a negative error code on failure; call
|
* \returns 0 on success or a negative error code on failure; call
|
||||||
* SDL_GetError() for more information.
|
* SDL_GetError() for more information.
|
||||||
*
|
*
|
||||||
* \since This function is available since SDL 3.0.0.
|
* \since This function is available since SDL 3.0.0.
|
||||||
*
|
*
|
||||||
|
@ -1025,7 +1025,7 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetQueuedAudioSize(SDL_AudioDeviceID dev);
|
||||||
*
|
*
|
||||||
* \param dev the device ID of which to clear the audio queue
|
* \param dev the device ID of which to clear the audio queue
|
||||||
* \returns 0 on success or a negative error code on failure; call
|
* \returns 0 on success or a negative error code on failure; call
|
||||||
* SDL_GetError() for more information.
|
* SDL_GetError() for more information.
|
||||||
*
|
*
|
||||||
* \since This function is available since SDL 3.0.0.
|
* \since This function is available since SDL 3.0.0.
|
||||||
*
|
*
|
||||||
|
@ -1079,7 +1079,7 @@ extern DECLSPEC int SDLCALL SDL_ClearQueuedAudio(SDL_AudioDeviceID dev);
|
||||||
*
|
*
|
||||||
* \param dev the ID of the device to be locked
|
* \param dev the ID of the device to be locked
|
||||||
* \returns 0 on success or a negative error code on failure; call
|
* \returns 0 on success or a negative error code on failure; call
|
||||||
* SDL_GetError() for more information.
|
* SDL_GetError() for more information.
|
||||||
*
|
*
|
||||||
* \since This function is available since SDL 3.0.0.
|
* \since This function is available since SDL 3.0.0.
|
||||||
*
|
*
|
||||||
|
@ -1132,14 +1132,14 @@ extern DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID dev);
|
||||||
* \param src_format The format of the source audio
|
* \param src_format The format of the source audio
|
||||||
* \param src_channels The number of channels of the source audio
|
* \param src_channels The number of channels of the source audio
|
||||||
* \param src_rate The sampling rate of the source audio
|
* \param src_rate The sampling rate of the source audio
|
||||||
* \param src_len The len of src_data
|
|
||||||
* \param src_data The audio data to be converted
|
* \param src_data The audio data to be converted
|
||||||
|
* \param src_len The len of src_data
|
||||||
* \param dst_format The format of the desired audio output
|
* \param dst_format The format of the desired audio output
|
||||||
* \param dst_channels The number of channels of the desired audio output
|
* \param dst_channels The number of channels of the desired audio output
|
||||||
* \param dst_rate The sampling rate of the desired audio output
|
* \param dst_rate The sampling rate of the desired audio output
|
||||||
* \param dst_len Will be filled with the len of dst_data
|
|
||||||
* \param dst_data Will be filled with a pointer to converted audio data,
|
* \param dst_data Will be filled with a pointer to converted audio data,
|
||||||
* which should be freed with SDL_free().
|
* which should be freed with SDL_free().
|
||||||
|
* \param dst_len Will be filled with the len of dst_data
|
||||||
* \returns 0 on success or a negative error code on failure. On error,
|
* \returns 0 on success or a negative error code on failure. On error,
|
||||||
* *dst_data will be NULL and so not allocated.
|
* *dst_data will be NULL and so not allocated.
|
||||||
*
|
*
|
||||||
|
@ -1150,13 +1150,13 @@ extern DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID dev);
|
||||||
extern DECLSPEC int SDLCALL SDL_ConvertAudioSamples(SDL_AudioFormat src_format,
|
extern DECLSPEC int SDLCALL SDL_ConvertAudioSamples(SDL_AudioFormat src_format,
|
||||||
Uint8 src_channels,
|
Uint8 src_channels,
|
||||||
int src_rate,
|
int src_rate,
|
||||||
|
const Uint8 *src_data,
|
||||||
int src_len,
|
int src_len,
|
||||||
Uint8 *src_data,
|
|
||||||
SDL_AudioFormat dst_format,
|
SDL_AudioFormat dst_format,
|
||||||
Uint8 dst_channels,
|
Uint8 dst_channels,
|
||||||
int dst_rate,
|
int dst_rate,
|
||||||
int *dst_len,
|
Uint8 **dst_data,
|
||||||
Uint8 **dst_data);
|
int *dst_len);
|
||||||
|
|
||||||
/* Ends C function definitions when using C++ */
|
/* Ends C function definitions when using C++ */
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -1674,8 +1674,8 @@ void SDL_CalculateAudioSpec(SDL_AudioSpec *spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_ConvertAudioSamples(
|
int SDL_ConvertAudioSamples(
|
||||||
SDL_AudioFormat src_format, Uint8 src_channels, int src_rate, int src_len, Uint8 *src_data,
|
SDL_AudioFormat src_format, Uint8 src_channels, int src_rate, const Uint8 *src_data, int src_len,
|
||||||
SDL_AudioFormat dst_format, Uint8 dst_channels, int dst_rate, int *dst_len, Uint8 **dst_data)
|
SDL_AudioFormat dst_format, Uint8 dst_channels, int dst_rate, Uint8 **dst_data, int *dst_len)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
SDL_AudioStream *stream = NULL;
|
SDL_AudioStream *stream = NULL;
|
||||||
|
@ -1684,21 +1684,21 @@ int SDL_ConvertAudioSamples(
|
||||||
int real_dst_len;
|
int real_dst_len;
|
||||||
|
|
||||||
|
|
||||||
if (src_len < 0) {
|
|
||||||
return SDL_InvalidParamError("src_len");
|
|
||||||
}
|
|
||||||
if (src_data == NULL) {
|
if (src_data == NULL) {
|
||||||
return SDL_InvalidParamError("src_data");
|
return SDL_InvalidParamError("src_data");
|
||||||
}
|
}
|
||||||
if (dst_len == NULL) {
|
if (src_len < 0) {
|
||||||
return SDL_InvalidParamError("dst_len");
|
return SDL_InvalidParamError("src_len");
|
||||||
}
|
}
|
||||||
if (dst_data == NULL) {
|
if (dst_data == NULL) {
|
||||||
return SDL_InvalidParamError("dst_data");
|
return SDL_InvalidParamError("dst_data");
|
||||||
}
|
}
|
||||||
|
if (dst_len == NULL) {
|
||||||
|
return SDL_InvalidParamError("dst_len");
|
||||||
|
}
|
||||||
|
|
||||||
*dst_len = 0;
|
|
||||||
*dst_data = NULL;
|
*dst_data = NULL;
|
||||||
|
*dst_len = 0;
|
||||||
|
|
||||||
stream = SDL_CreateAudioStream(src_format, src_channels, src_rate, dst_format, dst_channels, dst_rate);
|
stream = SDL_CreateAudioStream(src_format, src_channels, src_rate, dst_format, dst_channels, dst_rate);
|
||||||
if (stream == NULL) {
|
if (stream == NULL) {
|
||||||
|
@ -1737,8 +1737,8 @@ int SDL_ConvertAudioSamples(
|
||||||
end:
|
end:
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
SDL_free(*dst_data);
|
SDL_free(*dst_data);
|
||||||
*dst_len = 0;
|
|
||||||
*dst_data = NULL;
|
*dst_data = NULL;
|
||||||
|
*dst_len = 0;
|
||||||
}
|
}
|
||||||
SDL_DestroyAudioStream(stream);
|
SDL_DestroyAudioStream(stream);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -900,7 +900,7 @@ SDL_DYNAPI_PROC(int,SDL_GetRenderVSync,(SDL_Renderer *a, int *b),(a,b),return)
|
||||||
SDL_DYNAPI_PROC(int,SDL_PlayAudioDevice,(SDL_AudioDeviceID a),(a),return)
|
SDL_DYNAPI_PROC(int,SDL_PlayAudioDevice,(SDL_AudioDeviceID a),(a),return)
|
||||||
SDL_DYNAPI_PROC(void*,SDL_aligned_alloc,(size_t a, size_t b),(a,b),return)
|
SDL_DYNAPI_PROC(void*,SDL_aligned_alloc,(size_t a, size_t b),(a,b),return)
|
||||||
SDL_DYNAPI_PROC(void,SDL_aligned_free,(void *a),(a),)
|
SDL_DYNAPI_PROC(void,SDL_aligned_free,(void *a),(a),)
|
||||||
SDL_DYNAPI_PROC(int,SDL_ConvertAudioSamples,(SDL_AudioFormat a, Uint8 b, int c, int d, Uint8 *e, SDL_AudioFormat f, Uint8 g, int h, int *i, Uint8 **j),(a,b,c,d,e,f,g,h,i,j),return)
|
SDL_DYNAPI_PROC(int,SDL_ConvertAudioSamples,(SDL_AudioFormat a, Uint8 b, int c, const Uint8 *d, int e, SDL_AudioFormat f, Uint8 g, int h, Uint8 **i, int *j),(a,b,c,d,e,f,g,h,i,j),return)
|
||||||
SDL_DYNAPI_PROC(SDL_DisplayID*,SDL_GetDisplays,(int *a),(a),return)
|
SDL_DYNAPI_PROC(SDL_DisplayID*,SDL_GetDisplays,(int *a),(a),return)
|
||||||
SDL_DYNAPI_PROC(SDL_DisplayID,SDL_GetPrimaryDisplay,(void),(),return)
|
SDL_DYNAPI_PROC(SDL_DisplayID,SDL_GetPrimaryDisplay,(void),(),return)
|
||||||
SDL_DYNAPI_PROC(const SDL_DisplayMode**,SDL_GetFullscreenDisplayModes,(SDL_DisplayID a, int *b),(a,b),return)
|
SDL_DYNAPI_PROC(const SDL_DisplayMode**,SDL_GetFullscreenDisplayModes,(SDL_DisplayID a, int *b),(a,b),return)
|
||||||
|
|
|
@ -53,8 +53,8 @@ int main(int argc, char **argv)
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_ConvertAudioSamples(spec.format, spec.channels, spec.freq, len, data,
|
if (SDL_ConvertAudioSamples(spec.format, spec.channels, spec.freq, data, len,
|
||||||
spec.format, cvtchans, cvtfreq, &dst_len, &dst_buf) < 0) {
|
spec.format, cvtchans, cvtfreq, &dst_buf, &dst_len) < 0) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to convert samples: %s\n", SDL_GetError());
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to convert samples: %s\n", SDL_GetError());
|
||||||
ret = 4;
|
ret = 4;
|
||||||
goto end;
|
goto end;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue