2828/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
2929/* ************************************************************************/
3030
31- // /@TODO this is a near duplicate of CameraOSX , we should find a way to combine those to minimize code duplication!!!!
31+ // /@TODO this is a near duplicate of CameraMacOS , we should find a way to combine those to minimize code duplication!!!!
3232// If you fix something here, make sure you fix it there as wel!
3333
3434#include " camera_ios.h"
@@ -182,12 +182,12 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM
182182#if VERSION_MAJOR == 4
183183 uint8_t *w = img_data[0 ].ptrw ();
184184 memcpy (w, dataY, new_width * new_height);
185+ img[0 ].instantiate ();
185186#else
186187 GodotUInt8Vector::Write w = img_data[0 ].write ();
187188 memcpy (w.ptr (), dataY, new_width * new_height);
188- #endif
189-
190189 img[0 ].instance ();
190+ #endif
191191 img[0 ]->create (new_width, new_height, 0 , Image::FORMAT_R8, img_data[0 ]);
192192 }
193193
@@ -205,13 +205,14 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM
205205#if VERSION_MAJOR == 4
206206 uint8_t *w = img_data[1 ].ptrw ();
207207 memcpy (w, dataCbCr, 2 * new_width * new_height);
208+ img[1 ].instantiate ();
208209#else
209210 GodotUInt8Vector::Write w = img_data[1 ].write ();
210211 memcpy (w.ptr (), dataCbCr, 2 * new_width * new_height);
212+ img[1 ].instance ();
211213#endif
212214
213215 // /TODO GLES2 doesn't support FORMAT_RG8, need to do some form of conversion
214- img[1 ].instance ();
215216 img[1 ]->create (new_width, new_height, 0 , Image::FORMAT_RG8, img_data[1 ]);
216217 }
217218
@@ -358,7 +359,7 @@ - (void)dealloc {
358359MyDeviceNotifications *device_notifications = nil ;
359360
360361// ////////////////////////////////////////////////////////////////////////
361- // CameraIOS - Subclass for our camera server on iPhone
362+ // CameraIOS - Subclass for our camera server on iOS
362363
363364void CameraIOS::update_feeds () {
364365 // this way of doing things is deprecated but still works,
@@ -410,7 +411,11 @@ - (void)dealloc {
410411
411412 if (!found) {
412413 Ref<CameraFeedIOS> newfeed;
414+ #if VERSION_MAJOR == 4
415+ newfeed.instantiate ();
416+ #else
413417 newfeed.instance ();
418+ #endif
414419 newfeed->set_device (device);
415420 add_feed (newfeed);
416421 }
0 commit comments