merge upstream/master into andrew/thermonuclear

This commit is contained in:
Andrew Meadows 2015-03-10 14:28:02 -07:00
commit f82f9cc2f4
4 changed files with 33 additions and 13 deletions

View file

@ -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<AnimationCache>();
DependencyManager::destroy<TextureCache>();
@ -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__

View file

@ -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();
}

View file

@ -22,6 +22,8 @@ class GLCanvas : public QGLWidget {
public:
GLCanvas();
void stopFrameTimer();
bool isThrottleRendering() const;

View file

@ -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);
}
}
}