| 
									
										
										
										
											2021-06-03 14:16:02 +02:00
										 |  |  | // | 
					
						
							|  |  |  | //  AVAudioSession+updateCategory.swift | 
					
						
							|  |  |  | //  VisionCamera | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | //  Created by Marc Rousavy on 01.06.21. | 
					
						
							|  |  |  | //  Copyright © 2021 mrousavy. All rights reserved. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import AVFoundation | 
					
						
							|  |  |  | import Foundation | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extension AVAudioSession { | 
					
						
							|  |  |  |   /**
 | 
					
						
							| 
									
										
										
										
											2021-06-09 14:56:56 +02:00
										 |  |  |    Calls [setCategory] if the given category or options are not equal to the currently set category and options. | 
					
						
							| 
									
										
										
										
											2021-06-03 14:16:02 +02:00
										 |  |  |    */ | 
					
						
							| 
									
										
										
										
											2023-11-22 17:53:10 +01:00
										 |  |  |   func updateCategory(_ category: AVAudioSession.Category, | 
					
						
							|  |  |  |                       mode: AVAudioSession.Mode, | 
					
						
							|  |  |  |                       options: AVAudioSession.CategoryOptions = []) throws { | 
					
						
							|  |  |  |     if self.category != category || categoryOptions.rawValue != options.rawValue || self.mode != mode { | 
					
						
							| 
									
										
										
										
											2021-06-03 14:16:02 +02:00
										 |  |  |       ReactLogger.log(level: .info, | 
					
						
							| 
									
										
										
										
											2021-09-06 16:27:16 +02:00
										 |  |  |                       message: "Changing AVAudioSession category from \(self.category.rawValue) -> \(category.rawValue)") | 
					
						
							| 
									
										
										
										
											2023-11-22 17:53:10 +01:00
										 |  |  |       try setCategory(category, mode: mode, options: options) | 
					
						
							|  |  |  |       ReactLogger.log(level: .info, message: "AVAudioSession category changed!") | 
					
						
							| 
									
										
										
										
											2021-06-03 14:16:02 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |