Fix for audio breaking after a certain time into the stream

After some time into the audio stream, the audio breaks and an error message is displayed in the console stating that the frame offset exceeds the total frames. 
``
caught RangeError: Failed to execute 'copyTo' on 'AudioData': Frame offset exceeds total frames (1024 >= 1024).
``
This is my proposed solution to the issue.  I have tested and verified that my fix works and the audio now runs smoothly without any break.

Hope it helps :)
This commit is contained in:
Wanjohi 2023-05-02 15:57:58 +03:00 committed by GitHub
parent 261d6927c1
commit 43af19ba94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -59,11 +59,15 @@ export class Ring {
frameCount: first.length, frameCount: first.length,
}) })
//For some reason this breaks audio... and this is my temporary fix
//console.log("frame offset", first.length , "frame count", second.length) to test
if (first.length < second.length) {
frame.copyTo(second, { frame.copyTo(second, {
planeIndex: i, planeIndex: i,
frameOffset: first.length, frameOffset: first.length,
frameCount: second.length, frameCount: second.length,
}) })
}
} }
} }
@ -140,4 +144,4 @@ export class RingInit {
this.capacity = capacity this.capacity = capacity
} }
} }