Skip to content

Commit

Permalink
Merge pull request #221 from dolbyio-samples/bugfix/disable-tracks-on…
Browse files Browse the repository at this point in the history
…-inactive

Disable track on inactive event
  • Loading branch information
aravind-raveendran authored Oct 15, 2024
2 parents 412036c + 572e6e0 commit f820784
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions LocalPackages/RTSCore/Sources/RTSCore/Models/SourceBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,16 @@ private extension SourceBuilder {
guard !Task.isCancelled else { return }
switch activityEvent {
case .active:
Self.logger.debug("👨‍🔧 Audio track for \(sourceId) is active, \(track.isActive)")
Self.logger.debug("👨‍🔧 Audio track for \(sourceId) is active")
self.audioTrackStateUpdateSubject.send(sourceId)

case .inactive:
Self.logger.debug("👨‍🔧 Audio track for \(sourceId) is inactive, \(track.isActive)")
Self.logger.debug("👨‍🔧 Audio track for \(sourceId) is inactive")
do {
try await track.disable()
} catch {
Self.logger.debug("👨‍🔧 Error disabling audio track for \(sourceId), \(error.localizedDescription)")
}
self.audioTrackStateUpdateSubject.send(sourceId)
}
}
Expand All @@ -184,11 +189,16 @@ private extension SourceBuilder {
guard !Task.isCancelled else { return }
switch activityEvent {
case .active:
Self.logger.debug("👨‍🔧 Video track for \(sourceId) is active, \(track.isActive)")
Self.logger.debug("👨‍🔧 Video track for \(sourceId) is active")
self.videoTrackStateUpdateSubject.send(sourceId)

case .inactive:
Self.logger.debug("👨‍🔧 Video track for \(sourceId) is inactive, \(track.isActive)")
Self.logger.debug("👨‍🔧 Video track for \(sourceId) is inactive")
do {
try await track.disable()
} catch {
Self.logger.debug("👨‍🔧 Error disabling video track for \(sourceId), \(error.localizedDescription)")
}
self.videoTrackStateUpdateSubject.send(sourceId)
}
}
Expand Down

0 comments on commit f820784

Please sign in to comment.