Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios

This commit is contained in:
Ilya Laktyushin 2020-12-09 18:03:38 +04:00
commit 0a8d06f51f
4 changed files with 15 additions and 7 deletions

View File

@ -823,14 +823,14 @@ public final class ManagedAudioSession {
print("\(CFAbsoluteTimeGetCurrent()) AudioSession activate: \((CFAbsoluteTimeGetCurrent() - startTime) * 1000.0) ms")
self.updateCurrentAudioRouteInfo()
print("\(CFAbsoluteTimeGetCurrent()) AudioSession updateCurrentAudioRouteInfo: \((CFAbsoluteTimeGetCurrent() - startTime) * 1000.0) ms")
try self.setupOutputMode(outputMode, type: type)
print("\(CFAbsoluteTimeGetCurrent()) AudioSession setupOutputMode: \((CFAbsoluteTimeGetCurrent() - startTime) * 1000.0) ms")
self.updateCurrentAudioRouteInfo()
print("\(CFAbsoluteTimeGetCurrent()) AudioSession updateCurrentAudioRouteInfo: \((CFAbsoluteTimeGetCurrent() - startTime) * 1000.0) ms")
if case .voiceCall = type {
try AVAudioSession.sharedInstance().setPreferredIOBufferDuration(0.005)
}

View File

@ -463,6 +463,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
if !audioSession.getIsHeadsetPluggedIn() {
self.currentSelectedAudioOutputValue = .speaker
self.audioOutputStatePromise.set(.single(([], .speaker)))
}
self.audioSessionDisposable = audioSession.push(audioSessionType: .voiceCall, manualActivate: { [weak self] control in
@ -493,7 +494,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
if !didReceiveAudioOutputs {
didReceiveAudioOutputs = true
if currentOutput == .speaker {
signal = .single((availableOutputs, .builtin))
signal = .single((availableOutputs, .speaker))
|> then(
signal
|> delay(1.0, queue: Queue.mainQueue())
@ -989,6 +990,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
strongSelf.stateValue.adminIds = adminIds
strongSelf.stateValue.canManageCall = state.isCreator || adminIds.contains(strongSelf.accountContext.account.peerId)
if (state.isCreator || strongSelf.stateValue.adminIds.contains(strongSelf.accountContext.account.peerId)) && state.defaultParticipantsAreMuted.canChange {
strongSelf.stateValue.defaultParticipantMuteState = state.defaultParticipantsAreMuted.isMuted ? .muted : .unmuted
}

View File

@ -908,10 +908,14 @@ public final class VoiceChatController: ViewController {
guard let strongSelf = self else {
return
}
let wasEmpty = strongSelf.audioOutputState == nil
strongSelf.audioOutputState = state
if let (layout, navigationHeight) = strongSelf.validLayout {
strongSelf.containerLayoutUpdated(layout, navigationHeight: navigationHeight, transition: .immediate)
}
if wasEmpty {
strongSelf.controller?.audioOutputStateReady.set(true)
}
})
self.audioLevelsDisposable = (call.audioLevels
@ -1859,6 +1863,7 @@ public final class VoiceChatController: ViewController {
fileprivate let contentsReady = ValuePromise<Bool>(false, ignoreRepeated: true)
fileprivate let dataReady = ValuePromise<Bool>(false, ignoreRepeated: true)
fileprivate let audioOutputStateReady = ValuePromise<Bool>(false, ignoreRepeated: true)
private let _ready = Promise<Bool>(false)
override public var ready: Promise<Bool> {
return self._ready
@ -1895,7 +1900,8 @@ public final class VoiceChatController: ViewController {
self._ready.set(combineLatest([
self.contentsReady.get(),
self.dataReady.get()
self.dataReady.get(),
self.audioOutputStateReady.get()
])
|> map { values -> Bool in
for value in values {

View File

@ -2975,7 +2975,7 @@ func replayFinalState(accountManager: AccountManager, postbox: Postbox, accountP
case let .groupCall(flags, _, _, _, _, _):
let isMuted = (flags & (1 << 1)) != 0
let canChange = (flags & (1 << 2)) != 0
let defaultParticipantsAreMuted = GroupCallParticipantsContext.State.DefaultParticipantsAreMuted(isMuted: isMuted, canChange: isMuted)
let defaultParticipantsAreMuted = GroupCallParticipantsContext.State.DefaultParticipantsAreMuted(isMuted: isMuted, canChange: canChange)
updatedGroupCallParticipants.append((
info.id,
.call(isTerminated: false, defaultParticipantsAreMuted: defaultParticipantsAreMuted)