Skip to content

Commit

Permalink
ao_audiounit: add --audio-exclusiv support, make non-exclusive default
Browse files Browse the repository at this point in the history
  • Loading branch information
moffatman authored and Akemi committed Dec 31, 2024
1 parent 11dcd44 commit 748fc2b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions DOCS/interface-changes/audiounit-exclusive.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add --audio-exclusive option support for ao=audiounit and make non-exclusive the new default
4 changes: 2 additions & 2 deletions DOCS/man/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
7 changes: 6 additions & 1 deletion audio/out/ao_audiounit.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 748fc2b

Please sign in to comment.