mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-15 21:45:19 +00:00
Update voice chat sounds
This commit is contained in:
parent
72bd287744
commit
6294c438f1
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,7 +1,7 @@
|
||||
import Foundation
|
||||
import AVFoundation
|
||||
|
||||
private func loadToneData(name: String) -> Data? {
|
||||
private func loadToneData(name: String, addSilenceDuration: Double = 0.0) -> Data? {
|
||||
let outputSettings: [String: Any] = [
|
||||
AVFormatIDKey: kAudioFormatLinearPCM as NSNumber,
|
||||
AVSampleRateKey: 44100.0 as NSNumber,
|
||||
@ -62,6 +62,15 @@ private func loadToneData(name: String) -> Data? {
|
||||
}
|
||||
}
|
||||
|
||||
if !addSilenceDuration.isZero {
|
||||
let sampleRate = 44100
|
||||
let numberOfSamples = Int(Double(sampleRate) * addSilenceDuration)
|
||||
let numberOfChannels = 2
|
||||
let numberOfBytes = numberOfSamples * 2 * numberOfChannels
|
||||
|
||||
data.append(Data(count: numberOfBytes))
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
@ -110,6 +119,6 @@ func presentationCallToneData(_ tone: PresentationCallTone) -> Data? {
|
||||
case .groupLeft:
|
||||
return loadToneData(name: "voip_group_left.mp3")
|
||||
case .groupConnecting:
|
||||
return loadToneData(name: "voip_group_connecting.mp3")
|
||||
return loadToneData(name: "voip_group_connecting.mp3", addSilenceDuration: 2.0)
|
||||
}
|
||||
}
|
||||
|
@ -444,6 +444,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
||||
|
||||
private var removedChannelMembersDisposable: Disposable?
|
||||
|
||||
private var didStartConnectingOnce: Bool = false
|
||||
private var didConnectOnce: Bool = false
|
||||
private var toneRenderer: PresentationCallToneRenderer?
|
||||
|
||||
@ -857,6 +858,10 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
||||
}
|
||||
}
|
||||
|
||||
if isConnecting {
|
||||
strongSelf.didStartConnectingOnce = true
|
||||
}
|
||||
|
||||
if case .connected = state {
|
||||
if !strongSelf.didConnectOnce {
|
||||
strongSelf.didConnectOnce = true
|
||||
|
Loading…
x
Reference in New Issue
Block a user