From d722e0bf6a878212e7930b982963f303589d9f50 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 4 Dec 2013 14:24:03 -0800 Subject: [PATCH] repairs to Audio class after merge with upstream master --- interface/src/Audio.cpp | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 84c00b956c..08385513fd 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -172,7 +172,7 @@ void Audio::handleAudioInput() { static char monoAudioDataPacket[MAX_PACKET_SIZE]; // read out the current samples from the _inputDevice - _inputDevice->read((char*) stereoInputBuffer, BUFFER_LENGTH_BYTES_STEREO * SAMPLE_RATE_RATIO); + _inputDevice->read((char*) stereoInputBuffer, sizeof(stereoInputBuffer)); NodeList* nodeList = NodeList::getInstance(); Node* audioMixer = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER); @@ -187,7 +187,7 @@ void Audio::handleAudioInput() { if (audioMixer) { if (audioMixer->getActiveSocket()) { - Avatar* interfaceAvatar = Application::getInstance()->getAvatar(); + MyAvatar* interfaceAvatar = Application::getInstance()->getAvatar(); glm::vec3 headPosition = interfaceAvatar->getHeadJointPosition(); glm::quat headOrientation = interfaceAvatar->getHead().getOrientation(); @@ -241,9 +241,9 @@ void Audio::handleAudioInput() { // Add procedural effects to input samples addProceduralSounds((int16_t*) currentPacketPtr, stereoOutputBuffer, BUFFER_LENGTH_SAMPLES_PER_CHANNEL); - nodeList->getNodeSocket()->send(audioMixer->getActiveSocket(), - monoAudioDataPacket, - BUFFER_LENGTH_BYTES_PER_CHANNEL + leadingBytes); + nodeList->getNodeSocket().writeDatagram(monoAudioDataPacket, BUFFER_LENGTH_BYTES_PER_CHANNEL + leadingBytes, + audioMixer->getActiveSocket()->getAddress(), + audioMixer->getActiveSocket()->getPort()); } else { nodeList->pingPublicAndLocalSocketsForInactiveNode(audioMixer); } @@ -288,34 +288,9 @@ void Audio::handleAudioInput() { } } } - - eventuallySendRecvPing(inputLeft, outputLeft, outputRight); - - - // add output (@speakers) data just written to the scope - _scope->addSamples(1, outputLeft, BUFFER_LENGTH_SAMPLES_PER_CHANNEL); - _scope->addSamples(2, outputRight, BUFFER_LENGTH_SAMPLES_PER_CHANNEL); - gettimeofday(&_lastCallbackTime, NULL); -} - -// inputBuffer A pointer to an internal portaudio data buffer containing data read by portaudio. -// outputBuffer A pointer to an internal portaudio data buffer to be read by the configured output device. -// frames Number of frames that portaudio requests to be read/written. -// timeInfo Portaudio time info. Currently unused. -// statusFlags Portaudio status flags. Currently unused. -// userData Pointer to supplied user data (in this case, a pointer to the parent Audio object -int Audio::audioCallback (const void* inputBuffer, - void* outputBuffer, - unsigned long frames, - const PaStreamCallbackTimeInfo *timeInfo, - PaStreamCallbackFlags statusFlags, - void* userData) { - - // copy the audio data to the output device _outputDevice->write((char*) stereoOutputBuffer, sizeof(stereoOutputBuffer)); - _outputDevice->write((char*) stereoOutputBuffer, sizeof(stereoOutputBuffer)); - + // add output (@speakers) data just written to the scope // _scope->addSamples(1, outputLeft, BUFFER_LENGTH_SAMPLES_PER_CHANNEL); // _scope->addSamples(2, outputRight, BUFFER_LENGTH_SAMPLES_PER_CHANNEL);