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

View file

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

View file

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

View file

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

View file

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