Fix crash in AudioThread::setActive

If AudioThread::run() hasn't been called yet, we can dereference a null inputQueue
This commit is contained in:
Eoin Mcloughlin 2015-10-07 20:18:29 +01:00
parent 2a95d05631
commit 0b10a5b30c

View File

@ -428,7 +428,7 @@ bool AudioThread::isActive() {
void AudioThread::setActive(bool state) {
AudioThreadInput *dummy;
if (state && !active) {
if (state && !active && inputQueue) {
while (!inputQueue->empty()) { // flush queue
inputQueue->pop(dummy);
if (dummy) {
@ -438,10 +438,12 @@ void AudioThread::setActive(bool state) {
deviceController[parameters.deviceId]->bindThread(this);
} else if (!state && active) {
deviceController[parameters.deviceId]->removeThread(this);
while (!inputQueue->empty()) { // flush queue
inputQueue->pop(dummy);
if (dummy) {
dummy->decRefCount();
if(inputQueue) {
while (!inputQueue->empty()) { // flush queue
inputQueue->pop(dummy);
if (dummy) {
dummy->decRefCount();
}
}
}
}