Skip to content

Commit

Permalink
feat: Added mixertimeout support for Midas mixers. For a fast warning…
Browse files Browse the repository at this point in the history
… if mixer is not responding.
  • Loading branch information
olzzon committed Oct 6, 2021
1 parent c9c49ca commit b25efd5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions server/constants/mixerProtocols/midasMaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const MidasMaster: IMixerProtocol = {
},
],
pingTime: 9500,
mixerTimeout: 2000,
initializeCommands: [
{
mixerMessage: '/ch/{channel}/mix/fader',
Expand Down
22 changes: 20 additions & 2 deletions server/utils/mixerConnections/OscMixerConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export class OscMixerConnection {
mixerIndex: number
cmdChannelIndex: number
oscConnection: any
mixerOnlineTimer: any
mixerOnlineTimer: NodeJS.Timeout
timeoutTimer: NodeJS.Timeout
commandBuffer: IOscCommand[] = []

constructor(mixerProtocol: IMixerProtocol, mixerIndex: number) {
Expand Down Expand Up @@ -92,7 +93,11 @@ export class OscMixerConnection {
})
.on('message', (message: any) => {
clearTimeout(this.mixerOnlineTimer)
this.resetMixerTimeout()
if (!state.settings[0].mixers[this.mixerIndex].mixerOnline) {
logger.info(
`Audio Mixer number: ${this.mixerIndex + 1} is Online`
)
this.mixerOnline(true)
}
logger.verbose('Received OSC message: ' + message.address, {})
Expand Down Expand Up @@ -413,17 +418,30 @@ export class OscMixerConnection {

pingMixerCommand() {
//Ping OSC mixer if mixerProtocol needs it.
this.mixerProtocol.pingCommand.map((command) => {
this.mixerProtocol.pingCommand.forEach((command) => {
let value = command.value || 0
let type = command.type || 'i'
this.sendOutMessage(command.mixerMessage, 0, value, type)
})
global.mainThreadHandler.updateFullClientStore()
this.mixerOnlineTimer = setTimeout(() => {
logger.warn(`Audio Mixer number: ${this.mixerIndex + 1} is Offline`)
store.dispatch(storeSetMixerOnline(this.mixerIndex, false))
}, this.mixerProtocol.pingTime)
}

resetMixerTimeout() {
// Check mixer Timeout response if protocol needs it:
if (this.mixerProtocol.mixerTimeout > 0) {
clearTimeout(this.timeoutTimer)
this.timeoutTimer = setTimeout(() => {
logger.warn(
`Audio Mixer number: ${this.mixerIndex + 1} timeout`
)
}, this.mixerProtocol.mixerTimeout)
}
}

checkFxCommands(message: any) {
Object.keys(fxParamsList).forEach((keyName: string) => {
if (!isNaN(parseFloat(keyName))) {
Expand Down

0 comments on commit b25efd5

Please sign in to comment.