Merge branch 'ws/cleanup' into ws/docs
This commit is contained in:
commit
e74aef06ee
2 files changed
+12
-1
No files matched your search
@@ -7,7 +7,8 @@ generation) and on **LuaJIT / LÖVE** (through `tools/build.py`). Every format o
|
||||
|
||||
About 76 formats across images, audio, video, 3D models, CAD, fonts, archives, data, vector graphics, layered images,
|
||||
subtitles, music and playlists: see [docs/FORMATS.md](docs/FORMATS.md) (generated from the code) for the list and each
|
||||
format's capabilities, and [docs/API.md](docs/API.md) for the whole API.
|
||||
format's capabilities, [docs/API.md](docs/API.md) for the whole API, and the guide
|
||||
([docs/guide/README.md](docs/guide/README.md)) for walkthroughs.
|
||||
|
||||
```luau
|
||||
local F = require(Formats) -- LuaJIT: require("formats"); luau CLI: require("@formats")
|
||||
|
||||
@@ -117,6 +117,16 @@ function Pcm.collect(src: Source, maxFrames: number?): (Types.Audio?, Err.Err?)
|
||||
local total = 0
|
||||
local limit = maxFrames or 2 ^ 31
|
||||
local tmp: buffer? = nil
|
||||
-- a known length: one read straight into the result (decoders write into a big enough out buffer: no copy)
|
||||
if src.frames > 0 and src.frames <= limit then
|
||||
local b, n = src:read(src.frames, data)
|
||||
if n > 0 then
|
||||
if b ~= data then
|
||||
buffer.copy(data, 0, b, 0, math.min(n, cap) * ch * 4)
|
||||
end
|
||||
total = math.min(n, cap)
|
||||
end
|
||||
end
|
||||
while true do
|
||||
local b, n = src:read(16384, tmp)
|
||||
if n <= 0 then
|
||||
|
||||
Reference in new issue
Block a user