AudioThread: re-apply consistent formating

This commit is contained in:
vsonnier 2018-01-22 07:10:45 +01:00
parent fc1c1c3b4d
commit 033bbd07df
2 changed files with 166 additions and 157 deletions

View File

@ -201,7 +201,8 @@ static int audioCallback(void *outputBuffer, void * /* inputBuffer */, unsigned
} }
srcmix->audioQueuePtr++; srcmix->audioQueuePtr++;
} }
} else { }
else {
for (int i = 0, iMax = srcmix->currentInput->channels * nBufferFrames; i < iMax; i++) { for (int i = 0, iMax = srcmix->currentInput->channels * nBufferFrames; i < iMax; i++) {
if (srcmix->audioQueuePtr >= srcmix->currentInput->data.size()) { if (srcmix->audioQueuePtr >= srcmix->currentInput->data.size()) {
@ -400,7 +401,8 @@ void AudioThread::setupDevice(int deviceId) {
if (deviceSampleRate.find(parameters.deviceId) != deviceSampleRate.end()) { if (deviceSampleRate.find(parameters.deviceId) != deviceSampleRate.end()) {
sampleRate = deviceSampleRate[parameters.deviceId]; sampleRate = deviceSampleRate[parameters.deviceId];
} else { }
else {
std::cout << "Error, device sample rate wasn't initialized?" << std::endl; std::cout << "Error, device sample rate wasn't initialized?" << std::endl;
return; return;
// sampleRate = AudioThread::getDefaultAudioSampleRate(); // sampleRate = AudioThread::getDefaultAudioSampleRate();
@ -417,12 +419,14 @@ void AudioThread::setupDevice(int deviceId) {
deviceController[parameters.deviceId]->bindThread(this); deviceController[parameters.deviceId]->bindThread(this);
deviceController[parameters.deviceId]->attachControllerThread(new std::thread(&AudioThread::threadMain, deviceController[parameters.deviceId])); deviceController[parameters.deviceId]->attachControllerThread(new std::thread(&AudioThread::threadMain, deviceController[parameters.deviceId]));
} else if (deviceController[parameters.deviceId] == this) { }
else if (deviceController[parameters.deviceId] == this) {
//Attach callback //Attach callback
dac.openStream(&parameters, NULL, RTAUDIO_FLOAT32, sampleRate, &nBufferFrames, &audioCallback, (void *)this, &opts); dac.openStream(&parameters, NULL, RTAUDIO_FLOAT32, sampleRate, &nBufferFrames, &audioCallback, (void *)this, &opts);
dac.startStream(); dac.startStream();
} else { }
else {
//we are a bound thread, add ourselves to the controller deviceController[parameters.deviceId]. //we are a bound thread, add ourselves to the controller deviceController[parameters.deviceId].
//beware, we must take the controller mutex, because the audio callback may use the list of bounded //beware, we must take the controller mutex, because the audio callback may use the list of bounded
//threads at that moment: //threads at that moment:
@ -432,7 +436,8 @@ void AudioThread::setupDevice(int deviceId) {
} }
active = true; active = true;
} catch (RtAudioError& e) { }
catch (RtAudioError& e) {
e.printMessage(); e.printMessage();
return; return;
} }
@ -461,7 +466,8 @@ void AudioThread::setInitOutputDevice(int deviceId, int sampleRate) {
if (deviceSampleRate.find(parameters.deviceId) != deviceSampleRate.end()) { if (deviceSampleRate.find(parameters.deviceId) != deviceSampleRate.end()) {
sampleRate = deviceSampleRate[deviceId]; sampleRate = deviceSampleRate[deviceId];
} }
} else { }
else {
deviceSampleRate[deviceId] = sampleRate; deviceSampleRate[deviceId] = sampleRate;
} }
this->sampleRate = sampleRate; this->sampleRate = sampleRate;
@ -522,7 +528,8 @@ void AudioThread::run() {
std::lock_guard<std::recursive_mutex> lock(deviceController[parameters.deviceId]->getMutex()); std::lock_guard<std::recursive_mutex> lock(deviceController[parameters.deviceId]->getMutex());
deviceController[parameters.deviceId]->removeThread(this); deviceController[parameters.deviceId]->removeThread(this);
} else { }
else {
// 'this' is a controller thread: // 'this' is a controller thread:
try { try {
if (dac.isStreamOpen()) { if (dac.isStreamOpen()) {
@ -531,7 +538,8 @@ void AudioThread::run() {
} }
dac.closeStream(); dac.closeStream();
} }
} catch (RtAudioError& e) { }
catch (RtAudioError& e) {
e.printMessage(); e.printMessage();
} }
} }
@ -571,7 +579,8 @@ void AudioThread::setActive(bool state) {
if (state && !active && inputQueue) { if (state && !active && inputQueue) {
matchingControllerThread->bindThread(this); matchingControllerThread->bindThread(this);
} else if (!state && active) { }
else if (!state && active) {
matchingControllerThread->removeThread(this); matchingControllerThread->removeThread(this);
} }