diff options
author | Keuin <[email protected]> | 2022-09-15 01:36:12 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-09-15 02:01:33 +0800 |
commit | 12c856a10cb9c59ae97504ce0fcd9fdb044bdd14 (patch) | |
tree | 70a3b1619c488768a9c2c688ee4632e3551844e2 /recording/runner.go | |
parent | 4e742159af79cf0f6a14da630a362a0344a5a121 (diff) |
Use io.CopyN to utilize zero copy technique.
Diffstat (limited to 'recording/runner.go')
-rw-r--r-- | recording/runner.go | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/recording/runner.go b/recording/runner.go index 7fdffac..47c6764 100644 --- a/recording/runner.go +++ b/recording/runner.go @@ -26,7 +26,6 @@ type TaskResult struct { Error error } -const kReadChunkSize = 1024 * 1024 const kSpecialExtName = "partial" var errLiveEnded = NewRecoverableTaskError("live is ended", nil) @@ -310,16 +309,9 @@ func record( defer func() { _ = file.Close() }() writeBufferSize := task.Download.DiskWriteBufferBytes - if writeBufferSize < kReadChunkSize { - writeBufferSize = kReadChunkSize - } - if mod := writeBufferSize % kReadChunkSize; mod != 0 { - writeBufferSize += kReadChunkSize - mod - } - writeBuffer := make([]byte, writeBufferSize) logger.Info("Write buffer size: %v byte", writeBufferSize) logger.Info("Recording live stream to file \"%v\"...", filePath) - err = bi.CopyLiveStream(ctx, task.RoomId, streamSource, file, writeBuffer, kReadChunkSize) + err = bi.CopyLiveStream(ctx, task.RoomId, streamSource, file, writeBufferSize) if errors.Is(err, context.Canceled) || err == nil { return err } |