Browse Source

avsamplebuffer: enable for visionOS

pull/162/head
Felix Paul Kühne 2 years ago
committed by Steve Lhomme
parent
commit
492a9419ce
  1. 3
      modules/audio_output/Makefile.am
  2. 34
      modules/audio_output/apple/avsamplebuffer.m

3
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

34
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)

Loading…
Cancel
Save