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

Question: why is the AudioSession category 'playAndRecord', instead of just 'record' ? #76

Open
HectorRicardo opened this issue Aug 22, 2021 · 0 comments

Comments

@HectorRicardo
Copy link

Hello. First of all I want to thank you for developing such an amazing library.

I was going through the source code (inside the Source folder) to learn how the library is implemented. I understand all the source code and what's going one, except for two questions I've got:

  1. Check here. Why is the AudioSession category playAndRecord ? I mean, this library doesn't do playback at all. However, if I change the category to record only, an error is thrown at runtime.

  2. Check here. What is going on? The comment says //Check input type .... but it's clearly referencing currentRoute.outputs.... so is it input or output?
    I checked Apple documentation. It says this about overrideOutputAudioPort:

If your app uses the playAndRecord category, calling this method with the AVAudioSession.PortOverride.speaker option causes the system to route audio to the built-in speaker and microphone regardless of other settings. This change remains in effect only until the current route changes or you call this method again with the AVAudioSession.PortOverride.none option.

I understand the intent of the code. If we don't have any headphones (with microphone) plugged in, force the system to use the built-in mic. However, I think this falls back to these questions: 1. isn't this the default behaviour? and 2. why use category playAndRecord ?

Thanks!

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

No branches or pull requests

1 participant