packages icon indicating copy to clipboard operation
packages copied to clipboard

[video_player_avfoundation, camera_avfoundation] never overwrite but only upgrade audio session category

Open misos1 opened this issue 1 year ago • 3 comments

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

If you need help, consider asking for advice on the #hackers-new channel on Discord.

misos1 avatar Jul 16 '24 18:07 misos1

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.".

misos1 avatar Jul 23 '24 18:07 misos1

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.

misos1 avatar Jul 24 '24 17:07 misos1

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.

misos1 avatar Aug 27 '24 18:08 misos1

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-submit[bot] avatar Jan 13 '25 17:01 auto-submit[bot]

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.

auto-submit[bot] avatar Jan 13 '25 17:01 auto-submit[bot]