Keep playing the recording visually

This commit is contained in:
Zach Fox 2018-12-18 10:30:20 -08:00
parent 240917e8ae
commit 2964a05bd3
2 changed files with 9 additions and 8 deletions

View file

@ -428,6 +428,10 @@ void Agent::executeScript() {
using namespace recording; using namespace recording;
static const FrameType AUDIO_FRAME_TYPE = Frame::registerFrameType(AudioConstants::getAudioFrameName()); static const FrameType AUDIO_FRAME_TYPE = Frame::registerFrameType(AudioConstants::getAudioFrameName());
Frame::registerFrameHandler(AUDIO_FRAME_TYPE, [this, &scriptedAvatar](Frame::ConstPointer frame) { Frame::registerFrameHandler(AUDIO_FRAME_TYPE, [this, &scriptedAvatar](Frame::ConstPointer frame) {
if (_shouldMuteRecordingAudio) {
return;
}
static quint16 audioSequenceNumber{ 0 }; static quint16 audioSequenceNumber{ 0 };
QByteArray audio(frame->data); QByteArray audio(frame->data);
@ -756,9 +760,8 @@ void Agent::processAgentAvatarAudio() {
const int16_t* nextSoundOutput = NULL; const int16_t* nextSoundOutput = NULL;
if (_avatarSound) { if (_avatarSound) {
if (isPlayingRecording) { if (isPlayingRecording && !_shouldMuteRecordingAudio) {
recordingInterface->stopPlaying(); _shouldMuteRecordingAudio = true;
_recordingInterrupted = true;
} }
auto audioData = _avatarSound->getAudioData(); auto audioData = _avatarSound->getAudioData();
@ -787,9 +790,8 @@ void Agent::processAgentAvatarAudio() {
_numAvatarSoundSentBytes = 0; _numAvatarSoundSentBytes = 0;
_flushEncoder = true; _flushEncoder = true;
if (_recordingInterrupted) { if (_shouldMuteRecordingAudio) {
_recordingInterrupted = false; _shouldMuteRecordingAudio = false;
recordingInterface->startPlaying();
} }
} }
} }

View file

@ -107,6 +107,7 @@ private:
ResourceRequest* _pendingScriptRequest { nullptr }; ResourceRequest* _pendingScriptRequest { nullptr };
bool _isListeningToAudioStream = false; bool _isListeningToAudioStream = false;
SharedSoundPointer _avatarSound; SharedSoundPointer _avatarSound;
bool _shouldMuteRecordingAudio{ false };
int _numAvatarSoundSentBytes = 0; int _numAvatarSoundSentBytes = 0;
bool _isAvatar = false; bool _isAvatar = false;
QTimer* _avatarIdentityTimer = nullptr; QTimer* _avatarIdentityTimer = nullptr;
@ -122,8 +123,6 @@ private:
Encoder* _encoder { nullptr }; Encoder* _encoder { nullptr };
QTimer _avatarAudioTimer; QTimer _avatarAudioTimer;
bool _flushEncoder { false }; bool _flushEncoder { false };
bool _recordingInterrupted { false };
}; };
#endif // hifi_Agent_h #endif // hifi_Agent_h