2021-06-03 06:16:02 -06: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 06:56:56 -06:00
|
|
|
Calls [setCategory] if the given category or options are not equal to the currently set category and options.
|
2021-06-03 06:16:02 -06:00
|
|
|
*/
|
2023-11-22 09:53:10 -07: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 06:16:02 -06:00
|
|
|
ReactLogger.log(level: .info,
|
2021-09-06 08:27:16 -06:00
|
|
|
message: "Changing AVAudioSession category from \(self.category.rawValue) -> \(category.rawValue)")
|
2023-11-22 09:53:10 -07:00
|
|
|
try setCategory(category, mode: mode, options: options)
|
|
|
|
ReactLogger.log(level: .info, message: "AVAudioSession category changed!")
|
2021-06-03 06:16:02 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|