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

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;
@ -122,8 +123,6 @@ private:
Encoder* _encoder { nullptr };
QTimer _avatarAudioTimer;
bool _flushEncoder { false };
bool _recordingInterrupted { false };
};
#endif // hifi_Agent_h