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