ao_audiounit: add --audio-exclusiv support, make non-exclusive default

This commit is contained in:
Callum Moffat
2024-12-12 23:40:10 -05:00
committed by der richter
parent 11dcd445d9
commit 748fc2b752
3 changed files with 9 additions and 3 deletions

View File

@@ -0,0 +1 @@
add --audio-exclusive option support for ao=audiounit and make non-exclusive the new default

View File

@@ -2001,8 +2001,8 @@ Audio
Enable exclusive output mode. In this mode, the system is usually locked
out, and only mpv will be able to output audio.
This only works for some audio outputs, such as ``wasapi``, ``coreaudio``
and ``pipewire``. Other audio outputs silently ignore this option.
This only works for some audio outputs, such as ``wasapi``, ``coreaudio``,
``pipewire`` and ``audiounit``. Other audio outputs silently ignore this option.
They either have no concept of exclusive mode, or the mpv side of the
implementation is missing.

View File

@@ -115,7 +115,12 @@ static bool init_audiounit(struct ao *ao)
MP_VERBOSE(ao, "max channels: %ld, requested: %d\n", maxChannels, (int)ao->channels.num);
[instance setCategory:AVAudioSessionCategoryPlayback error:nil];
AVAudioSessionCategoryOptions options = 0;
if (!(ao->init_flags & AO_INIT_EXCLUSIVE)) {
options |= AVAudioSessionCategoryOptionMixWithOthers;
}
[instance setCategory:AVAudioSessionCategoryPlayback withOptions:options error:nil];
[instance setMode:AVAudioSessionModeMoviePlayback error:nil];
[instance setActive:YES error:nil];
[instance setPreferredOutputNumberOfChannels:prefChannels error:nil];