From a3e7084aca1074f7eb8990fd76e6415406d4441f Mon Sep 17 00:00:00 2001 From: Aravind Raveendran Date: Fri, 20 Oct 2023 11:44:23 +1100 Subject: [PATCH] Fix to fallback to the first source with audio track when the first connect source don't have an audio --- .../DolbyIORTSUIKit/Private/ViewModels/StreamViewModel.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/DolbyIORTSUIKit/Private/ViewModels/StreamViewModel.swift b/Sources/DolbyIORTSUIKit/Private/ViewModels/StreamViewModel.swift index 2f91e89..7dd66e3 100644 --- a/Sources/DolbyIORTSUIKit/Private/ViewModels/StreamViewModel.swift +++ b/Sources/DolbyIORTSUIKit/Private/ViewModels/StreamViewModel.swift @@ -426,7 +426,8 @@ final class StreamViewModel: ObservableObject { selectedAudioSource = sourcesWithAudio.first(where: { $0.sourceId == StreamSource.SourceId.main }) ?? sourcesWithAudio[0] case .followVideo: // Use audio from the video source, if no audio track uses the last one used or just the 1st one - selectedAudioSource = selectedVideoSource.audioTracksCount > 0 ? selectedVideoSource : internalState.selectedAudioSource + let fallbackAudioSource = internalState.selectedAudioSource != nil ? internalState.selectedAudioSource : sourcesWithAudio[0] + selectedAudioSource = selectedVideoSource.audioTracksCount > 0 ? selectedVideoSource : fallbackAudioSource case let .source(sourceId: sourceId): selectedAudioSource = sourcesWithAudio.first(where: { $0.sourceId == StreamSource.SourceId(id: sourceId) }) ?? sourcesWithAudio[0] }