bugfix: config was not properly enabling amd when configured

This commit is contained in:
Dave Horton
2022-09-19 21:16:19 +02:00
parent 099f33857c
commit 0c089e2380
2 changed files with 13 additions and 5 deletions

View File

@@ -26,7 +26,7 @@ class TaskConfig extends Task {
}); });
} }
if (this.bargeIn.sticky) this.autoEnable = true; if (this.bargeIn.sticky) this.autoEnable = true;
this.preconditions = (this.bargeIn.enable || this.record?.action) ? this.preconditions = (this.bargeIn.enable || this.record?.action || this.data.amd) ?
TaskPreconditions.Endpoint : TaskPreconditions.Endpoint :
TaskPreconditions.None; TaskPreconditions.None;
} }
@@ -54,13 +54,20 @@ class TaskConfig extends Task {
return `${this.name}{${phrase.join(',')}`; return `${this.name}{${phrase.join(',')}`;
} }
async exec(cs) { async exec(cs, {ep}) {
await super.exec(cs); await super.exec(cs);
if (this.data.amd) { if (this.data.amd) {
this.startAmd = cs.startAmd; this.startAmd = cs.startAmd;
this.stopAmd = cs.stopAmd; this.stopAmd = cs.stopAmd;
this.on('amd', this._onAmdEvent.bind(this, cs)); this.on('amd', this._onAmdEvent.bind(this, cs));
try {
this.ep = ep;
this.startAmd(cs, ep, this, this.data.amd);
} catch (err) {
this.logger.info({err}, 'Config:exec - Error calling startAmd');
}
} }
if (this.hasSynthesizer) { if (this.hasSynthesizer) {
@@ -133,6 +140,7 @@ class TaskConfig extends Task {
async kill(cs) { async kill(cs) {
super.kill(cs); super.kill(cs);
if (this.ep && this.stopAmd) this.stopAmd(this.ep, this);
} }
_onAmdEvent(cs, evt) { _onAmdEvent(cs, evt) {

View File

@@ -42,9 +42,9 @@ const clearChannels = () => {
}; };
const clearFiles = () => { const clearFiles = () => {
const {logger} = require('../..'); //const {logger} = require('../..');
const out = execSync('find /tmp -name "*.mp3" -mtime +2 -exec rm {} \\;'); /*const out = */ execSync('find /tmp -name "*.mp3" -mtime +2 -exec rm {} \\;');
logger.debug({out}, 'clearFiles: command output'); //logger.debug({out}, 'clearFiles: command output');
}; };