mirror of
https://github.com/Monibuca/engine.git
synced 2025-10-07 01:22:51 +08:00
fix: SplitBuffers函数导致修改原数组的内容的bug
This commit is contained in:
@@ -228,7 +228,7 @@ func (s *Subscriber) PlayBlock(spesic ISubscriber) {
|
|||||||
if s.VideoTrack.IDRing.Value.Sequence != firstIFrame.Sequence {
|
if s.VideoTrack.IDRing.Value.Sequence != firstIFrame.Sequence {
|
||||||
firstIFrame = nil
|
firstIFrame = nil
|
||||||
s.vr = s.VideoTrack.ReadRing()
|
s.vr = s.VideoTrack.ReadRing()
|
||||||
s.Debug("skip to latest key frame")
|
s.Debug("skip to latest key frame", zap.Uint32("seq", s.VideoTrack.IDRing.Value.Sequence))
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
vp = (*VideoFrame)(s.vr.Read(ctx))
|
vp = (*VideoFrame)(s.vr.Read(ctx))
|
||||||
|
@@ -97,6 +97,7 @@ func SizeOfBuffers[T ~[]byte](buf []T) (size int) {
|
|||||||
|
|
||||||
// SplitBuffers 按照一定大小分割 Buffers
|
// SplitBuffers 按照一定大小分割 Buffers
|
||||||
func SplitBuffers[T ~[]byte](buf []T, size int) (result [][]T) {
|
func SplitBuffers[T ~[]byte](buf []T, size int) (result [][]T) {
|
||||||
|
buf = append([]T(nil), buf...)
|
||||||
for total := SizeOfBuffers(buf); total > 0; {
|
for total := SizeOfBuffers(buf); total > 0; {
|
||||||
if total <= size {
|
if total <= size {
|
||||||
return append(result, buf)
|
return append(result, buf)
|
||||||
|
Reference in New Issue
Block a user