diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6945e88949..c53f387518 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -602,7 +602,10 @@ Application::~Application() { _myAvatar = NULL; - ModelEntityItem::cleanupLoadedAnimations() ; + ModelEntityItem::cleanupLoadedAnimations(); + + // stop the glWidget frame timer so it doesn't call paintGL + _glWidget->stopFrameTimer(); DependencyManager::destroy(); DependencyManager::destroy(); @@ -614,7 +617,7 @@ Application::~Application() { } void Application::initializeGL() { - qDebug( "Created Display Window."); + qDebug() << "Created Display Window."; // initialize glut for shape drawing; Qt apparently initializes it on OS X #ifndef __APPLE__ diff --git a/interface/src/GLCanvas.cpp b/interface/src/GLCanvas.cpp index 10090de51a..b72c00c779 100644 --- a/interface/src/GLCanvas.cpp +++ b/interface/src/GLCanvas.cpp @@ -31,6 +31,10 @@ GLCanvas::GLCanvas() : QGLWidget(QGL::NoDepthBuffer | QGL::NoStencilBuffer), #endif } +void GLCanvas::stopFrameTimer() { + _frameTimer.stop(); +} + bool GLCanvas::isThrottleRendering() const { return _throttleRendering || Application::getInstance()->getWindow()->isMinimized(); } diff --git a/interface/src/GLCanvas.h b/interface/src/GLCanvas.h index e2bbf3b841..7b86f983e9 100644 --- a/interface/src/GLCanvas.h +++ b/interface/src/GLCanvas.h @@ -22,6 +22,8 @@ class GLCanvas : public QGLWidget { public: GLCanvas(); + + void stopFrameTimer(); bool isThrottleRendering() const; diff --git a/libraries/audio/src/Sound.cpp b/libraries/audio/src/Sound.cpp index cc41a849e7..6f149bb203 100644 --- a/libraries/audio/src/Sound.cpp +++ b/libraries/audio/src/Sound.cpp @@ -94,30 +94,41 @@ void Sound::downloadFinished(QNetworkReply* reply) { void Sound::downSample(const QByteArray& rawAudioByteArray) { // assume that this was a RAW file and is now an array of samples that are - // signed, 16-bit, 48Khz, mono + // signed, 16-bit, 48Khz // we want to convert it to the format that the audio-mixer wants - // which is signed, 16-bit, 24Khz, mono - - _byteArray.resize(rawAudioByteArray.size() / 2); - + // which is signed, 16-bit, 24Khz + int numSourceSamples = rawAudioByteArray.size() / sizeof(int16_t); + + int numDestinationBytes = rawAudioByteArray.size() / 2; + if (_isStereo && numSourceSamples % 4 != 0) { + numDestinationBytes += 1; + } + + _byteArray.resize(numDestinationBytes); + + int16_t* sourceSamples = (int16_t*) rawAudioByteArray.data(); int16_t* destinationSamples = (int16_t*) _byteArray.data(); - if (_isStereo) { for (int i = 0; i < numSourceSamples; i += 4) { - destinationSamples[i / 2] = (sourceSamples[i] / 2) + (sourceSamples[i + 2] / 2); - destinationSamples[(i / 2) + 1] = (sourceSamples[i + 1] / 2) + (sourceSamples[i + 3] / 2); + if (i + 2 >= numSourceSamples) { + destinationSamples[i / 2] = sourceSamples[i]; + destinationSamples[(i / 2) + 1] = sourceSamples[i + 1]; + } else { + destinationSamples[i / 2] = (sourceSamples[i] + sourceSamples[i + 2]) / 2; + destinationSamples[(i / 2) + 1] = (sourceSamples[i + 1] + sourceSamples[i + 3]) / 2; + } + } } else { for (int i = 1; i < numSourceSamples; i += 2) { if (i + 1 >= numSourceSamples) { - destinationSamples[(i - 1) / 2] = (sourceSamples[i - 1] / 2) + (sourceSamples[i] / 2); + destinationSamples[(i - 1) / 2] = (sourceSamples[i - 1] + sourceSamples[i]) / 2; } else { - destinationSamples[(i - 1) / 2] = (sourceSamples[i - 1] / 4) + (sourceSamples[i] / 2) - + (sourceSamples[i + 1] / 4); + destinationSamples[(i - 1) / 2] = ((sourceSamples[i - 1] + sourceSamples[i + 1]) / 4) + (sourceSamples[i] / 2); } } }