From 9a2462391b46aa388f5d4e0102ef4ee74df2f8f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Brzezi=C5=84ski?= Date: Tue, 28 Feb 2023 15:26:45 +0100 Subject: [PATCH] vtenc: Fix checking for certain CPU variants when running in VMs These checks were introduced to prevent exposing ARGB64/RGBA64 in the caps when running on M1 Pro/Max with macOS <13 because of a bug in VideoToolbox. Unfortunately, the initial buffer size of 15 is too short when running in a VM - the CPU brand string there looks like "Apple M1 Pro (Virtual)", which due to its length causes sysctlbyname to return -1, resulting in broken formats still showing up in the caps. Part-of: --- subprojects/gst-plugins-bad/sys/applemedia/vtenc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/applemedia/vtenc.c b/subprojects/gst-plugins-bad/sys/applemedia/vtenc.c index c8babd8d86..782cdb08ed 100644 --- a/subprojects/gst-plugins-bad/sys/applemedia/vtenc.c +++ b/subprojects/gst-plugins-bad/sys/applemedia/vtenc.c @@ -234,8 +234,8 @@ gst_vtenc_base_init (GstVTEncClass * klass) #ifndef HAVE_IOS gboolean enable_argb = TRUE; int retval; - char cpu_name[15]; - size_t cpu_len = 15; + char cpu_name[30]; + size_t cpu_len = 30; if (__builtin_available (macOS 13.0, *)) { /* Can't negate a __builtin_available check */ @@ -247,8 +247,12 @@ gst_vtenc_base_init (GstVTEncClass * klass) if (retval == 0 && (strstr (cpu_name, "M1 Pro") != NULL || - strstr (cpu_name, "M1 Max") != NULL)) + strstr (cpu_name, "M1 Max") != NULL)) { + GST_WARNING + ("Disabling ARGB64/RGBA64 caps due to a bug in VideoToolbox " + "on M1 Pro/Max running macOS < 13.0."); enable_argb = FALSE; + } } if (enable_argb) {