mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix voice chat issues
This commit is contained in:
parent
b9f5db6a5a
commit
d109d9aed9
@ -422,7 +422,7 @@ public final class ManagedAudioSession {
|
||||
if let strongSelf = self {
|
||||
for holder in strongSelf.holders {
|
||||
if holder.id == id && holder.active {
|
||||
strongSelf.setup(type: audioSessionType, outputMode: holder.outputMode, activateNow: false)
|
||||
strongSelf.setup(type: audioSessionType, outputMode: holder.outputMode, activateNow: true)
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -649,7 +649,17 @@ public final class ManagedAudioSession {
|
||||
try AVAudioSession.sharedInstance().overrideOutputAudioPort(.none)
|
||||
try AVAudioSession.sharedInstance().setPreferredInput(nil)
|
||||
} catch let error {
|
||||
print("ManagedAudioSession applyNone error \(error)")
|
||||
print("ManagedAudioSession applyNone error \(error), waiting")
|
||||
|
||||
Thread.sleep(forTimeInterval: 2.0)
|
||||
|
||||
do {
|
||||
try AVAudioSession.sharedInstance().setActive(false, options: [.notifyOthersOnDeactivation])
|
||||
try AVAudioSession.sharedInstance().overrideOutputAudioPort(.none)
|
||||
try AVAudioSession.sharedInstance().setPreferredInput(nil)
|
||||
} catch let error {
|
||||
print("ManagedAudioSession applyNone repeated error \(error), giving up")
|
||||
}
|
||||
}
|
||||
|
||||
if wasActive {
|
||||
@ -677,7 +687,7 @@ public final class ManagedAudioSession {
|
||||
do {
|
||||
let nativeCategory = nativeCategoryForType(type, headphones: self.isHeadsetPluggedInValue, outputMode: outputMode)
|
||||
|
||||
print("ManagedAudioSession setting category for \(type) (native: \(nativeCategory))")
|
||||
print("ManagedAudioSession setting category for \(type) (native: \(nativeCategory)) activateNow: \(activateNow)")
|
||||
var options: AVAudioSession.CategoryOptions = []
|
||||
switch type {
|
||||
case .play, .ambient:
|
||||
@ -841,7 +851,7 @@ public final class ManagedAudioSession {
|
||||
}
|
||||
|
||||
private func updateOutputMode(_ outputMode: AudioSessionOutputMode) {
|
||||
if let (type, currentOutputMode) = self.currentTypeAndOutputMode, currentOutputMode != outputMode {
|
||||
if let (type, _) = self.currentTypeAndOutputMode {
|
||||
self.setup(type: type, outputMode: outputMode, activateNow: true)
|
||||
}
|
||||
}
|
||||
|
@ -146,6 +146,8 @@ public final class AccountGroupCallContextCacheImpl: AccountGroupCallContextCach
|
||||
|
||||
private let queue: Queue
|
||||
private var contexts: [Int64: Record] = [:]
|
||||
|
||||
private let leaveDisposables = DisposableSet()
|
||||
|
||||
init(queue: Queue) {
|
||||
self.queue = queue
|
||||
@ -181,6 +183,11 @@ public final class AccountGroupCallContextCacheImpl: AccountGroupCallContextCach
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
public func leaveInBackground(account: Account, id: Int64, accessHash: Int64, source: UInt32) {
|
||||
let disposable = leaveGroupCall(account: account, callId: id, accessHash: accessHash, source: source).start()
|
||||
self.leaveDisposables.add(disposable)
|
||||
}
|
||||
}
|
||||
|
||||
let queue: Queue = .mainQueue()
|
||||
@ -923,7 +930,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
||||
default:
|
||||
break
|
||||
}
|
||||
audioSessionControl.setup(synchronous: true)
|
||||
audioSessionControl.setup(synchronous: false)
|
||||
}
|
||||
|
||||
self.audioSessionShouldBeActive.set(true)
|
||||
@ -1412,7 +1419,13 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
||||
|> switchToLatest
|
||||
}
|
||||
|> deliverOnMainQueue).start(next: { [weak self] event in
|
||||
self?.memberEventsPipe.putNext(event)
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
if event.peer.id == strongSelf.stateValue.myPeerId {
|
||||
return
|
||||
}
|
||||
strongSelf.memberEventsPipe.putNext(event)
|
||||
}))
|
||||
|
||||
if let isCurrentlyConnecting = self.isCurrentlyConnecting, isCurrentlyConnecting {
|
||||
@ -1601,18 +1614,16 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
||||
strongSelf.markAsCanBeRemoved()
|
||||
}))
|
||||
} else {
|
||||
self.leaveDisposable.set((leaveGroupCall(account: self.account, callId: callInfo.id, accessHash: callInfo.accessHash, source: localSsrc)
|
||||
|> deliverOnMainQueue).start(error: { [weak self] _ in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
if let contexts = self.accountContext.cachedGroupCallContexts as? AccountGroupCallContextCacheImpl {
|
||||
let account = self.account
|
||||
let id = callInfo.id
|
||||
let accessHash = callInfo.accessHash
|
||||
let source = localSsrc
|
||||
contexts.impl.with { impl in
|
||||
impl.leaveInBackground(account: account, id: id, accessHash: accessHash, source: source)
|
||||
}
|
||||
strongSelf.markAsCanBeRemoved()
|
||||
}, completed: { [weak self] in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.markAsCanBeRemoved()
|
||||
}))
|
||||
}
|
||||
self.markAsCanBeRemoved()
|
||||
}
|
||||
} else {
|
||||
self.markAsCanBeRemoved()
|
||||
|
@ -149,7 +149,7 @@ extension TelegramUser {
|
||||
guard let lhs = lhs else {
|
||||
return rhs
|
||||
}
|
||||
if case .personal? = rhs.accessHash {
|
||||
if let rhsAccessHash = rhs.accessHash, case .personal = rhsAccessHash {
|
||||
return rhs
|
||||
} else {
|
||||
var userFlags: UserInfoFlags = []
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit d19c74b1474e4aab01d797373f1d62e4da5f87a5
|
||||
Subproject commit 943d24ab5c86d2e4d739e82234b4d14210433ca0
|
Loading…
x
Reference in New Issue
Block a user