From d1054b3cfc8c176a35e35bb8164284c662564aac Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 5 Dec 2013 13:17:16 -0800 Subject: [PATCH] add received audio to buffer via queued connection --- interface/src/Application.cpp | 3 ++- interface/src/Audio.cpp | 4 ++-- interface/src/Audio.h | 5 ++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 46be169a56..02160b926e 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4239,7 +4239,8 @@ void* Application::networkReceive(void* args) { break; case PACKET_TYPE_MIXED_AUDIO: - app->_audio.addReceivedAudioToBuffer(app->_incomingPacket, bytesReceived); + QMetaObject::invokeMethod(&app->_audio, "addReceivedAudioToBuffer", Qt::QueuedConnection, + Q_ARG(QByteArray, QByteArray((char*) app->_incomingPacket, bytesReceived))); break; case PACKET_TYPE_VOXEL_DATA: case PACKET_TYPE_VOXEL_ERASE: diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 55ae94c8ed..4df3591b8f 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -350,7 +350,7 @@ void Audio::handleAudioInput() { gettimeofday(&_lastCallbackTime, NULL); } -void Audio::addReceivedAudioToBuffer(unsigned char* receivedData, int receivedBytes) { +void Audio::addReceivedAudioToBuffer(const QByteArray& audioByteArray) { const int NUM_INITIAL_PACKETS_DISCARD = 3; const int STANDARD_DEVIATION_SAMPLE_COUNT = 500; @@ -389,7 +389,7 @@ void Audio::addReceivedAudioToBuffer(unsigned char* receivedData, int receivedBy } } - _ringBuffer.parseData((unsigned char*) receivedData, receivedBytes); + _ringBuffer.parseData((unsigned char*) audioByteArray.data(), audioByteArray.size()); Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::AUDIO) .updateValue(PACKET_LENGTH_BYTES + sizeof(PACKET_TYPE)); diff --git a/interface/src/Audio.h b/interface/src/Audio.h index f02b07757f..b92bc08860 100644 --- a/interface/src/Audio.h +++ b/interface/src/Audio.h @@ -42,8 +42,6 @@ public: void render(int screenWidth, int screenHeight); - void addReceivedAudioToBuffer(unsigned char* receivedData, int receivedBytes); - float getLastInputLoudness() const { return _lastInputLoudness; } void setLastAcceleration(const glm::vec3 lastAcceleration) { _lastAcceleration = lastAcceleration; } @@ -64,8 +62,9 @@ public: void init(QGLWidget *parent = 0); bool mousePressEvent(int x, int y); - public slots: +public slots: void start(); + void addReceivedAudioToBuffer(const QByteArray& audioByteArray); void handleAudioInput(); void reset();