[vlc-commits] [Git][videolan/vlc][master] 3 commits: avsamplebuffer: enable for visionOS

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Tue Jun 4 08:07:16 UTC 2024



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
492a9419 by Felix Paul Kühne at 2024-06-04T07:33:04+00:00
avsamplebuffer: enable for visionOS

- - - - -
6efd3de7 by Felix Paul Kühne at 2024-06-04T07:33:04+00:00
AVAudioSession: enable for visionOS

This also enables spatial audio if requested by the user

- - - - -
d7d6e180 by Felix Paul Kühne at 2024-06-04T07:33:04+00:00
AVAudioSession: set fixed spatial experience on visionOS

- - - - -


3 changed files:

- modules/audio_output/Makefile.am
- modules/audio_output/apple/avaudiosession_common.m
- modules/audio_output/apple/avsamplebuffer.m


Changes:

=====================================
modules/audio_output/Makefile.am
=====================================
@@ -125,6 +125,9 @@ endif
 if HAVE_TVOS
 libavsamplebuffer_plugin_la_SOURCES += audio_output/apple/avaudiosession_common.m
 endif
+if HAVE_XROS
+libavsamplebuffer_plugin_la_SOURCES += audio_output/apple/avaudiosession_common.m
+endif
 libavsamplebuffer_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(aoutdir)' \
 	-Wl,-framework,CoreMedia,-framework,Foundation,-framework,AVFoundation
 libavsamplebuffer_plugin_la_OBJCFLAGS = $(AM_OBJCFLAGS) -fobjc-arc


=====================================
modules/audio_output/apple/avaudiosession_common.m
=====================================
@@ -29,6 +29,16 @@
 #import <AVFoundation/AVFoundation.h>
 #import "avaudiosession_common.h"
 
+// work-around to fix compilation on older Xcode releases
+#if defined(TARGET_OS_VISION) && TARGET_OS_VISION
+#define MIN_VISIONOS 1.0
+#define VISIONOS_API_AVAILABLE , visionos(MIN_VISIONOS)
+#define VISIONOS_AVAILABLE , visionOS MIN_VISIONOS
+#else
+#define VISIONOS_API_AVAILABLE
+#define VISIONOS_AVAILABLE
+#endif
+
 void
 avas_PrepareFormat(audio_output_t *p_aout, AVAudioSession *instance,
                    audio_sample_format_t *fmt, bool spatial_audio)
@@ -61,7 +71,7 @@ avas_PrepareFormat(audio_output_t *p_aout, AVAudioSession *instance,
 
     if (spatial_audio)
     {
-        if (@available(iOS 15.0, tvOS 15.0, *))
+        if (@available(iOS 15.0, tvOS 15.0 VISIONOS_AVAILABLE, *))
         {
             /* Not mandatory, SpatialAudio can work without it. It just signals to
              * the user that he is playing spatial content */
@@ -117,21 +127,21 @@ avas_GetPortType(audio_output_t *p_aout, AVAudioSession *instance,
     return VLC_SUCCESS;
 }
 
-struct API_AVAILABLE(ios(11.0))
+struct API_AVAILABLE(ios(11.0) VISIONOS_API_AVAILABLE)
 role2policy
 {
     char role[sizeof("accessibility")];
     AVAudioSessionRouteSharingPolicy policy;
 };
 
-static int API_AVAILABLE(ios(11.0))
+static int API_AVAILABLE(ios(11.0) VISIONOS_API_AVAILABLE)
 role2policy_cmp(const void *key, const void *val)
 {
     const struct role2policy *entry = val;
     return strcmp(key, entry->role);
 }
 
-static AVAudioSessionRouteSharingPolicy API_AVAILABLE(ios(11.0))
+static AVAudioSessionRouteSharingPolicy API_AVAILABLE(ios(11.0) VISIONOS_API_AVAILABLE)
 GetRouteSharingPolicy(audio_output_t *p_aout)
 {
 #if __IPHONEOS_VERSION_MAX_ALLOWED < 130000
@@ -144,7 +154,7 @@ GetRouteSharingPolicy(audio_output_t *p_aout)
     AVAudioSessionRouteSharingPolicy policy = AVAudioSessionRouteSharingPolicyLongFormAudio;
     AVAudioSessionRouteSharingPolicy video_policy;
 #if !TARGET_OS_TV
-    if (@available(iOS 13.0, *))
+    if (@available(iOS 13.0 VISIONOS_AVAILABLE, *))
         video_policy = AVAudioSessionRouteSharingPolicyLongFormVideo;
     else
 #endif
@@ -188,7 +198,7 @@ avas_SetActive(audio_output_t *p_aout, AVAudioSession *instance, bool active,
 
     if (active)
     {
-        if (@available(iOS 11.0, tvOS 11.0, *))
+        if (@available(iOS 11.0, tvOS 11.0 VISIONOS_AVAILABLE, *))
         {
             AVAudioSessionRouteSharingPolicy policy = GetRouteSharingPolicy(p_aout);
 
@@ -207,6 +217,11 @@ avas_SetActive(audio_output_t *p_aout, AVAudioSession *instance, bool active,
             /* Not AVAudioSessionRouteSharingPolicy on older devices */
         }
         ret = ret && [instance setActive:YES withOptions:options error:&error];
+#if TARGET_OS_VISION
+        ret = ret && [instance setIntendedSpatialExperience:AVAudioSessionSpatialExperienceFixed
+                                                    options:nil
+                                                      error:&error];
+#endif
         if (ret)
             vlc_atomic_rc_inc(&active_rc);
     } else {


=====================================
modules/audio_output/apple/avsamplebuffer.m
=====================================
@@ -28,7 +28,7 @@
 #import <vlc_plugin.h>
 #import <vlc_aout.h>
 
-#if TARGET_OS_IPHONE || TARGET_OS_TV
+#if TARGET_OS_IPHONE || TARGET_OS_TV || TARGET_OS_VISION
 #define HAS_AVAUDIOSESSION
 #import "avaudiosession_common.h"
 #endif
@@ -40,9 +40,19 @@
 #define MIN_IOS 14.5
 #define MIN_TVOS 14.5
 
+// work-around to fix compilation on older Xcode releases
+#if defined(TARGET_OS_VISION) && TARGET_OS_VISION
+    #define MIN_VISIONOS 1.0
+    #define VISIONOS_API_AVAILABLE , visionos(MIN_VISIONOS)
+    #define VISIONOS_AVAILABLE , visionOS MIN_VISIONOS
+#else
+    #define VISIONOS_API_AVAILABLE
+    #define VISIONOS_AVAILABLE
+#endif
+
 #pragma mark Private
 
-API_AVAILABLE(macos(MIN_MACOS), ios(MIN_IOS), tvos(MIN_TVOS))
+API_AVAILABLE(macos(MIN_MACOS), ios(MIN_IOS), tvos(MIN_TVOS) VISIONOS_API_AVAILABLE)
 @interface VLCAVSample : NSObject
 {
     audio_output_t *_aout;
@@ -449,7 +459,7 @@ error_avas:
 
 @end
 
-static int API_AVAILABLE(macos(MIN_MACOS), ios(MIN_IOS), tvos(MIN_TVOS))
+static int API_AVAILABLE(macos(MIN_MACOS), ios(MIN_IOS), tvos(MIN_TVOS) VISIONOS_API_AVAILABLE)
 DeviceSelect(audio_output_t *aout, const char *name)
 {
     VLCAVSample *sys = (__bridge VLCAVSample*)aout->sys;
@@ -459,7 +469,7 @@ DeviceSelect(audio_output_t *aout, const char *name)
     return VLC_SUCCESS;
 }
 
-static int API_AVAILABLE(macos(MIN_MACOS), ios(MIN_IOS), tvos(MIN_TVOS))
+static int API_AVAILABLE(macos(MIN_MACOS), ios(MIN_IOS), tvos(MIN_TVOS) VISIONOS_API_AVAILABLE)
 MuteSet(audio_output_t *aout, bool mute)
 {
     VLCAVSample *sys = (__bridge VLCAVSample*)aout->sys;
@@ -469,7 +479,7 @@ MuteSet(audio_output_t *aout, bool mute)
     return VLC_SUCCESS;
 }
 
-static int API_AVAILABLE(macos(MIN_MACOS), ios(MIN_IOS), tvos(MIN_TVOS))
+static int API_AVAILABLE(macos(MIN_MACOS), ios(MIN_IOS), tvos(MIN_TVOS) VISIONOS_API_AVAILABLE)
 VolumeSet(audio_output_t *aout, float volume)
 {
     VLCAVSample *sys = (__bridge VLCAVSample*)aout->sys;
@@ -479,7 +489,7 @@ VolumeSet(audio_output_t *aout, float volume)
     return VLC_SUCCESS;
 }
 
-static void API_AVAILABLE(macos(MIN_MACOS), ios(MIN_IOS), tvos(MIN_TVOS))
+static void API_AVAILABLE(macos(MIN_MACOS), ios(MIN_IOS), tvos(MIN_TVOS) VISIONOS_API_AVAILABLE)
 Flush(audio_output_t *aout)
 {
     VLCAVSample *sys = (__bridge VLCAVSample*)aout->sys;
@@ -487,7 +497,7 @@ Flush(audio_output_t *aout)
     [sys flush];
 }
 
-static void API_AVAILABLE(macos(MIN_MACOS), ios(MIN_IOS), tvos(MIN_TVOS))
+static void API_AVAILABLE(macos(MIN_MACOS), ios(MIN_IOS), tvos(MIN_TVOS) VISIONOS_API_AVAILABLE)
 Pause(audio_output_t *aout, bool pause, vlc_tick_t date)
 {
     VLCAVSample *sys = (__bridge VLCAVSample*)aout->sys;
@@ -495,7 +505,7 @@ Pause(audio_output_t *aout, bool pause, vlc_tick_t date)
     [sys pause:pause date:date];
 }
 
-static void API_AVAILABLE(macos(MIN_MACOS), ios(MIN_IOS), tvos(MIN_TVOS))
+static void API_AVAILABLE(macos(MIN_MACOS), ios(MIN_IOS), tvos(MIN_TVOS) VISIONOS_API_AVAILABLE)
 Play(audio_output_t *aout, block_t *block, vlc_tick_t date)
 {
     VLCAVSample *sys = (__bridge VLCAVSample*)aout->sys;
@@ -503,7 +513,7 @@ Play(audio_output_t *aout, block_t *block, vlc_tick_t date)
     [sys play:block date:date];
 }
 
-static void API_AVAILABLE(macos(MIN_MACOS), ios(MIN_IOS), tvos(MIN_TVOS))
+static void API_AVAILABLE(macos(MIN_MACOS), ios(MIN_IOS), tvos(MIN_TVOS) VISIONOS_API_AVAILABLE)
 Stop(audio_output_t *aout)
 {
     VLCAVSample *sys = (__bridge VLCAVSample*)aout->sys;
@@ -511,7 +521,7 @@ Stop(audio_output_t *aout)
     [sys stop];
 }
 
-static int API_AVAILABLE(macos(MIN_MACOS), ios(MIN_IOS), tvos(MIN_TVOS))
+static int API_AVAILABLE(macos(MIN_MACOS), ios(MIN_IOS), tvos(MIN_TVOS) VISIONOS_API_AVAILABLE)
 Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
 {
     VLCAVSample *sys = (__bridge VLCAVSample*)aout->sys;
@@ -522,7 +532,7 @@ Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
 static void
 Close(vlc_object_t *obj)
 {
-    if (@available(macOS MIN_MACOS, iOS MIN_IOS, tvOS MIN_TVOS, *))
+    if (@available(macOS MIN_MACOS, iOS MIN_IOS, tvOS MIN_TVOS VISIONOS_AVAILABLE, *))
     {
         audio_output_t *aout = (audio_output_t *)obj;
         /* Transfer ownership back from VLC to ARC so that it can be released. */
@@ -536,7 +546,7 @@ Open(vlc_object_t *obj)
 {
     audio_output_t *aout = (audio_output_t *)obj;
 
-    if (@available(macOS MIN_MACOS, iOS MIN_IOS, tvOS MIN_TVOS, *))
+    if (@available(macOS MIN_MACOS, iOS MIN_IOS, tvOS MIN_TVOS VISIONOS_AVAILABLE, *))
     {
         aout->sys = (__bridge_retained void*) [[VLCAVSample alloc] init:aout];
         if (aout->sys == nil)



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d08e446a0fa17b183a537b32ffef783386af79fa...d7d6e1801e556fdfc651b721f6652604bc93ec4e

-- 
This project does not include diff previews in email notifications.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d08e446a0fa17b183a537b32ffef783386af79fa...d7d6e1801e556fdfc651b721f6652604bc93ec4e
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list