fixed the synchronized-audio corruption
This commit is contained in:
@@ -17,7 +17,6 @@ type fakeLocalSyncSource struct {
|
||||
audio source.AudioFrame
|
||||
readErr error
|
||||
rate mxl.Rational
|
||||
batch uint64
|
||||
timeout time.Duration
|
||||
closed bool
|
||||
closeError error
|
||||
@@ -25,10 +24,8 @@ type fakeLocalSyncSource struct {
|
||||
|
||||
func (s *fakeLocalSyncSource) NextSync(
|
||||
_ context.Context,
|
||||
batch uint64,
|
||||
timeout time.Duration,
|
||||
) (source.Frame, source.AudioFrame, error) {
|
||||
s.batch = batch
|
||||
s.timeout = timeout
|
||||
return s.video, s.audio, s.readErr
|
||||
}
|
||||
@@ -79,23 +76,8 @@ func TestSyncFactoryUsesDefaultsAndForwardsFeeds(t *testing.T) {
|
||||
t.Fatalf("open args = %q %q %q", domain, videoUUID, audioUUID)
|
||||
}
|
||||
got := reader.(*syncReader)
|
||||
if got.readTimeout != DefaultSyncReadTimeout || got.audioBatch != 480 {
|
||||
t.Fatalf("reader timeout=%s batch=%d, want %s and 480", got.readTimeout, got.audioBatch, DefaultSyncReadTimeout)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSyncFactoryClosesSourceForInvalidAudioRate(t *testing.T) {
|
||||
fake := &fakeLocalSyncSource{rate: mxl.Rational{}}
|
||||
factory := SyncFactory{open: func(string, string, string) (localSyncSource, error) {
|
||||
return fake, nil
|
||||
}}
|
||||
video, audio := syncFeedConfigs()
|
||||
reader, err := factory.OpenSync(context.Background(), video, audio)
|
||||
if reader != nil {
|
||||
t.Fatal("OpenSync() reader is not nil")
|
||||
}
|
||||
if !errors.Is(err, ErrInvalidAudioBatch) || !fake.closed {
|
||||
t.Fatalf("OpenSync() error=%v closed=%t", err, fake.closed)
|
||||
if got.readTimeout != DefaultSyncReadTimeout {
|
||||
t.Fatalf("reader timeout=%s, want %s", got.readTimeout, DefaultSyncReadTimeout)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +90,7 @@ func TestSyncReaderConvertsPairWithoutCopying(t *testing.T) {
|
||||
rate: mxl.Rational{Num: 48_000, Den: 1},
|
||||
}
|
||||
reader := &syncReader{
|
||||
source: fake, readTimeout: 7 * time.Millisecond, audioBatch: 12,
|
||||
source: fake, readTimeout: 7 * time.Millisecond,
|
||||
rateNumerator: 48_000, rateDenominator: 1,
|
||||
}
|
||||
|
||||
@@ -116,8 +98,8 @@ func TestSyncReaderConvertsPairWithoutCopying(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if fake.batch != 12 || fake.timeout != 7*time.Millisecond {
|
||||
t.Fatalf("NextSync() batch=%d timeout=%s", fake.batch, fake.timeout)
|
||||
if fake.timeout != 7*time.Millisecond {
|
||||
t.Fatalf("NextSync() timeout=%s", fake.timeout)
|
||||
}
|
||||
if frame.Video.Index != 10 || frame.Audio.Index != 40 || frame.Audio.SampleRateNumerator != 48_000 {
|
||||
t.Fatalf("frame = %+v", frame)
|
||||
|
||||
Reference in New Issue
Block a user