remove AudioClient dependency on Recorder

This commit is contained in:
Stephen Birarda 2015-01-21 13:20:46 -08:00
parent eebb21656e
commit 343b09c855
5 changed files with 15 additions and 17 deletions

View file

@ -490,9 +490,12 @@ void MyAvatar::startRecording() {
if (!_recorder) {
_recorder = RecorderPointer(new Recorder(this));
}
DependencyManager::get<AudioClient>()->setRecorder(_recorder);
_recorder->startRecording();
// connect to AudioClient's signal so we get input audio
auto audioClient = DependencyManager::get<AudioClient>();
connect(audioClient.data(), &AudioClient::inputReceived, _recorder.data(),
&Recorder::recordAudio, Qt::BlockingQueuedConnection);
_recorder->startRecording();
}
void MyAvatar::stopRecording() {
@ -504,6 +507,10 @@ void MyAvatar::stopRecording() {
return;
}
if (_recorder) {
// stop grabbing audio from the AudioClient
auto audioClient = DependencyManager::get<AudioClient>();
disconnect(audioClient.data(), 0, _recorder.data(), 0);
_recorder->stopRecording();
}
}

View file

@ -685,10 +685,6 @@ void AudioClient::handleAudioInput() {
auto nodeList = DependencyManager::get<NodeList>();
SharedNodePointer audioMixer = nodeList->soloNodeOfType(NodeType::AudioMixer);
if (_recorder && _recorder.data()->isRecording()) {
_recorder.data()->record(reinterpret_cast<char*>(networkAudioSamples), numNetworkBytes);
}
if (audioMixer && audioMixer->getActiveSocket()) {
glm::vec3 headPosition = _positionGetter();
glm::quat headOrientation = _orientationGetter();

View file

@ -37,8 +37,6 @@
#include <RingBufferHistory.h>
#include <StDev.h>
#include "Recorder.h"
#include "AudioIOStats.h"
#include "AudioNoiseGate.h"
@ -112,8 +110,6 @@ public:
float getInputRingBufferMsecsAvailable() const;
float getAudioOutputMsecsUnplayed() const;
void setRecorder(RecorderPointer recorder) { _recorder = recorder; }
int getOutputBufferSize() { return _outputBufferSizeFrames; }
@ -273,8 +269,6 @@ private:
AudioOutputIODevice _audioOutputIODevice;
WeakRecorderPointer _recorder;
AudioIOStats _stats;
AudioNoiseGate _inputGate;

View file

@ -136,7 +136,6 @@ void Recorder::record() {
}
}
void Recorder::record(char* samples, int size) {
QByteArray byteArray(samples, size);
_recording->addAudioPacket(byteArray);
void Recorder::recordAudio(const QByteArray& audioByteArray) {
_recording->addAudioPacket(audioByteArray);
}

View file

@ -26,7 +26,8 @@ typedef QSharedPointer<Recorder> RecorderPointer;
typedef QWeakPointer<Recorder> WeakRecorderPointer;
/// Records a recording
class Recorder {
class Recorder : public QObject {
Q_OBJECT
public:
Recorder(AvatarData* avatar);
@ -40,7 +41,8 @@ public slots:
void stopRecording();
void saveToFile(const QString& file);
void record();
void record(char* samples, int size);
void recordAudio(const QByteArray& audioArray);
private:
QElapsedTimer _timer;