[FFmpeg-devel] [PATCH 1/2] avfoundation: Fix compilation for OSes other than macOS and iOS

Martin Storsjö martin at martin.st
Tue Apr 1 19:01:53 EEST 2025


E.g. tvOS doesn't have devicesWithMediaType.

In principle, we could probably disable building the whole
input device on such OSes, but that would either require
testing explicitly for the OS type in configure (which we don't
do anywhere so far), or test for individual objective C methods.

This approach allows the code to compile, but no input devices
will be found at runtime.
---
 libavdevice/avfoundation.m | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index 61dac4b713..6f15e2837e 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -814,8 +814,10 @@ static int get_audio_config(AVFormatContext *s)
                               mediaType:mediaType
                                position:AVCaptureDevicePositionUnspecified];
     return [captureDeviceDiscoverySession devices];
-#else
+#elif TARGET_OS_OSX
     return [AVCaptureDevice devicesWithMediaType:mediaType];
+#else
+    return nil;
 #endif
 }
 
-- 
2.39.5 (Apple Git-154)



More information about the ffmpeg-devel mailing list