diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index cd2723e896..07d1533101 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -428,6 +428,10 @@ void Agent::executeScript() { using namespace recording; static const FrameType AUDIO_FRAME_TYPE = Frame::registerFrameType(AudioConstants::getAudioFrameName()); Frame::registerFrameHandler(AUDIO_FRAME_TYPE, [this, &scriptedAvatar](Frame::ConstPointer frame) { + if (_shouldMuteRecordingAudio) { + return; + } + static quint16 audioSequenceNumber{ 0 }; QByteArray audio(frame->data); @@ -756,9 +760,8 @@ void Agent::processAgentAvatarAudio() { const int16_t* nextSoundOutput = NULL; if (_avatarSound) { - if (isPlayingRecording) { - recordingInterface->stopPlaying(); - _recordingInterrupted = true; + if (isPlayingRecording && !_shouldMuteRecordingAudio) { + _shouldMuteRecordingAudio = true; } auto audioData = _avatarSound->getAudioData(); @@ -787,9 +790,8 @@ void Agent::processAgentAvatarAudio() { _numAvatarSoundSentBytes = 0; _flushEncoder = true; - if (_recordingInterrupted) { - _recordingInterrupted = false; - recordingInterface->startPlaying(); + if (_shouldMuteRecordingAudio) { + _shouldMuteRecordingAudio = false; } } } diff --git a/assignment-client/src/Agent.h b/assignment-client/src/Agent.h index 19e9a06336..8951fffb8c 100644 --- a/assignment-client/src/Agent.h +++ b/assignment-client/src/Agent.h @@ -107,6 +107,7 @@ private: ResourceRequest* _pendingScriptRequest { nullptr }; bool _isListeningToAudioStream = false; SharedSoundPointer _avatarSound; + bool _shouldMuteRecordingAudio{ false }; int _numAvatarSoundSentBytes = 0; bool _isAvatar = false; QTimer* _avatarIdentityTimer = nullptr; @@ -122,8 +123,6 @@ private: Encoder* _encoder { nullptr }; QTimer _avatarAudioTimer; bool _flushEncoder { false }; - - bool _recordingInterrupted { false }; }; #endif // hifi_Agent_h