From 240917e8ae05cb6d835fd6e18387cbd3e4a38b2c Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 17 Dec 2018 15:46:08 -0800 Subject: [PATCH] Fix MS20089: Enable interrupting of avatar recordings with sounds --- assignment-client/src/Agent.cpp | 10 ++++++++++ assignment-client/src/Agent.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index bd368ef7c2..cd2723e896 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -756,6 +756,11 @@ void Agent::processAgentAvatarAudio() { const int16_t* nextSoundOutput = NULL; if (_avatarSound) { + if (isPlayingRecording) { + recordingInterface->stopPlaying(); + _recordingInterrupted = true; + } + auto audioData = _avatarSound->getAudioData(); nextSoundOutput = reinterpret_cast(audioData->rawData() + _numAvatarSoundSentBytes); @@ -781,6 +786,11 @@ void Agent::processAgentAvatarAudio() { _avatarSound.clear(); _numAvatarSoundSentBytes = 0; _flushEncoder = true; + + if (_recordingInterrupted) { + _recordingInterrupted = false; + recordingInterface->startPlaying(); + } } } diff --git a/assignment-client/src/Agent.h b/assignment-client/src/Agent.h index 7d47c8e713..19e9a06336 100644 --- a/assignment-client/src/Agent.h +++ b/assignment-client/src/Agent.h @@ -122,6 +122,8 @@ private: Encoder* _encoder { nullptr }; QTimer _avatarAudioTimer; bool _flushEncoder { false }; + + bool _recordingInterrupted { false }; }; #endif // hifi_Agent_h