4582a8c
commit 4582a8c
1 file changed
+10 -6
Showing 1 changed file+10-6
▼packages/codecs/src/index.ts
+10-6
| @@ -190,9 +190,11 @@ export class WebCodecsVideoDecoder { | ||
190 | 190 | } |
191 | 191 | |
192 | 192 | public close(): void { |
193 | - if (this.decoder && this._state !== 'closed') { | |
194 | - (this.decoder as any).close(); | |
195 | - this.decoder = undefined; | |
193 | + if (this._state !== 'closed') { | |
194 | + if (this.decoder) { | |
195 | + (this.decoder as any).close(); | |
196 | + this.decoder = undefined; | |
197 | + } | |
196 | 198 | this._state = 'closed'; |
197 | 199 | } |
198 | 200 | } |
| @@ -268,9 +270,11 @@ export class WebCodecsAudioDecoder { | ||
268 | 270 | } |
269 | 271 | |
270 | 272 | public close(): void { |
271 | - if (this.decoder && this._state !== 'closed') { | |
272 | - (this.decoder as any).close(); | |
273 | - this.decoder = undefined; | |
273 | + if (this._state !== 'closed') { | |
274 | + if (this.decoder) { | |
275 | + (this.decoder as any).close(); | |
276 | + this.decoder = undefined; | |
277 | + } | |
274 | 278 | this._state = 'closed'; |
275 | 279 | } |
276 | 280 | } |
277 | 281 | |