Possible null pointer calls, fix unnecessary context switches

This commit is contained in:
Charles J. Cliffe 2015-10-22 01:42:50 -04:00
parent 1e0489f974
commit e61caaf5a6
2 changed files with 11 additions and 6 deletions

View File

@ -255,7 +255,9 @@ void DemodulatorInstance::setOutputDevice(int device_id) {
int DemodulatorInstance::getOutputDevice() {
if (currentOutputDevice == -1) {
currentOutputDevice = audioThread->getOutputDevice();
if (audioThread) {
currentOutputDevice = audioThread->getOutputDevice();
}
}
return currentOutputDevice;
@ -308,7 +310,7 @@ void DemodulatorInstance::setBandwidth(int bw) {
bw = AudioThread::deviceSampleRate[getOutputDevice()];
}
}
if (!active) {
if (!active && demodulatorPreThread != NULL) {
currentBandwidth = bw;
checkBandwidth();
demodulatorPreThread->getParams().bandwidth = currentBandwidth;

View File

@ -79,6 +79,7 @@ void WaterfallCanvas::processInputQueue() {
double targetVis = 1.0 / (double)linesPerSecond;
lpsIndex += gTimer.lastUpdateSeconds();
bool updated = false;
if (linesPerSecond) {
if (lpsIndex >= targetVis) {
while (lpsIndex >= targetVis) {
@ -90,6 +91,7 @@ void WaterfallCanvas::processInputQueue() {
waterfallPanel.setPoints(vData->spectrum_points);
waterfallPanel.step();
vData->decRefCount();
updated = true;
}
lpsIndex-=targetVis;
} else {
@ -98,10 +100,11 @@ void WaterfallCanvas::processInputQueue() {
}
}
}
wxClientDC(this);
glContext->SetCurrent(*this);
waterfallPanel.update();
if (updated) {
wxClientDC(this);
glContext->SetCurrent(*this);
waterfallPanel.update();
}
tex_update.unlock();
}