mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-30 12:01:20 -08:00
feat(asr): [PKG-ASR-09] add explicit capture ownership and cancel stale restarts
This commit is contained in:
1 parent
5ab7da6e1f
commit
146b78d576
27 files changed
+12951
-64
No files matched your search
@@ -34,8 +34,11 @@ export class Capture {
|
||||
restart() {
|
||||
const active = this.running || Boolean(this.starting)
|
||||
this.pause()
|
||||
if (this.graph && !this.graph.ownsMediaConnection)
|
||||
return this.stop().then(() => active ? this.start() : undefined)
|
||||
if (this.graph && !this.graph.ownsMediaConnection) {
|
||||
const stopping = this.stop()
|
||||
const epoch = this.epoch
|
||||
return stopping.then(() => active && !this.terminal && this.epoch === epoch ? this.start() : undefined)
|
||||
}
|
||||
return active ? this.start() : Promise.resolve()
|
||||
}
|
||||
|
||||
@@ -54,7 +57,7 @@ export class Capture {
|
||||
const count = Math.floor(sampleRate * interval / 1000)
|
||||
if (!Number.isSafeInteger(count) || count < 1 || !Number.isFinite(interval) || interval <= 0)
|
||||
throw new Error('Audio chunk length must be positive and finite')
|
||||
const graph = this.graph ??= new AudioGraph(this.video, sampleRate)
|
||||
const graph = this.graph ??= new AudioGraph(this.video, sampleRate, this.options.captureOnly)
|
||||
await graph.prepare()
|
||||
if (!current()) {
|
||||
if (!this.running && this.graph === graph)
|
||||
|
||||
Reference in new issue
Block a user