Repository: flutter
Issue: [camera]When is recording interrupted by alarm or phone call video is not synchronized with audio
Labels: p: camera,package,team-ecosystem,has reproducible steps,P2,triaged-ecosystem,found in release: 3.22,found in release: 3.24

### Steps to reproduce

1. run code sample
2. start recording
3. make some alarm or phone call happen during recording
4. stop alarm or phone call
5. stop video recording and check the result

After you try to stop the alarm or phone call it may often crash due to #132073, you can either try to reproduce it again (and it may need some considerable amount of tries) or use patch from https://github.com/flutter/packages/pull/6901.

### Expected results

Video and audio synchronized. Recording should be probably paused during such an event as an alarm or phone call.

### Actual results

In the attached video is recording of counting. What is actually recorded here is the screen of the device after step 5. At number 11 in the video the alarm started and at 24 stopped. It can be heard that audio is seemingly properly handled but video just shows a static frame between 11 and 24 and only after those 13 seconds for which alarm sounded continues from 24 and up.


### Code sample

<details open><summary>Code sample</summary>

```dart
import "dart:io";
import "package:flutter/material.dart";
import "package:camera/camera.dart";
import "package:video_player/video_player.dart";

void main()
{
	runApp(const MaterialApp(home: MyHomePage()));
}

class MyHomePage extends StatefulWidget
{
	const MyHomePage({super.key});
	@override State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage>
{
	bool loading = true;
	bool recording = false;
	late CameraController camera_cont;
	String? file;

	@override void initState()
	{
		super.initState();
		init_camera();
	}

	init_camera() async
	{
		final cameras = await availableCameras();
		camera_cont = CameraController(cameras.firstWhere((camera) => camera.lensDirection == CameraLensDirection.back), ResolutionPreset.ultraHigh);
		await camera_cont.initialize();
		setState(() => loading = false);
		await camera_cont.prepareForVideoRecording();
	}

	void record() async
	{
		await camera_cont.startVideoRecording();
		setState(() => recording = true);
	}

	void stop() async
	{
		final f = await camera_cont.stopVideoRecording();
		setState(() => file = f.path);
	}

	@override Widget build(BuildContext context)
	{
		if(loading)return const Center(child: CircularProgressIndicator());
		if(file != null)return VideoPlayer(VideoPlayerController.file(File(file!))..initialize()..setLooping(true)..play());
		return Stack(
			alignment: Alignment.bottomCenter,
			children: [
				CameraPreview(camera_cont),
				if(recording)FilledButton(onPressed: stop, child: const Text("Stop"))
				else FilledButton(onPressed: record, child: const Text("Record")),
			],
		);
	}
}
```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>


https://github.com/flutter/flutter/assets/30872003/c424aa9e-3691-433f-8342-df8216ad42f3


</details>


### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.22.2, on macOS 14.5 23F79 darwin-x64)
```

</details>