Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ios/macos: use non-exclusive audio session #15506

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

moffatman
Copy link

Using this option means the OS won't pause other
sources of audio when playback starts in MPV.

This matches the behaviour on other platforms.

Copy link

github-actions bot commented Dec 13, 2024

Download the artifacts for this pull request:

Windows
macOS

@moffatman moffatman changed the title ios/macos: Use non-exclusive audio session ios/macos: use non-exclusive audio session Dec 13, 2024
@moffatman
Copy link
Author

updated the commit with desired capitalization

@llyyr
Copy link
Contributor

llyyr commented Dec 13, 2024

mpv has --audio-exclusive so the option should preferably be mapped to this AO.

@moffatman moffatman force-pushed the master branch 2 times, most recently from baf634e to 3771c60 Compare December 13, 2024 16:04
@moffatman
Copy link
Author

Good point, added it

@kasper93 kasper93 requested a review from Akemi December 13, 2024 17:47
@Akemi
Copy link
Member

Akemi commented Dec 14, 2024

the commit prefix should be ao_audiounit:. also on a side note, currently seems to be iOS/tvOS/iPadOS only because of kAudioUnitSubType_RemoteIO (https://developer.apple.com/documentation/audiotoolbox/kaudiounitsubtype_remoteio?language=objc). so no macOS support.

mpv/meson.build

Lines 811 to 817 in e52f975

audiounit_opt = get_option('audiounit').require(darwin)
audiounit = {
'deps': dependency('appleframeworks', modules: ['Foundation', 'AudioToolbox'],
required: audiounit_opt),
'symbol': cc.has_header_symbol('AudioToolbox/AudioToolbox.h', 'kAudioUnitSubType_RemoteIO',
required: audiounit_opt),
}

this change should also update the corresponding manual entry for --audio-exclusive

mpv/DOCS/man/options.rst

Lines 2000 to 2007 in e52f975

``--audio-exclusive=<yes|no>``
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.
They either have no concept of exclusive mode, or the mpv side of the
implementation is missing.

a bit OCD, in the commit message there is a double space between OS won't.

pinging @tmm1 since he did the initial implementation. i also lack any device to test this on.

[instance setCategory:AVAudioSessionCategoryPlayback error:nil];
AVAudioSessionCategoryOptions options = 0;
if (!(ao->init_flags & AO_INIT_EXCLUSIVE)) {
// Non-exclusive
Copy link
Member

@Akemi Akemi Dec 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the comment is not needed, the condition in the if should make that clear enough.

Copy link
Member

@Akemi Akemi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above.

@moffatman
Copy link
Author

Sure, updated, I just tested it on iOS only, and assumed it was macOS too. Which I guess must use coreaudio?

@tmm1
Copy link
Contributor

tmm1 commented Dec 14, 2024

seems reasonable 👍🏼

@Akemi
Copy link
Member

Akemi commented Dec 21, 2024

still missing:

  • additions to the documentation
  • removal of the unnecessary comment

besides this it LGTM, though untested.

@moffatman
Copy link
Author

Can you give me a hint towards the documentation

@llyyr
Copy link
Contributor

llyyr commented Dec 22, 2024

mpv/DOCS/man/options.rst

Lines 2000 to 2007 in d827019

``--audio-exclusive=<yes|no>``
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.
They either have no concept of exclusive mode, or the mpv side of the
implementation is missing.

Add this audio output to the list

Using this option means the OS won't pause other
sources of audio when playback starts in MPV.

But if --audio-exclusive is used, still use an exclusive session.

This should apply to iOS, iPadOS, and tvOS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants