Skip to content

Commit 81ad371

Browse files
committed
Properly free buffers and clear contexts on disposal in FilterAPI and FilterComplexAPI
1 parent 90449ba commit 81ad371

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/api/filter-complex.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,19 +1771,24 @@ export class FilterComplexAPI implements Disposable {
17711771

17721772
this.isClosed = true;
17731773

1774-
// Free any queued frames
17751774
for (const inputState of this.inputs.values()) {
17761775
for (const frame of inputState.queuedFrames) {
17771776
frame.free();
17781777
}
17791778
inputState.queuedFrames = [];
1779+
inputState.buffersrc?.free();
1780+
inputState.buffersrc = null;
1781+
}
1782+
1783+
for (const outputState of this.outputs.values()) {
1784+
outputState.buffersink?.free();
1785+
outputState.buffersink = null;
17801786
}
17811787

1782-
// Clear maps
17831788
this.inputs.clear();
17841789
this.outputs.clear();
17851790

1786-
// Free graph
1791+
this.frame.free();
17871792
this.graph.free();
17881793

17891794
this.initialized = false;

src/api/filter.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,11 +1490,14 @@ export class FilterAPI implements Disposable {
14901490
this.inputQueue.close();
14911491
this.outputQueue.close();
14921492

1493-
this.frame.free();
1494-
this.graph.free();
1493+
this.buffersrcCtx?.free();
1494+
this.buffersinkCtx?.free();
14951495
this.buffersrcCtx = null;
14961496
this.buffersinkCtx = null;
14971497

1498+
this.frame.free();
1499+
this.graph.free();
1500+
14981501
this.initialized = false;
14991502
this.initializePromise = null;
15001503
}

0 commit comments

Comments
 (0)