Merge pull request from zfox23/MS20089_interruptRecording

Implement MS20089: ACs playing avatar recordings now correctly handle playAvatarSound
This commit is contained in:
Antonina Savinova 2018-12-18 15:14:53 -08:00 committed by GitHub
commit 1977180ecf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions
assignment-client/src

View file

@ -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,6 +760,10 @@ void Agent::processAgentAvatarAudio() {
const int16_t* nextSoundOutput = NULL;
if (_avatarSound && _avatarSound->isReady()) {
if (isPlayingRecording && !_shouldMuteRecordingAudio) {
_shouldMuteRecordingAudio = true;
}
auto audioData = _avatarSound->getAudioData();
nextSoundOutput = reinterpret_cast<const int16_t*>(audioData->rawData()
+ _numAvatarSoundSentBytes);
@ -781,6 +789,10 @@ void Agent::processAgentAvatarAudio() {
_avatarSound.clear();
_numAvatarSoundSentBytes = 0;
_flushEncoder = true;
if (_shouldMuteRecordingAudio) {
_shouldMuteRecordingAudio = false;
}
}
}

View file

@ -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;