SDL_GetCameraSupportedFormats() follows the SDL_GetStringRule
Also changed the function to return an array of pointers and added example usage to testcamera
This commit is contained in:
@@ -734,7 +734,7 @@ SDL_CameraID *SDL_GetCameras(int *count)
|
||||
return retval;
|
||||
}
|
||||
|
||||
SDL_CameraSpec *SDL_GetCameraSupportedFormats(SDL_CameraID instance_id, int *count)
|
||||
const SDL_CameraSpec * const *SDL_GetCameraSupportedFormats(SDL_CameraID instance_id, int *count)
|
||||
{
|
||||
if (count) {
|
||||
*count = 0;
|
||||
@@ -745,17 +745,25 @@ SDL_CameraSpec *SDL_GetCameraSupportedFormats(SDL_CameraID instance_id, int *cou
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_CameraSpec *retval = (SDL_CameraSpec *) SDL_calloc(device->num_specs + 1, sizeof (SDL_CameraSpec));
|
||||
int i;
|
||||
int num_specs = device->num_specs;
|
||||
const SDL_CameraSpec **retval = (const SDL_CameraSpec **) SDL_malloc(((num_specs + 1) * sizeof(SDL_CameraSpec *)) + (num_specs * sizeof (SDL_CameraSpec)));
|
||||
if (retval) {
|
||||
SDL_memcpy(retval, device->all_specs, sizeof (SDL_CameraSpec) * device->num_specs);
|
||||
SDL_CameraSpec *specs = (SDL_CameraSpec *)((Uint8 *)retval + ((num_specs + 1) * sizeof(SDL_CameraSpec *)));
|
||||
SDL_memcpy(specs, device->all_specs, sizeof (SDL_CameraSpec) * num_specs);
|
||||
for (i = 0; i < num_specs; ++i) {
|
||||
retval[i] = specs++;
|
||||
}
|
||||
retval[i] = NULL;
|
||||
|
||||
if (count) {
|
||||
*count = device->num_specs;
|
||||
*count = num_specs;
|
||||
}
|
||||
}
|
||||
|
||||
ReleaseCamera(device);
|
||||
|
||||
return retval;
|
||||
return SDL_FreeLater(retval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -232,7 +232,7 @@ SDL_DYNAPI_PROC(const char*,SDL_GetCameraName,(SDL_CameraID a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetCameraPermissionState,(SDL_Camera *a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_CameraPosition,SDL_GetCameraPosition,(SDL_CameraID a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetCameraProperties,(SDL_Camera *a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_CameraSpec*,SDL_GetCameraSupportedFormats,(SDL_CameraID a, int *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(const SDL_CameraSpec* const*,SDL_GetCameraSupportedFormats,(SDL_CameraID a, int *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_CameraID*,SDL_GetCameras,(int *a),(a),return)
|
||||
SDL_DYNAPI_PROC(void*,SDL_GetClipboardData,(const char *a, size_t *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(const char*,SDL_GetClipboardText,(void),(),return)
|
||||
|
||||
Reference in New Issue
Block a user