[vlc-commits] [Git][videolan/vlc][3.0.x] 2 commits: aout iOS: add support for spatial audio
Hugo Beauzée-Luyssen (@chouquette)
gitlab at videolan.org
Fri Oct 22 11:37:29 UTC 2021
Hugo Beauzée-Luyssen pushed to branch 3.0.x at VideoLAN / VLC
Commits:
50b424a8 by Felix Paul Kühne at 2021-10-19T12:59:11+02:00
aout iOS: add support for spatial audio
This adds support for the spatial audio API introduced in iOS 15.
(cherry picked from commit 744248f5ee6e2ffa205e2282036f9450025bc80f)
- - - - -
9bc28dab by Felix Paul Kühne at 2021-10-19T13:00:20+02:00
NEWS: mention spatial audio on iOS/tvOS
- - - - -
2 changed files:
- NEWS
- modules/audio_output/audiounit_ios.m
Changes:
=====================================
NEWS
=====================================
@@ -1,3 +1,9 @@
+Changes between 3.0.16 and 3.0.17:
+----------------------------------
+
+Audio Output:
+ * iOS/tvOS: add support for spatial audio
+
Changes between 3.0.15 and 3.0.16:
----------------------------------
=====================================
modules/audio_output/audiounit_ios.m
=====================================
@@ -72,6 +72,21 @@ static const struct {
AU_DEV_ENCODED }, /* This can also be forced with the --spdif option */
};
+#if ((__IPHONE_OS_VERSION_MAX_ALLOWED && __IPHONE_OS_VERSION_MAX_ALLOWED < 150000) || (__TV_OS_MAX_VERSION_ALLOWED && __TV_OS_MAX_VERSION_ALLOWED < 150000))
+
+extern NSString *const AVAudioSessionSpatialAudioEnabledKey = @"AVAudioSessionSpatializationEnabledKey";
+extern NSString *const AVAudioSessionSpatialPlaybackCapabilitiesChangedNotification = @"AVAudioSessionSpatialPlaybackCapabilitiesChangedNotification";
+
+ at interface AVAudioSession (iOS15RoutingConfiguration)
+- (BOOL)setSupportsMultichannelContent:(BOOL)inValue error:(NSError **)outError;
+ at end
+
+ at interface AVAudioSessionPortDescription (iOS15RoutingConfiguration)
+ at property (readonly, getter=isSpatialAudioEnabled) BOOL spatialAudioEnabled;
+ at end
+
+#endif
+
@interface SessionManager : NSObject
{
NSMutableSet *_registeredInstances;
@@ -136,6 +151,7 @@ struct aout_sys_t
bool b_muted;
bool b_stopped;
bool b_preferred_channels_set;
+ bool b_spatial_audio_supported;
enum au_dev au_dev;
/* sw gain */
@@ -205,6 +221,23 @@ enum port_type
ca_SetAliveState(p_aout, true);
}
}
+
+- (void)handleSpatialCapabilityChange:(NSNotification *)notification
+{
+ if (@available(iOS 15.0, tvOS 15.0, *)) {
+ audio_output_t *p_aout = [self aout];
+ struct aout_sys_t *p_sys = p_aout->sys;
+ NSDictionary *userInfo = notification.userInfo;
+ BOOL spatialAudioEnabled =
+ [[userInfo valueForKey:AVAudioSessionSpatialAudioEnabledKey] boolValue];
+
+ msg_Dbg(p_aout, "Spatial Audio availability changed: %i", spatialAudioEnabled);
+
+ if (spatialAudioEnabled) {
+ aout_RestartRequest(p_aout, AOUT_RESTART_OUTPUT);
+ }
+ }
+}
@end
static void
@@ -274,6 +307,10 @@ avas_GetOptimalChannelLayout(audio_output_t *p_aout, enum port_type *pport_type,
else
port_type = PORT_TYPE_DEFAULT;
+ if (@available(iOS 15.0, tvOS 15.0, *)) {
+ p_sys->b_spatial_audio_supported = out.spatialAudioEnabled;
+ }
+
NSArray<AVAudioSessionChannelDescription *> *chans = [out channels];
if (chans.count > last_channel_count || port_type == PORT_TYPE_HDMI)
@@ -325,11 +362,11 @@ avas_GetOptimalChannelLayout(audio_output_t *p_aout, enum port_type *pport_type,
break;
}
- msg_Dbg(p_aout, "Output on %s, channel count: %u",
+ msg_Dbg(p_aout, "Output on %s, channel count: %u, spatialAudioEnabled %i",
*pport_type == PORT_TYPE_HDMI ? "HDMI" :
*pport_type == PORT_TYPE_USB ? "USB" :
*pport_type == PORT_TYPE_HEADPHONES ? "Headphones" : "Default",
- layout ? (unsigned) layout->mNumberChannelDescriptions : 2);
+ layout ? (unsigned) layout->mNumberChannelDescriptions : 2, p_sys->b_spatial_audio_supported);
*playout = layout;
return VLC_SUCCESS;
@@ -347,6 +384,9 @@ avas_SetActive(audio_output_t *p_aout, bool active, NSUInteger options)
{
ret = [instance setCategory:AVAudioSessionCategoryPlayback error:&error];
ret = ret && [instance setMode:AVAudioSessionModeMoviePlayback error:&error];
+ if (@available(iOS 15.0, tvOS 15.0, *)) {
+ ret = ret && [instance setSupportsMultichannelContent:p_sys->b_spatial_audio_supported error:&error];
+ }
ret = ret && [instance setActive:YES withOptions:options error:&error];
[[SessionManager sharedInstance] addAoutInstance: p_sys->aoutWrapper];
} else {
@@ -503,14 +543,21 @@ Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
p_sys->au_unit = NULL;
- [[NSNotificationCenter defaultCenter] addObserver:p_sys->aoutWrapper
- selector:@selector(audioSessionRouteChange:)
- name:AVAudioSessionRouteChangeNotification
- object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:p_sys->aoutWrapper
- selector:@selector(handleInterruption:)
- name:AVAudioSessionInterruptionNotification
- object:nil];
+ NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+ [notificationCenter addObserver:p_sys->aoutWrapper
+ selector:@selector(audioSessionRouteChange:)
+ name:AVAudioSessionRouteChangeNotification
+ object:nil];
+ [notificationCenter addObserver:p_sys->aoutWrapper
+ selector:@selector(handleInterruption:)
+ name:AVAudioSessionInterruptionNotification
+ object:nil];
+ if (@available(iOS 15.0, tvOS 15.0, *)) {
+ [notificationCenter addObserver:p_sys->aoutWrapper
+ selector:@selector(handleSpatialCapabilityChange:)
+ name:AVAudioSessionSpatialPlaybackCapabilitiesChangedNotification
+ object:nil];
+ }
/* Activate the AVAudioSession */
if (avas_SetActive(p_aout, true, 0) != VLC_SUCCESS)
@@ -665,6 +712,7 @@ Open(vlc_object_t *obj)
sys->b_muted = false;
sys->b_preferred_channels_set = false;
+ sys->b_spatial_audio_supported = false;
sys->au_dev = var_InheritBool(aout, "spdif") ? AU_DEV_ENCODED : AU_DEV_PCM;
aout->start = Start;
aout->stop = Stop;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/14a4dc04a504638936e28237a70fbf858b84bf7b...9bc28dabb7e17bdbc4483f7ebc74820da9c665a9
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/14a4dc04a504638936e28237a70fbf858b84bf7b...9bc28dabb7e17bdbc4483f7ebc74820da9c665a9
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list