[video_player_avfoundation, camera_avfoundation] never overwrite but only upgrade audio session category
Setting category of AVAudioSession was moved into a wrapper which ensures that only changes which do not disable the ability to play in silent mode (play) and ability to record (record) are considered. If either the new category or old category is play/record then also the set category will be play/record. This currently means that the video player will not overwrite PlayAndRecord with Playback which causes inability to record audio by camera. Options are treated selectively so the video player will no longer overwrite flags set by camera like DefaultToSpeaker and camera will not overwrite MixWithOthers set by video player setMixWithOthers. It will also only change category or options if there is change to prevent lags every time is constructed VideoPlayerController with non-null videoPlayerOptions which always causes call to setMixWithOthers.
Test testSeekToWhilePausedStartsDisplayLinkTemporarily is failing on the main branch on the tested device:
XCTAssertEqual([player position], 1234); // (([player position]) equal to (1234)) failed: ("0") is not equal to ("1234")
Fixes https://github.com/flutter/flutter/issues/131553
Pre-launch Checklist
- [x] I read the Contributor Guide and followed the process outlined there for submitting PRs.
- [x] I read the Tree Hygiene page, which explains my responsibilities.
- [x] I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use
dart format.) - [x] I signed the CLA.
- [x] The title of the PR starts with the name of the package surrounded by square brackets, e.g.
[shared_preferences] - [x] I linked to at least one issue that this PR fixes in the description above.
- [x] I updated
pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes. - [x] I updated
CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or this PR is exempt from CHANGELOG changes. - [x] I updated/added relevant documentation (doc comments with
///). - [x] I added new tests to check the change I am making, or this PR is test-exempt.
- [x] All existing and new tests are passing.
If you need help, consider asking for advice on the #hackers-new channel on Discord.
I have no way how to test AVAudioSessionCategoryOptionOverrideMutedMicrophoneInterruption so this one was not added although it might prevent some errors for which camera may not be prepared: "Attempting to start audio input after the system mutes the microphone results in an error.".
I removed AVAudioSessionCategoryOptionAllowBluetooth which basically just enables and prefers HFP profile over A2DP. This is not implicitly present with the playback category and has unintended consequences as output is not stereo and lower quality so if there ever is HFP support it should be opt-in from the dart side.
Also when will we need to pass a nil category param?
It means it should not be changed, used in player, AVAudioSession.sharedInstance.category could not be passed as argument when there was thread switch inside function, now that changed so I can remove that check and make player pass AVAudioSession.sharedInstance.category instead of nil.
I meant it seems we only pass 0 and never other values to this param. So do we really need this param?
No, not in camera at the moment.
auto label is removed for flutter/packages/7143, due to - The status or check suite ci.yaml validation has failed. Please fix the issues identified (or deflake) before re-applying this label.
- The status or check suite Merge Queue Guard has failed. Please fix the issues identified (or deflake) before re-applying this label.
auto label is removed for flutter/packages/7143, due to - The status or check suite Mac_arm64 macos_platform_tests master - packages has failed. Please fix the issues identified (or deflake) before re-applying this label.