diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index 2b080dd79..d8addd329 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -9432,7 +9432,7 @@ repositoryURL = "https://github.com/element-hq/matrix-rust-components-swift"; requirement = { kind = exactVersion; - version = "25.10.07-2"; + version = 25.10.21; }; }; 701C7BEF8F70F7A83E852DCC /* XCRemoteSwiftPackageReference "GZIP" */ = { diff --git a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 1b987276b..cfc239c2e 100644 --- a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -149,8 +149,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/element-hq/matrix-rust-components-swift", "state" : { - "revision" : "8dd60f0967f638f2fd119a315a268c253e20ef52", - "version" : "25.10.7-2" + "revision" : "bb0db6dabeceb59daade5d84ca56c7e7db0c10c5", + "version" : "25.10.21" } }, { diff --git a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift index 929597fd2..388945d2d 100644 --- a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift +++ b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift @@ -17541,9 +17541,9 @@ class TimelineProxyMock: TimelineProxyProtocol, @unchecked Sendable { } } } - var sendVoiceMessageUrlAudioInfoWaveformRequestHandleClosure: ((URL, AudioInfo, [UInt16], @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result)? + var sendVoiceMessageUrlAudioInfoWaveformRequestHandleClosure: ((URL, AudioInfo, [Float], @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result)? - func sendVoiceMessage(url: URL, audioInfo: AudioInfo, waveform: [UInt16], requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result { + func sendVoiceMessage(url: URL, audioInfo: AudioInfo, waveform: [Float], requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result { sendVoiceMessageUrlAudioInfoWaveformRequestHandleCallsCount += 1 if let sendVoiceMessageUrlAudioInfoWaveformRequestHandleClosure = sendVoiceMessageUrlAudioInfoWaveformRequestHandleClosure { return await sendVoiceMessageUrlAudioInfoWaveformRequestHandleClosure(url, audioInfo, waveform, requestHandle) diff --git a/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift index 4d90c253b..399968a7a 100644 --- a/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift +++ b/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift @@ -17054,6 +17054,81 @@ open class RoomSDKMock: MatrixRustSDK.Room, @unchecked Sendable { } } + //MARK: - subscribeToSendQueueUpdates + + open var subscribeToSendQueueUpdatesListenerThrowableError: Error? + var subscribeToSendQueueUpdatesListenerUnderlyingCallsCount = 0 + open var subscribeToSendQueueUpdatesListenerCallsCount: Int { + get { + if Thread.isMainThread { + return subscribeToSendQueueUpdatesListenerUnderlyingCallsCount + } else { + var returnValue: Int? = nil + DispatchQueue.main.sync { + returnValue = subscribeToSendQueueUpdatesListenerUnderlyingCallsCount + } + + return returnValue! + } + } + set { + if Thread.isMainThread { + subscribeToSendQueueUpdatesListenerUnderlyingCallsCount = newValue + } else { + DispatchQueue.main.sync { + subscribeToSendQueueUpdatesListenerUnderlyingCallsCount = newValue + } + } + } + } + open var subscribeToSendQueueUpdatesListenerCalled: Bool { + return subscribeToSendQueueUpdatesListenerCallsCount > 0 + } + open var subscribeToSendQueueUpdatesListenerReceivedListener: SendQueueListener? + open var subscribeToSendQueueUpdatesListenerReceivedInvocations: [SendQueueListener] = [] + + var subscribeToSendQueueUpdatesListenerUnderlyingReturnValue: TaskHandle! + open var subscribeToSendQueueUpdatesListenerReturnValue: TaskHandle! { + get { + if Thread.isMainThread { + return subscribeToSendQueueUpdatesListenerUnderlyingReturnValue + } else { + var returnValue: TaskHandle? = nil + DispatchQueue.main.sync { + returnValue = subscribeToSendQueueUpdatesListenerUnderlyingReturnValue + } + + return returnValue! + } + } + set { + if Thread.isMainThread { + subscribeToSendQueueUpdatesListenerUnderlyingReturnValue = newValue + } else { + DispatchQueue.main.sync { + subscribeToSendQueueUpdatesListenerUnderlyingReturnValue = newValue + } + } + } + } + open var subscribeToSendQueueUpdatesListenerClosure: ((SendQueueListener) async throws -> TaskHandle)? + + open override func subscribeToSendQueueUpdates(listener: SendQueueListener) async throws -> TaskHandle { + if let error = subscribeToSendQueueUpdatesListenerThrowableError { + throw error + } + subscribeToSendQueueUpdatesListenerCallsCount += 1 + subscribeToSendQueueUpdatesListenerReceivedListener = listener + DispatchQueue.main.async { + self.subscribeToSendQueueUpdatesListenerReceivedInvocations.append(listener) + } + if let subscribeToSendQueueUpdatesListenerClosure = subscribeToSendQueueUpdatesListenerClosure { + return try await subscribeToSendQueueUpdatesListenerClosure(listener) + } else { + return subscribeToSendQueueUpdatesListenerReturnValue + } + } + //MARK: - subscribeToTypingNotifications var subscribeToTypingNotificationsListenerUnderlyingCallsCount = 0 @@ -25247,8 +25322,8 @@ open class TimelineSDKMock: MatrixRustSDK.Timeline, @unchecked Sendable { open var sendVoiceMessageParamsAudioInfoWaveformCalled: Bool { return sendVoiceMessageParamsAudioInfoWaveformCallsCount > 0 } - open var sendVoiceMessageParamsAudioInfoWaveformReceivedArguments: (params: UploadParameters, audioInfo: AudioInfo, waveform: [UInt16])? - open var sendVoiceMessageParamsAudioInfoWaveformReceivedInvocations: [(params: UploadParameters, audioInfo: AudioInfo, waveform: [UInt16])] = [] + open var sendVoiceMessageParamsAudioInfoWaveformReceivedArguments: (params: UploadParameters, audioInfo: AudioInfo, waveform: [Float])? + open var sendVoiceMessageParamsAudioInfoWaveformReceivedInvocations: [(params: UploadParameters, audioInfo: AudioInfo, waveform: [Float])] = [] var sendVoiceMessageParamsAudioInfoWaveformUnderlyingReturnValue: SendAttachmentJoinHandle! open var sendVoiceMessageParamsAudioInfoWaveformReturnValue: SendAttachmentJoinHandle! { @@ -25274,9 +25349,9 @@ open class TimelineSDKMock: MatrixRustSDK.Timeline, @unchecked Sendable { } } } - open var sendVoiceMessageParamsAudioInfoWaveformClosure: ((UploadParameters, AudioInfo, [UInt16]) throws -> SendAttachmentJoinHandle)? + open var sendVoiceMessageParamsAudioInfoWaveformClosure: ((UploadParameters, AudioInfo, [Float]) throws -> SendAttachmentJoinHandle)? - open override func sendVoiceMessage(params: UploadParameters, audioInfo: AudioInfo, waveform: [UInt16]) throws -> SendAttachmentJoinHandle { + open override func sendVoiceMessage(params: UploadParameters, audioInfo: AudioInfo, waveform: [Float]) throws -> SendAttachmentJoinHandle { if let error = sendVoiceMessageParamsAudioInfoWaveformThrowableError { throw error } diff --git a/ElementX/Sources/Services/Timeline/TimelineController/MockTimelineController.swift b/ElementX/Sources/Services/Timeline/TimelineController/MockTimelineController.swift index 02d87dd4a..cec966770 100644 --- a/ElementX/Sources/Services/Timeline/TimelineController/MockTimelineController.swift +++ b/ElementX/Sources/Services/Timeline/TimelineController/MockTimelineController.swift @@ -241,7 +241,7 @@ class MockTimelineController: TimelineControllerProtocol { func sendVoiceMessage(url: URL, audioInfo: MatrixRustSDK.AudioInfo, - waveform: [UInt16], + waveform: [Float], requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result { if let timelineProxy { return await timelineProxy.sendVoiceMessage(url: url, diff --git a/ElementX/Sources/Services/Timeline/TimelineController/TimelineController.swift b/ElementX/Sources/Services/Timeline/TimelineController/TimelineController.swift index b718a913f..9f437f611 100644 --- a/ElementX/Sources/Services/Timeline/TimelineController/TimelineController.swift +++ b/ElementX/Sources/Services/Timeline/TimelineController/TimelineController.swift @@ -356,7 +356,7 @@ class TimelineController: TimelineControllerProtocol { func sendVoiceMessage(url: URL, audioInfo: MatrixRustSDK.AudioInfo, - waveform: [UInt16], + waveform: [Float], requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result { await activeTimeline.sendVoiceMessage(url: url, audioInfo: audioInfo, diff --git a/ElementX/Sources/Services/Timeline/TimelineController/TimelineControllerProtocol.swift b/ElementX/Sources/Services/Timeline/TimelineController/TimelineControllerProtocol.swift index bed5ef1fb..94c9e903f 100644 --- a/ElementX/Sources/Services/Timeline/TimelineController/TimelineControllerProtocol.swift +++ b/ElementX/Sources/Services/Timeline/TimelineController/TimelineControllerProtocol.swift @@ -130,7 +130,7 @@ protocol TimelineControllerProtocol { func sendVoiceMessage(url: URL, audioInfo: AudioInfo, - waveform: [UInt16], + waveform: [Float], requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result // MARK: - Poll diff --git a/ElementX/Sources/Services/Timeline/TimelineProxy.swift b/ElementX/Sources/Services/Timeline/TimelineProxy.swift index 125f13a8b..4ae6eec76 100644 --- a/ElementX/Sources/Services/Timeline/TimelineProxy.swift +++ b/ElementX/Sources/Services/Timeline/TimelineProxy.swift @@ -359,7 +359,7 @@ final class TimelineProxy: TimelineProxyProtocol { func sendVoiceMessage(url: URL, audioInfo: AudioInfo, - waveform: [UInt16], + waveform: [Float], requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result { MXLog.info("Sending voice message") diff --git a/ElementX/Sources/Services/Timeline/TimelineProxyProtocol.swift b/ElementX/Sources/Services/Timeline/TimelineProxyProtocol.swift index a7969cb38..17eaaa9ef 100644 --- a/ElementX/Sources/Services/Timeline/TimelineProxyProtocol.swift +++ b/ElementX/Sources/Services/Timeline/TimelineProxyProtocol.swift @@ -109,7 +109,7 @@ protocol TimelineProxyProtocol { func sendVoiceMessage(url: URL, audioInfo: AudioInfo, - waveform: [UInt16], + waveform: [Float], requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result func sendReadReceipt(for eventID: String, type: ReceiptType) async -> Result diff --git a/ElementX/Sources/Services/VoiceMessage/VoiceMessageRecorder.swift b/ElementX/Sources/Services/VoiceMessage/VoiceMessageRecorder.swift index 25a0c2c4f..f83ac2c03 100644 --- a/ElementX/Sources/Services/VoiceMessage/VoiceMessageRecorder.swift +++ b/ElementX/Sources/Services/VoiceMessage/VoiceMessageRecorder.swift @@ -127,17 +127,17 @@ class VoiceMessageRecorder: VoiceMessageRecorderProtocol { await previewAudioPlayerState?.updateState(progress: progress) } - func buildRecordingWaveform() async -> Result<[UInt16], VoiceMessageRecorderError> { + func buildRecordingWaveform() async -> Result<[Float], VoiceMessageRecorderError> { guard let url = audioRecorder.audioFileURL else { return .failure(.missingRecordingFile) } // build the waveform - var waveformData: [UInt16] = [] + var waveformData: [Float] = [] let analyzer = WaveformAnalyzer() do { let samples = try await analyzer.samples(fromAudioAt: url, count: 100) // linearly normalized to [0, 1] (1 -> -50 dB) - waveformData = samples.map { UInt16(max(0, (1 - $0) * 1024)) } + waveformData = samples.map { max(0, 1 - $0) } } catch { MXLog.error("Waveform analysis failed. \(error)") return .failure(.waveformAnalysisError) diff --git a/Package.resolved b/Package.resolved index 295415dfe..4ad266478 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,13 +1,13 @@ { - "originHash" : "8fc5521127eb479d8784a8d77e682b092e09920246eaefaccc1b1151c08e0f3e", + "originHash" : "43d8d4409954f06d1f1b8ea37d305f2db6b1e8bd1b8a0e108e9bae075d7a601c", "pins" : [ { "identity" : "swift-argument-parser", "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-argument-parser", "state" : { - "revision" : "309a47b2b1d9b5e991f36961c983ecec72275be3", - "version" : "1.6.1" + "revision" : "cdd0ef3755280949551dc26dee5de9ddeda89f54", + "version" : "1.6.2" } }, { diff --git a/project.yml b/project.yml index 092d32488..2c1675940 100644 --- a/project.yml +++ b/project.yml @@ -71,7 +71,7 @@ packages: # Element/Matrix dependencies MatrixRustSDK: url: https://github.com/element-hq/matrix-rust-components-swift - exactVersion: 25.10.07-2 + exactVersion: 25.10.21 # path: ../matrix-rust-sdk Compound: path: compound-ios