SDL: camera: Fixed Emscripten support.

From 405693175db7d5c076588f4cce4e1add48d8e9dd Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Mon, 19 Aug 2024 14:15:47 -0400
Subject: [PATCH] camera: Fixed Emscripten support.

---
 src/camera/SDL_camera.c                       | 2 +-
 src/camera/emscripten/SDL_camera_emscripten.c | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/camera/SDL_camera.c b/src/camera/SDL_camera.c
index a99ea3805acec..b87089e954b1d 100644
--- a/src/camera/SDL_camera.c
+++ b/src/camera/SDL_camera.c
@@ -309,7 +309,7 @@ void RefPhysicalCamera(SDL_Camera *device)
     SDL_AtomicIncRef(&device->refcount);
 }
 
-static void ObtainPhysicalCameraObj(SDL_Camera *device) SDL_NO_THREAD_SAFETY_ANALYSIS  // !!! FIXMEL SDL_ACQUIRE
+static void ObtainPhysicalCameraObj(SDL_Camera *device) SDL_NO_THREAD_SAFETY_ANALYSIS  // !!! FIXME: SDL_ACQUIRE
 {
     if (device) {
         RefPhysicalCamera(device);
diff --git a/src/camera/emscripten/SDL_camera_emscripten.c b/src/camera/emscripten/SDL_camera_emscripten.c
index 1d8b33aa9d9f7..79fa8e32303ae 100644
--- a/src/camera/emscripten/SDL_camera_emscripten.c
+++ b/src/camera/emscripten/SDL_camera_emscripten.c
@@ -90,7 +90,6 @@ static void EMSCRIPTENCAMERA_CloseDevice(SDL_Camera *device)
                 return;  // camera was closed and/or subsystem was shut down, we're already done.
             }
             SDL3.camera.stream.getTracks().forEach(track => track.stop());  // stop all recording.
-            _SDL_free(SDL3.camera.rgba);
             SDL3.camera = {};  // dump our references to everything.
         });
         SDL_free(device->hidden);
@@ -104,6 +103,10 @@ static void SDLEmscriptenCameraPermissionOutcome(SDL_Camera *device, int approve
     device->spec.height = device->actual_spec.height = h;
     device->spec.framerate_numerator = device->actual_spec.framerate_numerator = fps;
     device->spec.framerate_denominator = device->actual_spec.framerate_denominator = 1;
+    if (device->acquire_surface) {
+        device->acquire_surface->w = w;
+        device->acquire_surface->h = h;
+    }
     SDL_CameraPermissionOutcome(device, approved ? SDL_TRUE : SDL_FALSE);
 }
 
@@ -187,7 +190,6 @@ static int EMSCRIPTENCAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec
                 SDL3.camera.video = video;
                 SDL3.camera.canvas = canvas;
                 SDL3.camera.ctx2d = ctx2d;
-                SDL3.camera.rgba = 0;
                 SDL3.camera.next_frame_time = performance.now();
 
                 video.play();