From 9392737dd0768e40d63d4b8837a8781be5026710 Mon Sep 17 00:00:00 2001 From: David Colburn Date: Wed, 26 Jun 2024 14:39:04 -0700 Subject: [PATCH] dont wait for expected participant tracks (#711) --- pkg/pipeline/source/sdk.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pkg/pipeline/source/sdk.go b/pkg/pipeline/source/sdk.go index 191ebb73..47fac1df 100644 --- a/pkg/pipeline/source/sdk.go +++ b/pkg/pipeline/source/sdk.go @@ -209,6 +209,8 @@ func (s *SDKSource) awaitParticipantTracks(identity string) (uint32, uint32, err return 0, 0, err } + // await expected subscriptions + subscribed := 0 pubs := rp.TrackPublications() expected := 0 for _, pub := range pubs { @@ -217,13 +219,23 @@ func (s *SDKSource) awaitParticipantTracks(identity string) (uint32, uint32, err } } - // await all expected subscriptions - for trackCount := 0; trackCount < expected; trackCount++ { + deadline := make(chan struct{}) + time.AfterFunc(time.Second*3, func() { + close(deadline) + }) + done := false + for !done { select { case err = <-s.errors: if err != nil { return 0, 0, err } + subscribed++ + if subscribed == expected { + done = true + } + case <-deadline: + done = true } }