Skip to content

Commit 51af223

Browse files
committed
MSRP: remove unnecessary throws declaration from _findTalkerRegistration
The _findTalkerRegistration(for:) method that searches across all participants was declared as throwing but never actually throws any errors, instead returning nil when no talker is found.
1 parent 3f75562 commit 51af223

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

Sources/MRP/Applications/MSRP/MSRPApplication.swift

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,10 @@ public final class MSRPApplication<P: AVBPort>: BaseApplication, BaseApplication
466466
public func deregisterStream(
467467
streamID: MSRPStreamID
468468
) async throws {
469-
let talkerRegistration = try await _findTalkerRegistration(for: streamID)
470-
let declarationType: MSRPDeclarationType
471-
guard let talkerRegistration else {
469+
guard let talkerRegistration = await _findTalkerRegistration(for: streamID) else {
472470
throw MRPError.participantNotFound
473471
}
472+
let declarationType: MSRPDeclarationType
474473
if talkerRegistration.1 is MSRPTalkerAdvertiseValue {
475474
declarationType = .talkerAdvertise
476475
} else {
@@ -1169,19 +1168,17 @@ extension MSRPApplication {
11691168

11701169
private func _findTalkerRegistration(
11711170
for streamID: MSRPStreamID
1172-
) async throws -> TalkerRegistration? {
1171+
) async -> TalkerRegistration? {
11731172
var talkerRegistration: TalkerRegistration?
11741173

11751174
await apply { participant in
11761175
guard let participantTalker = await _findTalkerRegistration(
11771176
for: streamID,
11781177
participant: participant
1179-
) else {
1178+
), talkerRegistration == nil else {
11801179
return
11811180
}
1182-
if talkerRegistration == nil {
1183-
talkerRegistration = (participant, participantTalker)
1184-
}
1181+
talkerRegistration = (participant, participantTalker)
11851182
}
11861183

11871184
return talkerRegistration
@@ -1446,7 +1443,7 @@ extension MSRPApplication {
14461443
isNew: Bool,
14471444
eventSource: EventSource
14481445
) async throws {
1449-
guard let talkerRegistration = try? await _findTalkerRegistration(for: streamID) else {
1446+
guard let talkerRegistration = await _findTalkerRegistration(for: streamID) else {
14501447
// no listener attribute propagation if no talker (35.2.4.4.1)
14511448
// this is an expected race condition - listener arrives before talker
14521449
// when talker arrives, _updateExistingListeners() will process it
@@ -1635,7 +1632,7 @@ extension MSRPApplication {
16351632
// StreamID of the Declaration matches a Stream that the Talker is
16361633
// transmitting, then the Talker shall stop the transmission for this
16371634
// Stream, if it is transmitting.
1638-
guard let talkerRegistration = try? await _findTalkerRegistration(for: streamID) else {
1635+
guard let talkerRegistration = await _findTalkerRegistration(for: streamID) else {
16391636
return
16401637
}
16411638

0 commit comments

Comments
 (0)