Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Threema/Threema/Chats/ChatView/   (Social Medium ©)  Datei vom 26.9.2026 mit Größe 984 B image not shown  

Quelle  ProximityAudioRouting.swift   Sprache: JAVA

 

import AudioSessionManager
import AVFoundation
import UIKit

/// Where a voice message should play, given the proximity sensor.
@MainActor
enum ProximityAudioRouting {

    /// Ports where holding the phone to your ear is a meaningful signal.
    private static let builtInOutputs: Set<AVAudioSession.Port> = [.builtInSpeaker, .builtInReceiver]

    /// The route to ask for right now.
    ///
    /// - Parameter audioSessionManager: asked for the current ports, so this does not have to read
    ///   `AVAudioSession` itself.
    static func currentOutput(
        _ audioSessionManager: any AudioSessionManagerProtocol
    ) async -> AudioSessionOutput {
        guard UIDevice.current.proximityState else {
            return .system
        }

        // Headphones and Bluetooth outrank the ear
        guard await audioSessionManager.currentRoute().outputs.contains(where: builtInOutputs.contains) else {
            return .system
        }

        return .receiver
    }
}

Messung
CHZG
869810094

¤ Dauer der Verarbeitung: 0.2 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover


Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.