mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
fix race condition with filler noise and also play filler noise when idle and waiting for commands (#763)
This commit is contained in:
@@ -990,6 +990,11 @@ class CallSession extends Emitter {
|
||||
) {
|
||||
try {
|
||||
await this._awaitCommandsOrHangup();
|
||||
if (this._isPlayingFillerNoise) {
|
||||
this._isPlayingFillerNoise = false;
|
||||
this.ep.api('uuid_break', this.ep.uuid)
|
||||
.catch((err) => this.logger.info(err, 'Error killing filler noise'));
|
||||
}
|
||||
if (this.callGone) break;
|
||||
} catch (err) {
|
||||
this.logger.info(err, 'CallSession:exec - error waiting for new commands');
|
||||
@@ -2427,6 +2432,20 @@ Duration=${duration} `
|
||||
return new Promise((resolve, reject) => {
|
||||
this.logger.info('_awaitCommandsOrHangup - waiting...');
|
||||
this.wakeupResolver = resolve;
|
||||
|
||||
/* start filler noise if configured while we wait for new commands */
|
||||
if (this.fillerNoise?.url && this.ep?.connected && !this.ep2) {
|
||||
this.logger.debug('CallSession:_awaitCommandsOrHangup - playing filler noise');
|
||||
this._isPlayingFillerNoise = true;
|
||||
this.ep.play(this.fillerNoise.url);
|
||||
this.ep.once('playback-start', (evt) => {
|
||||
if (evt.file === this.fillerNoise.url && !this._isPlayingFillerNoise) {
|
||||
this.logger.info('CallSession:_awaitCommandsOrHangup - filler noise started');
|
||||
this.ep.api('uuid_break', this.ep.uuid)
|
||||
.catch((err) => this.logger.info(err, 'Error killing filler noise'));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user