From d5552c21577c446a10725d5d6797536bef61a11e Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 2 Dec 2021 09:46:58 +1300 Subject: [PATCH] Log certain warnings only once --- src/domain/audio-client/AudioClient.ts | 14 ++++++++++++-- src/domain/audio/InboundAudioStream.ts | 8 +++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/domain/audio-client/AudioClient.ts b/src/domain/audio-client/AudioClient.ts index e9549cf9..4499d913 100644 --- a/src/domain/audio-client/AudioClient.ts +++ b/src/domain/audio-client/AudioClient.ts @@ -78,6 +78,10 @@ class AudioClient { #_avatarBoundingBoxCorner = { x: -0.5, y: 0.0, z: -0.5 }; #_avatarBoundingBoxScale = { x: 1, y: 2, z: 1 }; + // WEBRTC TODO: Remove when have logger with "once" function. + #_haveWarnedAudioEnvironment = false; + #_haveWarnedAudioStreamStats = false; + constructor(contextID: number) { @@ -435,7 +439,10 @@ class AudioClient { #processStreamStatsPacket = (message: ReceivedMessage, sendingNode: Node | null): void => { // eslint-disable-line // C++ void AudioIOStats::processStreamStatsPacket(ReceivedMessage*, Node* sendingNode) - console.warn("AudioClient: AudioStreamStats packet not processed."); + if (!this.#_haveWarnedAudioStreamStats) { + console.warn("AudioClient: AudioStreamStats packet not processed."); + this.#_haveWarnedAudioStreamStats = true; + } // WEBRTC TODO: Address further C++ code. @@ -447,7 +454,10 @@ class AudioClient { #handleAudioEnvironmentDataPacket = (message: ReceivedMessage): void => { // eslint-disable-line // C++ void handleAudioEnvironmentDataPacket(ReceivedMessage* message) - console.warn("AudioClient: AudioEnvironment packet not processed."); + if (!this.#_haveWarnedAudioEnvironment) { + console.warn("AudioClient: AudioEnvironment packet not processed."); + this.#_haveWarnedAudioEnvironment = true; + } // WEBRTC TODO: Address further C++ code. diff --git a/src/domain/audio/InboundAudioStream.ts b/src/domain/audio/InboundAudioStream.ts index 51f9e20b..99254949 100644 --- a/src/domain/audio/InboundAudioStream.ts +++ b/src/domain/audio/InboundAudioStream.ts @@ -38,6 +38,9 @@ class InboundAudioStream { #_selectedCodecName = ""; #_decoder = null; + // WEBRTC TODO: Remove when have logger with "once" function. + #_haveWarnedWriteDroppableSilentFrames = false;; + /* eslint-disable */ // @ts-ignore @@ -124,7 +127,10 @@ class InboundAudioStream { // C++ int writeDroppableSilentFrames(int silentFrames) // WEBRTC TODO: Address further C++ code. - console.warn("InboundAudioStream.#writeDroppableSilentFrames() not implemented. Frames:", silentFrames); + if (!this.#_haveWarnedWriteDroppableSilentFrames) { + console.warn("InboundAudioStream.#writeDroppableSilentFrames() not implemented. Frames:", silentFrames); + this.#_haveWarnedWriteDroppableSilentFrames = true; + } }