From a5a121ee00065151739da3fcaec879499aaf4802 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Sat, 30 Jul 2022 23:07:33 +0200 Subject: [PATCH] flag for whether autodetection is currently active --- src/ext/lib/ar-detect/ArDetector.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/ext/lib/ar-detect/ArDetector.ts b/src/ext/lib/ar-detect/ArDetector.ts index 94a1ada..55d76be 100644 --- a/src/ext/lib/ar-detect/ArDetector.ts +++ b/src/ext/lib/ar-detect/ArDetector.ts @@ -42,7 +42,9 @@ export interface AardPerformanceData { blackFrameDrawCount: number, blackFrameCount: number, fastLetterboxCount: number, - edgeDetectCount: number + edgeDetectCount: number, + + aardActive: boolean, // whether autodetection is currently running or not } class ArDetector { @@ -91,7 +93,8 @@ class ArDetector { nextFrameCheckTime: Date.now() } private status = { - lastVideoStatus: VideoPlaybackState.Playing + lastVideoStatus: VideoPlaybackState.Playing, + aardActive: false, } //#region debug variables @@ -157,7 +160,6 @@ class ArDetector { } } - init(){ this.logger.log('info', 'init', `[ArDetect::init] <@${this.arid}> Initializing autodetection.`); this.setup(); @@ -287,11 +289,14 @@ class ArDetector { window.cancelAnimationFrame(this.animationFrameHandle); } + this.status.aardActive = true; this.animationFrameHandle = window.requestAnimationFrame( (ts) => this.animationFrameBootstrap(ts)); this.logger.log('info', 'debug', `"%c[ArDetect::startLoop] <@${this.arid}> AARD loop started.`, _ard_console_start); } stop() { + this.status.aardActive = false; + if (this.animationFrameHandle) { this.logger.log('info', 'debug', `"%c[ArDetect::stop] <@${this.arid}> Stopping AnimationFrame loop.`, _ard_console_stop); window.cancelAnimationFrame(this.animationFrameHandle); @@ -325,7 +330,7 @@ class ArDetector { //#region helper functions (general) isRunning(){ - return true; + return this.status.aardActive; } private getVideoPlaybackState(): VideoPlaybackState { @@ -702,7 +707,8 @@ class ArDetector { blackFrameDrawCount, blackFrameCount: blackFrameProcessCount, fastLetterboxCount, - edgeDetectCount + edgeDetectCount, + aardActive: this.status.aardActive, } this.eventBus.send('uw-config-broadcast', {type: 'aard-performance-data', performanceData: res}); @@ -777,9 +783,6 @@ class ArDetector { // check if aspect ratio is changed: let lastAr = this.conf.resizer.getLastAr(); if (lastAr.type === AspectRatioType.AutomaticUpdate && lastAr.ratio !== null && lastAr.ratio !== undefined){ - // spremembo lahko zavrnemo samo, če uporabljamo avtomatski način delovanja in če smo razmerje stranic - // že nastavili. - // // we can only deny aspect ratio changes if we use automatic mode and if aspect ratio was set from here. let arDiff = trueAr - lastAr.ratio;