//public static void PostProcessSound() //{ } public static bool ShouldPlaySound(SingleSound singleSound, SoundMetadata soundMetadata) { if (PlaybackModerator.crewChief != null && !PlaybackModerator.crewChief.running) { PlaybackModerator.Trace(string.Format("Sound {0} rejected because main thread is shutting down", singleSound.fullPath)); return(false); } int messageId = soundMetadata == null ? 0 : soundMetadata.messageId; if (PlaybackModerator.lastBlockedMessageId == messageId) { PlaybackModerator.Trace(string.Format("Sound {0} rejected because other members of the same message have been blocked", singleSound.fullPath)); return(false); } if (PlaybackModerator.rejectMessagesWhenTalking && soundMetadata.type != SoundType.VOICE_COMMAND_RESPONSE && SpeechRecogniser.waitingForSpeech && MainWindow.voiceOption != MainWindow.VoiceOptionEnum.ALWAYS_ON) { PlaybackModerator.Trace(string.Format("Sound {0} rejected because we're in the middle of a voice command", singleSound.fullPath)); if (messageId != 0) { PlaybackModerator.lastBlockedMessageId = messageId; } return(false); } if (PlaybackModerator.minPriorityForInterrupt != SoundType.OTHER && PlaybackModerator.CanInterrupt(soundMetadata)) { SoundType mostImportantTypeInImmediateQueue = PlaybackModerator.audioPlayer.getPriortyOfFirstWaitingImmediateMessage(); if (mostImportantTypeInImmediateQueue <= PlaybackModerator.minPriorityForInterrupt) { PlaybackModerator.Trace(string.Format("Blocking queued messasge {0} because at least 1 {1} message is waiting", singleSound.fullPath, mostImportantTypeInImmediateQueue)); PlaybackModerator.Trace("Messages triggering block logic: " + audioPlayer.getMessagesBlocking(minPriorityForInterrupt)); if (messageId != 0) { PlaybackModerator.lastBlockedMessageId = messageId; } // ensure the blocking message won't expire var firstWaitingMessage = PlaybackModerator.audioPlayer.getFirstWaitingImmediateMessage(mostImportantTypeInImmediateQueue); if (firstWaitingMessage != null && firstWaitingMessage.expiryTime > 0) { firstWaitingMessage.expiryTime = firstWaitingMessage.expiryTime + 2000; } return(false); } } return(true); }