fix: Fix Video Recording delay and improve startRecording() performance (#2192)
				
					
				
			* fix: Add more logs * perf: Init audio AVAssetWriter in parallel * chore: Log Audio Session activation * perf: Init Audio Session asynchronously * chore: Log when category changed * fix: Revert lazy audio initialization * Update Podfile.lock * Pass `sourceFormatHint` to video and audio AVAssetWriter * fix: Remove `sourceFormatHint` from Video Asset Writer * Use default options for Audio Asset Writer * Update Podfile.lock * Revert "Use default options for Audio Asset Writer" This reverts commit e575a14c5342ddc7f9db557d5e3915328ed9e798. * Add time logs * fix: Don't synchronize audio buffers, they are already in sync * shouldOptimizeForNetworkUse = false * fix: Only update `latestTimestamp` once video buffer has been written * perf: Use `AVAssetWriterInput` instead of `AVAssetWriterInputPixelBufferAdaptor` * fix: Fix Audio not being synchronized with Video * Remove logs add comments * Format * feat: Set `.videoRecording` AVAudioSession mode * Refactor `startRecording()` a bit * Format * chore: Throw error directly instead of double-checking
This commit is contained in:
		| @@ -23,6 +23,7 @@ extension CameraSession { | ||||
|       let audioSession = AVAudioSession.sharedInstance() | ||||
|  | ||||
|       try audioSession.updateCategory(AVAudioSession.Category.playAndRecord, | ||||
|                                       mode: .videoRecording, | ||||
|                                       options: [.mixWithOthers, | ||||
|                                                 .allowBluetoothA2DP, | ||||
|                                                 .defaultToSpeaker, | ||||
| @@ -39,6 +40,7 @@ extension CameraSession { | ||||
|       } | ||||
|  | ||||
|       audioCaptureSession.startRunning() | ||||
|       ReactLogger.log(level: .info, message: "Audio Session activated!") | ||||
|     } catch let error as NSError { | ||||
|       ReactLogger.log(level: .error, message: "Failed to activate audio session! Error \(error.code): \(error.description)") | ||||
|       switch error.code { | ||||
| @@ -54,6 +56,7 @@ extension CameraSession { | ||||
|     ReactLogger.log(level: .info, message: "Deactivating Audio Session...") | ||||
|  | ||||
|     audioCaptureSession.stopRunning() | ||||
|     ReactLogger.log(level: .info, message: "Audio Session deactivated!") | ||||
|   } | ||||
|  | ||||
|   @objc | ||||
|   | ||||
		Reference in New Issue
	
	Block a user