From 2d6a9d4442b805220d5a5e11676db3e94b8b4cda Mon Sep 17 00:00:00 2001 From: sauwming Date: Tue, 27 Feb 2024 12:54:00 +0800 Subject: [PATCH] Check the availability of Metal device (#3871) --- pjmedia/src/pjmedia-videodev/metal_dev.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pjmedia/src/pjmedia-videodev/metal_dev.m b/pjmedia/src/pjmedia-videodev/metal_dev.m index ab7f3a408d..3118687739 100644 --- a/pjmedia/src/pjmedia-videodev/metal_dev.m +++ b/pjmedia/src/pjmedia-videodev/metal_dev.m @@ -217,7 +217,16 @@ static pj_status_t metal_factory_refresh(pjmedia_vid_dev_factory *f) if (@available(macOS 10.14, iOS 12.0, *)) { struct metal_dev_info *qdi; unsigned l; - + id device; + + device = MTLCreateSystemDefaultDevice(); + if (!device) { + PJ_LOG(3, (THIS_FILE, "No Metal device found")); + return PJ_SUCCESS; + } else { + [device release]; + } + /* Init output device */ qdi = &qf->dev_info[qf->dev_count++]; pj_bzero(qdi, sizeof(*qdi));