mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-30 08:27:39 +00:00
camera: SDL_GetCameraDeviceName() now follows the SDL_GetStringRule.
This commit is contained in:
parent
2ad7c70ac6
commit
5bc654aad3
4 changed files with 7 additions and 9 deletions
|
@ -230,8 +230,7 @@ extern SDL_DECLSPEC SDL_CameraSpec *SDLCALL SDL_GetCameraDeviceSupportedFormats(
|
|||
/**
|
||||
* Get the human-readable device name for a camera.
|
||||
*
|
||||
* The returned string is owned by the caller; please release it with
|
||||
* SDL_free() when done with it.
|
||||
* The returned string follows the SDL_GetStringRule.
|
||||
*
|
||||
* \param instance_id the camera device instance ID
|
||||
* \returns a human-readable device name, or NULL on error; call
|
||||
|
@ -243,7 +242,7 @@ extern SDL_DECLSPEC SDL_CameraSpec *SDLCALL SDL_GetCameraDeviceSupportedFormats(
|
|||
*
|
||||
* \sa SDL_GetCameraDevices
|
||||
*/
|
||||
extern SDL_DECLSPEC char * SDLCALL SDL_GetCameraDeviceName(SDL_CameraDeviceID instance_id);
|
||||
extern SDL_DECLSPEC const char * SDLCALL SDL_GetCameraDeviceName(SDL_CameraDeviceID instance_id);
|
||||
|
||||
/**
|
||||
* Get the position of the camera in relation to the system.
|
||||
|
|
|
@ -285,7 +285,7 @@ static void DestroyPhysicalCameraDevice(SDL_CameraDevice *device)
|
|||
camera_driver.impl.FreeDeviceHandle(device);
|
||||
SDL_DestroyMutex(device->lock);
|
||||
SDL_free(device->all_specs);
|
||||
SDL_free(device->name);
|
||||
SDL_FreeLater(device->name); // this is returned in SDL_GetCameraDeviceName.
|
||||
SDL_free(device);
|
||||
}
|
||||
}
|
||||
|
@ -662,12 +662,12 @@ int SDL_GetCameraFormat(SDL_Camera *camera, SDL_CameraSpec *spec)
|
|||
return 0;
|
||||
}
|
||||
|
||||
char *SDL_GetCameraDeviceName(SDL_CameraDeviceID instance_id)
|
||||
const char *SDL_GetCameraDeviceName(SDL_CameraDeviceID instance_id)
|
||||
{
|
||||
char *retval = NULL;
|
||||
SDL_CameraDevice *device = ObtainPhysicalCameraDevice(instance_id);
|
||||
if (device) {
|
||||
retval = SDL_strdup(device->name);
|
||||
retval = device->name;
|
||||
ReleaseCameraDevice(device);
|
||||
}
|
||||
return retval;
|
||||
|
|
|
@ -227,7 +227,7 @@ SDL_DYNAPI_PROC(char*,SDL_GetBasePath,(void),(),return)
|
|||
SDL_DYNAPI_PROC(SDL_bool,SDL_GetBooleanProperty,(SDL_PropertiesID a, const char *b, SDL_bool c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetCPUCacheLineSize,(void),(),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetCPUCount,(void),(),return)
|
||||
SDL_DYNAPI_PROC(char*,SDL_GetCameraDeviceName,(SDL_CameraDeviceID a),(a),return)
|
||||
SDL_DYNAPI_PROC(const char*,SDL_GetCameraDeviceName,(SDL_CameraDeviceID a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_CameraPosition,SDL_GetCameraDevicePosition,(SDL_CameraDeviceID a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_CameraSpec*,SDL_GetCameraDeviceSupportedFormats,(SDL_CameraDeviceID a, int *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_CameraDeviceID*,SDL_GetCameraDevices,(int *a),(a),return)
|
||||
|
|
|
@ -98,7 +98,7 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
|
|||
SDL_Log("Saw %d camera devices.", devcount);
|
||||
for (i = 0; i < devcount; i++) {
|
||||
const SDL_CameraDeviceID device = devices[i];
|
||||
char *name = SDL_GetCameraDeviceName(device);
|
||||
const char *name = SDL_GetCameraDeviceName(device);
|
||||
const SDL_CameraPosition position = SDL_GetCameraDevicePosition(device);
|
||||
const char *posstr = "";
|
||||
if (position == SDL_CAMERA_POSITION_FRONT_FACING) {
|
||||
|
@ -112,7 +112,6 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
|
|||
camera_id = device;
|
||||
}
|
||||
SDL_Log(" - Camera #%d: %s %s", i, posstr, name);
|
||||
SDL_free(name);
|
||||
}
|
||||
|
||||
if (!camera_id) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue