[vlc-commits] [Git][videolan/vlc][3.0.x] 2 commits: audiounit_ios: setup the RouteSharingPolicy
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Sun Nov 14 14:24:42 UTC 2021
Jean-Baptiste Kempf pushed to branch 3.0.x at VideoLAN / VLC
Commits:
b0bb1680 by Thomas Guillem at 2021-11-13T12:41:44+01:00
audiounit_ios: setup the RouteSharingPolicy
Starting iOS 11.0
Setting it to LongFormAudio or LongFormVideo will select audio devices
that are used for long playback (music or video) in priority.
(cherry picked from commit 5abc4ea8534128368a36c291fe38ad97f439b4f2)
Signed-off-by: Felix Paul Kühne <felix at feepk.net>
- - - - -
cf0973bb by Thomas Guillem at 2021-11-13T12:41:44+01:00
audiounit_ios: don't register the aout in case of failure
(cherry picked from commit 6fd238d9c9b7f640cd862b0ebca543ad8fb642e2)
Signed-off-by: Felix Paul Kühne <felix at feepk.net>
- - - - -
1 changed file:
- modules/audio_output/audiounit_ios.m
Changes:
=====================================
modules/audio_output/audiounit_ios.m
=====================================
@@ -372,6 +372,59 @@ avas_GetOptimalChannelLayout(audio_output_t *p_aout, enum port_type *pport_type,
return VLC_SUCCESS;
}
+struct role2policy
+{
+ char role[sizeof("accessibility")];
+ AVAudioSessionRouteSharingPolicy policy;
+};
+
+static int role2policy_cmp(const void *key, const void *val)
+{
+ const struct role2policy *entry = val;
+ return strcmp(key, entry->role);
+}
+
+static AVAudioSessionRouteSharingPolicy
+GetRouteSharingPolicy(audio_output_t *p_aout)
+{
+ /* LongFormAudio by defaut */
+ AVAudioSessionRouteSharingPolicy policy = AVAudioSessionRouteSharingPolicyLongFormAudio;
+ AVAudioSessionRouteSharingPolicy video_policy;
+#if !TARGET_OS_TV
+ if (@available(iOS 13.0, *))
+ video_policy = AVAudioSessionRouteSharingPolicyLongFormVideo;
+ else
+#endif
+ video_policy = AVAudioSessionRouteSharingPolicyLongFormAudio;
+
+ char *str = var_InheritString(p_aout, "role");
+ if (str != NULL)
+ {
+ const struct role2policy role_list[] =
+ {
+ { "accessibility", AVAudioSessionRouteSharingPolicyDefault },
+ { "animation", AVAudioSessionRouteSharingPolicyDefault },
+ { "communication", AVAudioSessionRouteSharingPolicyDefault },
+ { "game", AVAudioSessionRouteSharingPolicyLongFormAudio },
+ { "music", AVAudioSessionRouteSharingPolicyLongFormAudio },
+ { "notification", AVAudioSessionRouteSharingPolicyDefault },
+ { "production", AVAudioSessionRouteSharingPolicyDefault },
+ { "test", AVAudioSessionRouteSharingPolicyDefault },
+ { "video", video_policy},
+ };
+
+ const struct role2policy *entry =
+ bsearch(str, role_list, ARRAY_SIZE(role_list),
+ sizeof (*role_list), role2policy_cmp);
+ free(str);
+ if (entry != NULL)
+ policy = entry->policy;
+ }
+
+ return policy;
+}
+
+
static int
avas_SetActive(audio_output_t *p_aout, bool active, NSUInteger options)
{
@@ -382,13 +435,31 @@ avas_SetActive(audio_output_t *p_aout, bool active, NSUInteger options)
if (active)
{
- ret = [instance setCategory:AVAudioSessionCategoryPlayback error:&error];
- ret = ret && [instance setMode:AVAudioSessionModeMoviePlayback error:&error];
+ AVAudioSessionCategory category = AVAudioSessionCategoryPlayback;
+ AVAudioSessionMode mode = AVAudioSessionModeMoviePlayback;
+ AVAudioSessionRouteSharingPolicy policy = GetRouteSharingPolicy(p_aout);
+
+ if (@available(iOS 11.0, tvOS 11.0, *))
+ {
+ ret = [instance setCategory:category
+ mode:mode
+ routeSharingPolicy:policy
+ options:0
+ error:&error];
+ }
+ else
+ {
+ ret = [instance setCategory:category
+ error:&error];
+ ret = ret && [instance setMode:mode error:&error];
+ /* Not AVAudioSessionRouteSharingPolicy on older devices */
+ }
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];
+ if (ret)
+ [[SessionManager sharedInstance] addAoutInstance: p_sys->aoutWrapper];
} else {
NSInteger numberOfRegisteredInstances = [[SessionManager sharedInstance] removeAoutInstance: p_sys->aoutWrapper];
if (numberOfRegisteredInstances == 0) {
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fb79c1242d8c6b640124a7c36126e5002107cae8...cf0973bb7ffe26d82a8cc05551df5a78d3ec3557
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fb79c1242d8c6b640124a7c36126e5002107cae8...cf0973bb7ffe26d82a8cc05551df5a78d3ec3557
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list