mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-28 10:14:14 +00:00
Use C99 bool internally in SDL
This commit is contained in:
@@ -542,7 +542,7 @@ void SDL_CameraDisconnected(SDL_Camera *device)
|
||||
|
||||
ObtainPhysicalCameraObj(device);
|
||||
|
||||
const SDL_bool first_disconnect = SDL_AtomicCompareAndSwap(&device->zombie, 0, 1);
|
||||
const bool first_disconnect = SDL_AtomicCompareAndSwap(&device->zombie, 0, 1);
|
||||
if (first_disconnect) { // if already disconnected this device, don't do it twice.
|
||||
// Swap in "Zombie" versions of the usual platform interfaces, so the device will keep
|
||||
// making progress until the app closes it. Otherwise, streams might continue to
|
||||
@@ -580,7 +580,7 @@ void SDL_CameraDisconnected(SDL_Camera *device)
|
||||
}
|
||||
}
|
||||
|
||||
void SDL_CameraPermissionOutcome(SDL_Camera *device, SDL_bool approved)
|
||||
void SDL_CameraPermissionOutcome(SDL_Camera *device, bool approved)
|
||||
{
|
||||
if (!device) {
|
||||
return;
|
||||
@@ -618,7 +618,7 @@ void SDL_CameraPermissionOutcome(SDL_Camera *device, SDL_bool approved)
|
||||
}
|
||||
|
||||
|
||||
SDL_Camera *SDL_FindPhysicalCameraByCallback(SDL_bool (*callback)(SDL_Camera *device, void *userdata), void *userdata)
|
||||
SDL_Camera *SDL_FindPhysicalCameraByCallback(bool (*callback)(SDL_Camera *device, void *userdata), void *userdata)
|
||||
{
|
||||
if (!SDL_GetCurrentCameraDriver()) {
|
||||
SDL_SetError("Camera subsystem is not initialized");
|
||||
@@ -784,22 +784,22 @@ void SDL_CameraThreadSetup(SDL_Camera *device)
|
||||
#endif
|
||||
}
|
||||
|
||||
SDL_bool SDL_CameraThreadIterate(SDL_Camera *device)
|
||||
bool SDL_CameraThreadIterate(SDL_Camera *device)
|
||||
{
|
||||
SDL_LockMutex(device->lock);
|
||||
|
||||
if (SDL_AtomicGet(&device->shutdown)) {
|
||||
SDL_UnlockMutex(device->lock);
|
||||
return SDL_FALSE; // we're done, shut it down.
|
||||
return false; // we're done, shut it down.
|
||||
}
|
||||
|
||||
const int permission = device->permission;
|
||||
if (permission <= 0) {
|
||||
SDL_UnlockMutex(device->lock);
|
||||
return (permission < 0) ? SDL_FALSE : SDL_TRUE; // if permission was denied, shut it down. if undecided, we're done for now.
|
||||
return (permission < 0) ? false : true; // if permission was denied, shut it down. if undecided, we're done for now.
|
||||
}
|
||||
|
||||
SDL_bool failed = SDL_FALSE; // set to true if disaster worthy of treating the device as lost has happened.
|
||||
bool failed = false; // set to true if disaster worthy of treating the device as lost has happened.
|
||||
SDL_Surface *acquired = NULL;
|
||||
SDL_Surface *output_surface = NULL;
|
||||
SurfaceList *slist = NULL;
|
||||
@@ -851,7 +851,7 @@ SDL_bool SDL_CameraThreadIterate(SDL_Camera *device)
|
||||
#if DEBUG_CAMERA
|
||||
SDL_Log("CAMERA: dev[%p] error AcquireFrame: %s", device, SDL_GetError());
|
||||
#endif
|
||||
failed = SDL_TRUE;
|
||||
failed = true;
|
||||
}
|
||||
|
||||
// we can let go of the lock once we've tried to grab a frame of video and maybe moved the output frame off the empty list.
|
||||
@@ -908,7 +908,7 @@ SDL_bool SDL_CameraThreadIterate(SDL_Camera *device)
|
||||
SDL_UnlockMutex(device->lock);
|
||||
}
|
||||
|
||||
return SDL_TRUE; // always go on if not shutting down, even if device failed.
|
||||
return true; // always go on if not shutting down, even if device failed.
|
||||
}
|
||||
|
||||
void SDL_CameraThreadShutdown(SDL_Camera *device)
|
||||
@@ -1140,7 +1140,7 @@ SDL_Camera *SDL_OpenCamera(SDL_CameraID instance_id, const SDL_CameraSpec *spec)
|
||||
|
||||
// if we have to scale _and_ convert, we need a middleman surface, since we can't do both changes at once.
|
||||
if (device->needs_scaling && device->needs_conversion) {
|
||||
const SDL_bool downsampling_first = (device->needs_scaling < 0);
|
||||
const bool downsampling_first = (device->needs_scaling < 0);
|
||||
const SDL_CameraSpec *s = downsampling_first ? &device->spec : &closest;
|
||||
const SDL_PixelFormat fmt = downsampling_first ? closest.format : device->spec.format;
|
||||
device->conversion_surface = SDL_CreateSurface(s->width, s->height, fmt);
|
||||
@@ -1229,7 +1229,7 @@ SDL_Surface *SDL_AcquireCameraFrame(SDL_Camera *camera, Uint64 *timestampNS)
|
||||
slist = slist->next;
|
||||
}
|
||||
|
||||
const SDL_bool list_is_empty = (slist == slistprev);
|
||||
const bool list_is_empty = (slist == slistprev);
|
||||
if (!list_is_empty) { // report the oldest frame.
|
||||
if (timestampNS) {
|
||||
*timestampNS = slist->timestampNS;
|
||||
@@ -1398,7 +1398,7 @@ static Uint32 HashCameraID(const void *key, void *data)
|
||||
return ((Uint32) ((uintptr_t) key)) - 1;
|
||||
}
|
||||
|
||||
static SDL_bool MatchCameraID(const void *a, const void *b, void *data)
|
||||
static bool MatchCameraID(const void *a, const void *b, void *data)
|
||||
{
|
||||
return (a == b); // simple integers, just compare them as pointer values.
|
||||
}
|
||||
@@ -1419,7 +1419,7 @@ int SDL_CameraInit(const char *driver_name)
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_HashTable *device_hash = SDL_CreateHashTable(NULL, 8, HashCameraID, MatchCameraID, NukeCameraHashItem, SDL_FALSE);
|
||||
SDL_HashTable *device_hash = SDL_CreateHashTable(NULL, 8, HashCameraID, MatchCameraID, NukeCameraHashItem, false);
|
||||
if (!device_hash) {
|
||||
SDL_DestroyRWLock(device_hash_lock);
|
||||
return -1;
|
||||
@@ -1430,8 +1430,8 @@ int SDL_CameraInit(const char *driver_name)
|
||||
driver_name = SDL_GetHint(SDL_HINT_CAMERA_DRIVER);
|
||||
}
|
||||
|
||||
SDL_bool initialized = SDL_FALSE;
|
||||
SDL_bool tried_to_init = SDL_FALSE;
|
||||
bool initialized = false;
|
||||
bool tried_to_init = false;
|
||||
|
||||
if (driver_name && (*driver_name != 0)) {
|
||||
char *driver_name_copy = SDL_strdup(driver_name);
|
||||
@@ -1451,7 +1451,7 @@ int SDL_CameraInit(const char *driver_name)
|
||||
|
||||
for (int i = 0; bootstrap[i]; i++) {
|
||||
if (SDL_strcasecmp(bootstrap[i]->name, driver_attempt) == 0) {
|
||||
tried_to_init = SDL_TRUE;
|
||||
tried_to_init = true;
|
||||
SDL_zero(camera_driver);
|
||||
camera_driver.pending_events_tail = &camera_driver.pending_events;
|
||||
camera_driver.device_hash_lock = device_hash_lock;
|
||||
@@ -1459,7 +1459,7 @@ int SDL_CameraInit(const char *driver_name)
|
||||
if (bootstrap[i]->init(&camera_driver.impl)) {
|
||||
camera_driver.name = bootstrap[i]->name;
|
||||
camera_driver.desc = bootstrap[i]->desc;
|
||||
initialized = SDL_TRUE;
|
||||
initialized = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1475,7 +1475,7 @@ int SDL_CameraInit(const char *driver_name)
|
||||
continue;
|
||||
}
|
||||
|
||||
tried_to_init = SDL_TRUE;
|
||||
tried_to_init = true;
|
||||
SDL_zero(camera_driver);
|
||||
camera_driver.pending_events_tail = &camera_driver.pending_events;
|
||||
camera_driver.device_hash_lock = device_hash_lock;
|
||||
@@ -1483,7 +1483,7 @@ int SDL_CameraInit(const char *driver_name)
|
||||
if (bootstrap[i]->init(&camera_driver.impl)) {
|
||||
camera_driver.name = bootstrap[i]->name;
|
||||
camera_driver.desc = bootstrap[i]->desc;
|
||||
initialized = SDL_TRUE;
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,10 +39,10 @@ extern SDL_Camera *SDL_AddCamera(const char *name, SDL_CameraPosition position,
|
||||
extern void SDL_CameraDisconnected(SDL_Camera *device);
|
||||
|
||||
// Find an SDL_Camera, selected by a callback. NULL if not found. DOES NOT LOCK THE DEVICE.
|
||||
extern SDL_Camera *SDL_FindPhysicalCameraByCallback(SDL_bool (*callback)(SDL_Camera *device, void *userdata), void *userdata);
|
||||
extern SDL_Camera *SDL_FindPhysicalCameraByCallback(bool (*callback)(SDL_Camera *device, void *userdata), void *userdata);
|
||||
|
||||
// Backends should call this when the user has approved/denied access to a camera.
|
||||
extern void SDL_CameraPermissionOutcome(SDL_Camera *device, SDL_bool approved);
|
||||
extern void SDL_CameraPermissionOutcome(SDL_Camera *device, bool approved);
|
||||
|
||||
// Backends can call this to get a standardized name for a thread to power a specific camera device.
|
||||
extern char *SDL_GetCameraThreadName(SDL_Camera *device, char *buf, size_t buflen);
|
||||
@@ -53,7 +53,7 @@ extern void UnrefPhysicalCamera(SDL_Camera *device);
|
||||
|
||||
// These functions are the heart of the camera threads. Backends can call them directly if they aren't using the SDL-provided thread.
|
||||
extern void SDL_CameraThreadSetup(SDL_Camera *device);
|
||||
extern SDL_bool SDL_CameraThreadIterate(SDL_Camera *device);
|
||||
extern bool SDL_CameraThreadIterate(SDL_Camera *device);
|
||||
extern void SDL_CameraThreadShutdown(SDL_Camera *device);
|
||||
|
||||
// common utility functionality to gather up camera specs. Not required!
|
||||
@@ -138,8 +138,8 @@ struct SDL_Camera
|
||||
// non-zero if acquire_surface needs to be scaled for final output.
|
||||
int needs_scaling; // -1: downscale, 0: no scaling, 1: upscale
|
||||
|
||||
// SDL_TRUE if acquire_surface needs to be converted for final output.
|
||||
SDL_bool needs_conversion;
|
||||
// true if acquire_surface needs to be converted for final output.
|
||||
bool needs_conversion;
|
||||
|
||||
// Current state flags
|
||||
SDL_AtomicInt shutdown;
|
||||
@@ -169,7 +169,7 @@ typedef struct SDL_CameraDriverImpl
|
||||
void (*FreeDeviceHandle)(SDL_Camera *device); // SDL is done with this device; free the handle from SDL_AddCamera()
|
||||
void (*Deinitialize)(void);
|
||||
|
||||
SDL_bool ProvidesOwnCallbackThread;
|
||||
bool ProvidesOwnCallbackThread;
|
||||
} SDL_CameraDriverImpl;
|
||||
|
||||
typedef struct SDL_PendingCameraEvent
|
||||
@@ -198,8 +198,8 @@ typedef struct CameraBootStrap
|
||||
{
|
||||
const char *name;
|
||||
const char *desc;
|
||||
SDL_bool (*init)(SDL_CameraDriverImpl *impl);
|
||||
SDL_bool demand_only; // if SDL_TRUE: request explicitly, or it won't be available.
|
||||
bool (*init)(SDL_CameraDriverImpl *impl);
|
||||
bool demand_only; // if true: request explicitly, or it won't be available.
|
||||
} CameraBootStrap;
|
||||
|
||||
// Not all of these are available in a given build. Use #ifdefs, etc.
|
||||
|
||||
@@ -520,13 +520,13 @@ static void SDLCALL CameraPermissionCallback(void *userdata, const char *permiss
|
||||
SDL_Camera *device = (SDL_Camera *) userdata;
|
||||
if (device->hidden != NULL) { // if device was already closed, don't send an event.
|
||||
if (!granted) {
|
||||
SDL_CameraPermissionOutcome(device, SDL_FALSE); // sorry, permission denied.
|
||||
SDL_CameraPermissionOutcome(device, false); // sorry, permission denied.
|
||||
} else if (PrepareCamera(device) < 0) { // permission given? Actually open the camera now.
|
||||
// uhoh, setup failed; since the app thinks we already "opened" the device, mark it as disconnected and don't report the permission.
|
||||
SDL_CameraDisconnected(device);
|
||||
} else {
|
||||
// okay! We have permission to use the camera _and_ opening the hardware worked out, report that the camera is usable!
|
||||
SDL_CameraPermissionOutcome(device, SDL_TRUE); // go go go!
|
||||
SDL_CameraPermissionOutcome(device, true); // go go go!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -666,7 +666,7 @@ static void GatherCameraSpecs(const char *devid, CameraFormatAddData *add_data,
|
||||
pACameraMetadata_free(metadata);
|
||||
}
|
||||
|
||||
static SDL_bool FindAndroidCameraByID(SDL_Camera *device, void *userdata)
|
||||
static bool FindAndroidCameraByID(SDL_Camera *device, void *userdata)
|
||||
{
|
||||
const char *devid = (const char *) userdata;
|
||||
return (SDL_strcmp(devid, (const char *) device->handle) == 0);
|
||||
@@ -800,25 +800,25 @@ static void ANDROIDCAMERA_Deinitialize(void)
|
||||
pAImageReader_new = NULL;
|
||||
}
|
||||
|
||||
static SDL_bool ANDROIDCAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||
static bool ANDROIDCAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||
{
|
||||
// !!! FIXME: slide this off into a subroutine
|
||||
// system libraries are in android-24 and later; we currently target android-16 and later, so check if they exist at runtime.
|
||||
void *libcamera2 = dlopen("libcamera2ndk.so", RTLD_NOW | RTLD_LOCAL);
|
||||
if (!libcamera2) {
|
||||
SDL_Log("CAMERA: libcamera2ndk.so can't be loaded: %s", dlerror());
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
void *libmedia = dlopen("libmediandk.so", RTLD_NOW | RTLD_LOCAL);
|
||||
if (!libmedia) {
|
||||
SDL_Log("CAMERA: libmediandk.so can't be loaded: %s", dlerror());
|
||||
dlclose(libcamera2);
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_bool okay = SDL_TRUE;
|
||||
#define LOADSYM(lib, fn) if (okay) { p##fn = (pfn##fn) dlsym(lib, #fn); if (!p##fn) { SDL_Log("CAMERA: symbol '%s' can't be found in %s: %s", #fn, #lib "ndk.so", dlerror()); okay = SDL_FALSE; } }
|
||||
bool okay = true;
|
||||
#define LOADSYM(lib, fn) if (okay) { p##fn = (pfn##fn) dlsym(lib, #fn); if (!p##fn) { SDL_Log("CAMERA: symbol '%s' can't be found in %s: %s", #fn, #lib "ndk.so", dlerror()); okay = false; } }
|
||||
//#define LOADSYM(lib, fn) p##fn = (pfn##fn) fn
|
||||
LOADSYM(libcamera2, ACameraManager_create);
|
||||
LOADSYM(libcamera2, ACameraManager_registerAvailabilityCallback);
|
||||
@@ -867,7 +867,7 @@ static SDL_bool ANDROIDCAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||
if (CreateCameraManager() < 0) {
|
||||
dlclose(libmedia);
|
||||
dlclose(libcamera2);
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
libcamera2ndk = libcamera2;
|
||||
@@ -882,13 +882,13 @@ static SDL_bool ANDROIDCAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||
impl->FreeDeviceHandle = ANDROIDCAMERA_FreeDeviceHandle;
|
||||
impl->Deinitialize = ANDROIDCAMERA_Deinitialize;
|
||||
|
||||
impl->ProvidesOwnCallbackThread = SDL_TRUE;
|
||||
impl->ProvidesOwnCallbackThread = true;
|
||||
|
||||
return SDL_TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
CameraBootStrap ANDROIDCAMERA_bootstrap = {
|
||||
"android", "SDL Android camera driver", ANDROIDCAMERA_Init, SDL_FALSE
|
||||
"android", "SDL Android camera driver", ANDROIDCAMERA_Init, false
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -83,16 +83,16 @@ static void CoreMediaFormatToSDL(FourCharCode fmt, SDL_PixelFormat *pixel_format
|
||||
@end
|
||||
|
||||
|
||||
static SDL_bool CheckCameraPermissions(SDL_Camera *device)
|
||||
static bool CheckCameraPermissions(SDL_Camera *device)
|
||||
{
|
||||
if (device->permission == 0) { // still expecting a permission result.
|
||||
if (@available(macOS 14, *)) {
|
||||
const AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
|
||||
if (status != AVAuthorizationStatusNotDetermined) { // NotDetermined == still waiting for an answer from the user.
|
||||
SDL_CameraPermissionOutcome(device, (status == AVAuthorizationStatusAuthorized) ? SDL_TRUE : SDL_FALSE);
|
||||
SDL_CameraPermissionOutcome(device, (status == AVAuthorizationStatusAuthorized) ? true : false);
|
||||
}
|
||||
} else {
|
||||
SDL_CameraPermissionOutcome(device, SDL_TRUE); // always allowed (or just unqueryable...?) on older macOS.
|
||||
SDL_CameraPermissionOutcome(device, true); // always allowed (or just unqueryable...?) on older macOS.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,11 +408,11 @@ static void GatherCameraSpecs(AVCaptureDevice *device, CameraFormatAddData *add_
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_bool FindCoreMediaCameraByUniqueID(SDL_Camera *device, void *userdata)
|
||||
static bool FindCoreMediaCameraByUniqueID(SDL_Camera *device, void *userdata)
|
||||
{
|
||||
NSString *uniqueid = (__bridge NSString *) userdata;
|
||||
AVCaptureDevice *avdev = (__bridge AVCaptureDevice *) device->handle;
|
||||
return ([uniqueid isEqualToString:avdev.uniqueID]) ? SDL_TRUE : SDL_FALSE;
|
||||
return ([uniqueid isEqualToString:avdev.uniqueID]) ? true : false;
|
||||
}
|
||||
|
||||
static void MaybeAddDevice(AVCaptureDevice *avdevice)
|
||||
@@ -484,7 +484,7 @@ static void COREMEDIA_Deinitialize(void)
|
||||
// !!! FIXME: disable hotplug.
|
||||
}
|
||||
|
||||
static SDL_bool COREMEDIA_Init(SDL_CameraDriverImpl *impl)
|
||||
static bool COREMEDIA_Init(SDL_CameraDriverImpl *impl)
|
||||
{
|
||||
impl->DetectDevices = COREMEDIA_DetectDevices;
|
||||
impl->OpenDevice = COREMEDIA_OpenDevice;
|
||||
@@ -495,13 +495,13 @@ static SDL_bool COREMEDIA_Init(SDL_CameraDriverImpl *impl)
|
||||
impl->FreeDeviceHandle = COREMEDIA_FreeDeviceHandle;
|
||||
impl->Deinitialize = COREMEDIA_Deinitialize;
|
||||
|
||||
impl->ProvidesOwnCallbackThread = SDL_TRUE;
|
||||
impl->ProvidesOwnCallbackThread = true;
|
||||
|
||||
return SDL_TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
CameraBootStrap COREMEDIA_bootstrap = {
|
||||
"coremedia", "SDL Apple CoreMedia camera driver", COREMEDIA_Init, SDL_FALSE
|
||||
"coremedia", "SDL Apple CoreMedia camera driver", COREMEDIA_Init, false
|
||||
};
|
||||
|
||||
#endif // SDL_CAMERA_DRIVER_COREMEDIA
|
||||
|
||||
@@ -59,7 +59,7 @@ static void DUMMYCAMERA_Deinitialize(void)
|
||||
{
|
||||
}
|
||||
|
||||
static SDL_bool DUMMYCAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||
static bool DUMMYCAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||
{
|
||||
impl->DetectDevices = DUMMYCAMERA_DetectDevices;
|
||||
impl->OpenDevice = DUMMYCAMERA_OpenDevice;
|
||||
@@ -70,11 +70,11 @@ static SDL_bool DUMMYCAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||
impl->FreeDeviceHandle = DUMMYCAMERA_FreeDeviceHandle;
|
||||
impl->Deinitialize = DUMMYCAMERA_Deinitialize;
|
||||
|
||||
return SDL_TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
CameraBootStrap DUMMYCAMERA_bootstrap = {
|
||||
"dummy", "SDL dummy camera driver", DUMMYCAMERA_Init, SDL_TRUE
|
||||
"dummy", "SDL dummy camera driver", DUMMYCAMERA_Init, true
|
||||
};
|
||||
|
||||
#endif // SDL_CAMERA_DRIVER_DUMMY
|
||||
|
||||
@@ -107,7 +107,7 @@ static void SDLEmscriptenCameraPermissionOutcome(SDL_Camera *device, int approve
|
||||
device->acquire_surface->w = w;
|
||||
device->acquire_surface->h = h;
|
||||
}
|
||||
SDL_CameraPermissionOutcome(device, approved ? SDL_TRUE : SDL_FALSE);
|
||||
SDL_CameraPermissionOutcome(device, approved ? true : false);
|
||||
}
|
||||
|
||||
static int EMSCRIPTENCAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
|
||||
@@ -234,7 +234,7 @@ static void EMSCRIPTENCAMERA_DetectDevices(void)
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_bool EMSCRIPTENCAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||
static bool EMSCRIPTENCAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||
{
|
||||
MAIN_THREAD_EM_ASM({
|
||||
if (typeof(Module['SDL3']) === 'undefined') {
|
||||
@@ -252,13 +252,13 @@ static SDL_bool EMSCRIPTENCAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||
impl->FreeDeviceHandle = EMSCRIPTENCAMERA_FreeDeviceHandle;
|
||||
impl->Deinitialize = EMSCRIPTENCAMERA_Deinitialize;
|
||||
|
||||
impl->ProvidesOwnCallbackThread = SDL_TRUE;
|
||||
impl->ProvidesOwnCallbackThread = true;
|
||||
|
||||
return SDL_TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
CameraBootStrap EMSCRIPTENCAMERA_bootstrap = {
|
||||
"emscripten", "SDL Emscripten MediaStream camera driver", EMSCRIPTENCAMERA_Init, SDL_FALSE
|
||||
"emscripten", "SDL Emscripten MediaStream camera driver", EMSCRIPTENCAMERA_Init, false
|
||||
};
|
||||
|
||||
/* *INDENT-ON* */ // clang-format on
|
||||
|
||||
@@ -821,7 +821,7 @@ static int MEDIAFOUNDATION_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *
|
||||
IMFMediaSource_Release(source); // srcreader is holding a reference to this.
|
||||
|
||||
// There is no user permission prompt for camera access (I think?)
|
||||
SDL_CameraPermissionOutcome(device, SDL_TRUE);
|
||||
SDL_CameraPermissionOutcome(device, true);
|
||||
|
||||
#undef CHECK_HRESULT
|
||||
|
||||
@@ -962,7 +962,7 @@ static void GatherCameraSpecs(IMFMediaSource *source, CameraFormatAddData *add_d
|
||||
IMFPresentationDescriptor_Release(presentdesc);
|
||||
}
|
||||
|
||||
static SDL_bool FindMediaFoundationCameraBySymlink(SDL_Camera *device, void *userdata)
|
||||
static bool FindMediaFoundationCameraBySymlink(SDL_Camera *device, void *userdata)
|
||||
{
|
||||
return (SDL_strcmp((const char *) device->handle, (const char *) userdata) == 0);
|
||||
}
|
||||
@@ -1051,29 +1051,29 @@ static void MEDIAFOUNDATION_Deinitialize(void)
|
||||
pMFGetStrideForBitmapInfoHeader = NULL;
|
||||
}
|
||||
|
||||
static SDL_bool MEDIAFOUNDATION_Init(SDL_CameraDriverImpl *impl)
|
||||
static bool MEDIAFOUNDATION_Init(SDL_CameraDriverImpl *impl)
|
||||
{
|
||||
// !!! FIXME: slide this off into a subroutine
|
||||
HMODULE mf = LoadLibrary(TEXT("Mf.dll")); // this library is available in Vista and later, but also can be on XP with service packs and Windows
|
||||
if (!mf) {
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
HMODULE mfplat = LoadLibrary(TEXT("Mfplat.dll")); // this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now!
|
||||
if (!mfplat) {
|
||||
FreeLibrary(mf);
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
HMODULE mfreadwrite = LoadLibrary(TEXT("Mfreadwrite.dll")); // this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now!
|
||||
if (!mfreadwrite) {
|
||||
FreeLibrary(mfplat);
|
||||
FreeLibrary(mf);
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_bool okay = SDL_TRUE;
|
||||
#define LOADSYM(lib, fn) if (okay) { p##fn = (pfn##fn) GetProcAddress(lib, #fn); if (!p##fn) { okay = SDL_FALSE; } }
|
||||
bool okay = true;
|
||||
#define LOADSYM(lib, fn) if (okay) { p##fn = (pfn##fn) GetProcAddress(lib, #fn); if (!p##fn) { okay = false; } }
|
||||
LOADSYM(mf, MFEnumDeviceSources);
|
||||
LOADSYM(mf, MFCreateDeviceSource);
|
||||
LOADSYM(mfplat, MFStartup);
|
||||
@@ -1087,7 +1087,7 @@ static SDL_bool MEDIAFOUNDATION_Init(SDL_CameraDriverImpl *impl)
|
||||
if (okay) {
|
||||
const HRESULT ret = pMFStartup(MF_VERSION, MFSTARTUP_LITE);
|
||||
if (FAILED(ret)) {
|
||||
okay = SDL_FALSE;
|
||||
okay = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1095,7 +1095,7 @@ static SDL_bool MEDIAFOUNDATION_Init(SDL_CameraDriverImpl *impl)
|
||||
FreeLibrary(mfreadwrite);
|
||||
FreeLibrary(mfplat);
|
||||
FreeLibrary(mf);
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
libmf = mf;
|
||||
@@ -1111,11 +1111,11 @@ static SDL_bool MEDIAFOUNDATION_Init(SDL_CameraDriverImpl *impl)
|
||||
impl->FreeDeviceHandle = MEDIAFOUNDATION_FreeDeviceHandle;
|
||||
impl->Deinitialize = MEDIAFOUNDATION_Deinitialize;
|
||||
|
||||
return SDL_TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
CameraBootStrap MEDIAFOUNDATION_bootstrap = {
|
||||
"mediafoundation", "SDL Windows Media Foundation camera driver", MEDIAFOUNDATION_Init, SDL_FALSE
|
||||
"mediafoundation", "SDL Windows Media Foundation camera driver", MEDIAFOUNDATION_Init, false
|
||||
};
|
||||
|
||||
#endif // SDL_CAMERA_DRIVER_MEDIAFOUNDATION
|
||||
|
||||
@@ -54,7 +54,7 @@ enum PW_READY_FLAGS
|
||||
#define PW_ID_TO_HANDLE(x) (void *)((uintptr_t)x)
|
||||
#define PW_HANDLE_TO_ID(x) (uint32_t)((uintptr_t)x)
|
||||
|
||||
static SDL_bool pipewire_initialized = SDL_FALSE;
|
||||
static bool pipewire_initialized = false;
|
||||
|
||||
// Pipewire entry points
|
||||
static const char *(*PIPEWIRE_pw_get_library_version)(void);
|
||||
@@ -232,9 +232,9 @@ static struct
|
||||
|
||||
struct spa_list global_list;
|
||||
|
||||
SDL_bool have_1_0_5;
|
||||
SDL_bool init_complete;
|
||||
SDL_bool events_enabled;
|
||||
bool have_1_0_5;
|
||||
bool init_complete;
|
||||
bool events_enabled;
|
||||
} hotplug;
|
||||
|
||||
struct global
|
||||
@@ -258,7 +258,7 @@ struct global
|
||||
struct spa_list pending_list;
|
||||
struct spa_list param_list;
|
||||
|
||||
SDL_bool added;
|
||||
bool added;
|
||||
};
|
||||
|
||||
struct global_class
|
||||
@@ -434,7 +434,7 @@ static void on_stream_state_changed(void *data, enum pw_stream_state old,
|
||||
case PW_STREAM_STATE_UNCONNECTED:
|
||||
break;
|
||||
case PW_STREAM_STATE_STREAMING:
|
||||
SDL_CameraPermissionOutcome(device, SDL_TRUE);
|
||||
SDL_CameraPermissionOutcome(device, true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -722,7 +722,7 @@ static void add_device(struct global *g)
|
||||
}
|
||||
SDL_free(data.specs);
|
||||
|
||||
g->added = SDL_TRUE;
|
||||
g->added = true;
|
||||
}
|
||||
|
||||
static void PIPEWIRECAMERA_DetectDevices(void)
|
||||
@@ -742,7 +742,7 @@ static void PIPEWIRECAMERA_DetectDevices(void)
|
||||
}
|
||||
}
|
||||
|
||||
hotplug.events_enabled = SDL_TRUE;
|
||||
hotplug.events_enabled = true;
|
||||
|
||||
PIPEWIRE_pw_thread_loop_unlock(hotplug.loop);
|
||||
}
|
||||
@@ -954,7 +954,7 @@ static void hotplug_core_done_callback(void *object, uint32_t id, int seq)
|
||||
add_device(g);
|
||||
}
|
||||
}
|
||||
hotplug.init_complete = SDL_TRUE;
|
||||
hotplug.init_complete = true;
|
||||
PIPEWIRE_pw_thread_loop_signal(hotplug.loop, false);
|
||||
}
|
||||
}
|
||||
@@ -968,7 +968,7 @@ static const struct pw_core_events hotplug_core_events =
|
||||
/* When in a container, the library version can differ from the underlying core version,
|
||||
* so make sure the underlying Pipewire implementation meets the version requirement.
|
||||
*/
|
||||
static SDL_bool pipewire_server_version_at_least(int major, int minor, int patch)
|
||||
static bool pipewire_server_version_at_least(int major, int minor, int patch)
|
||||
{
|
||||
return (hotplug.server_major >= major) &&
|
||||
(hotplug.server_major > major || hotplug.server_minor >= minor) &&
|
||||
@@ -1055,23 +1055,23 @@ static void PIPEWIRECAMERA_Deinitialize(void)
|
||||
}
|
||||
deinit_pipewire_library();
|
||||
spa_zero(hotplug);
|
||||
pipewire_initialized = SDL_FALSE;
|
||||
pipewire_initialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_bool PIPEWIRECAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||
static bool PIPEWIRECAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||
{
|
||||
if (!pipewire_initialized) {
|
||||
|
||||
if (init_pipewire_library() < 0) {
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
pipewire_initialized = SDL_TRUE;
|
||||
pipewire_initialized = true;
|
||||
|
||||
if (hotplug_loop_init() < 0) {
|
||||
PIPEWIRECAMERA_Deinitialize();
|
||||
return SDL_FALSE;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1084,11 +1084,11 @@ static SDL_bool PIPEWIRECAMERA_Init(SDL_CameraDriverImpl *impl)
|
||||
impl->FreeDeviceHandle = PIPEWIRECAMERA_FreeDeviceHandle;
|
||||
impl->Deinitialize = PIPEWIRECAMERA_Deinitialize;
|
||||
|
||||
return SDL_TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
CameraBootStrap PIPEWIRECAMERA_bootstrap = {
|
||||
"pipewire", "SDL PipeWire camera driver", PIPEWIRECAMERA_Init, SDL_FALSE
|
||||
"pipewire", "SDL PipeWire camera driver", PIPEWIRECAMERA_Init, false
|
||||
};
|
||||
|
||||
#endif // SDL_CAMERA_DRIVER_PIPEWIRE
|
||||
|
||||
@@ -601,7 +601,7 @@ static int V4L2_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
|
||||
}
|
||||
|
||||
size_t size, pitch;
|
||||
SDL_CalculateSurfaceSize(device->spec.format, device->spec.width, device->spec.height, &size, &pitch, SDL_FALSE);
|
||||
SDL_CalculateSurfaceSize(device->spec.format, device->spec.width, device->spec.height, &size, &pitch, false);
|
||||
|
||||
int rc = 0;
|
||||
switch (io) {
|
||||
@@ -634,12 +634,12 @@ static int V4L2_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
|
||||
}
|
||||
|
||||
// Currently there is no user permission prompt for camera access, but maybe there will be a D-Bus portal interface at some point.
|
||||
SDL_CameraPermissionOutcome(device, SDL_TRUE);
|
||||
SDL_CameraPermissionOutcome(device, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static SDL_bool FindV4L2CameraByBusInfoCallback(SDL_Camera *device, void *userdata)
|
||||
static bool FindV4L2CameraByBusInfoCallback(SDL_Camera *device, void *userdata)
|
||||
{
|
||||
const V4L2DeviceHandle *handle = (const V4L2DeviceHandle *) device->handle;
|
||||
return (SDL_strcmp(handle->bus_info, (const char *) userdata) == 0);
|
||||
@@ -820,7 +820,7 @@ static void V4L2_FreeDeviceHandle(SDL_Camera *device)
|
||||
}
|
||||
|
||||
#ifdef SDL_USE_LIBUDEV
|
||||
static SDL_bool FindV4L2CameraByPathCallback(SDL_Camera *device, void *userdata)
|
||||
static bool FindV4L2CameraByPathCallback(SDL_Camera *device, void *userdata)
|
||||
{
|
||||
const V4L2DeviceHandle *handle = (const V4L2DeviceHandle *) device->handle;
|
||||
return (SDL_strcmp(handle->path, (const char *) userdata) == 0);
|
||||
@@ -878,7 +878,7 @@ static void V4L2_DetectDevices(void)
|
||||
#endif // SDL_USE_LIBUDEV
|
||||
}
|
||||
|
||||
static SDL_bool V4L2_Init(SDL_CameraDriverImpl *impl)
|
||||
static bool V4L2_Init(SDL_CameraDriverImpl *impl)
|
||||
{
|
||||
impl->DetectDevices = V4L2_DetectDevices;
|
||||
impl->OpenDevice = V4L2_OpenDevice;
|
||||
@@ -889,11 +889,11 @@ static SDL_bool V4L2_Init(SDL_CameraDriverImpl *impl)
|
||||
impl->FreeDeviceHandle = V4L2_FreeDeviceHandle;
|
||||
impl->Deinitialize = V4L2_Deinitialize;
|
||||
|
||||
return SDL_TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
CameraBootStrap V4L2_bootstrap = {
|
||||
"v4l2", "SDL Video4Linux2 camera driver", V4L2_Init, SDL_FALSE
|
||||
"v4l2", "SDL Video4Linux2 camera driver", V4L2_Init, false
|
||||
};
|
||||
|
||||
#endif // SDL_CAMERA_DRIVER_V4L2
|
||||
|
||||
Reference in New Issue
Block a user