Skip to content

Commit

Permalink
AudioThread: rollback deviceCleanup() to only doing terminate + TEST:…
Browse files Browse the repository at this point in the history
… apply to all platforms
  • Loading branch information
vsonnier committed Jan 22, 2018
1 parent 36224de commit fc1c1c3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
3 changes: 1 addition & 2 deletions src/CubicSDR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,8 @@ int CubicSDR::OnExit() {

std::cout << "Application termination complete." << std::endl << std::flush;

#ifdef __APPLE__
//TODO ?
AudioThread::deviceCleanup();
#endif

return wxApp::OnExit();
}
Expand Down
24 changes: 4 additions & 20 deletions src/audio/AudioThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,10 @@ void AudioThread::removeThread(AudioThread *other) {
void AudioThread::deviceCleanup() {

std::lock_guard<std::recursive_mutex> lock(m_device_mutex);

auto it = deviceController.begin();

std::cout << "Final audio management cleanup, terminating " << deviceController.size() << " device controllers..." << std::endl << std::flush;

while (it != deviceController.end()) {

//notify termination...
it->second->terminate();

//deletion of it->second will take care of the controllerThread:
delete it->second;

//next device
it++;
}

std::cout << "Final audio management cleanup complete..." << std::endl << std::flush;
// only notify, let the thread die by itself.
for (auto i = deviceController.begin(); i != deviceController.end(); i++) {
i->second->terminate();
}
}

static int audioCallback(void *outputBuffer, void * /* inputBuffer */, unsigned int nBufferFrames, double /* streamTime */, RtAudioStreamStatus status,
Expand Down Expand Up @@ -428,9 +414,7 @@ void AudioThread::setupDevice(int deviceId) {
deviceController[parameters.deviceId] = new AudioThread();

deviceController[parameters.deviceId]->setInitOutputDevice(parameters.deviceId, sampleRate);
// BEWARE: the controller add itself to the list of boundThreads !
deviceController[parameters.deviceId]->bindThread(this);

deviceController[parameters.deviceId]->attachControllerThread(new std::thread(&AudioThread::threadMain, deviceController[parameters.deviceId]));

} else if (deviceController[parameters.deviceId] == this) {
Expand Down
1 change: 0 additions & 1 deletion src/audio/AudioThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <map>
#include <string>
#include <atomic>
#include <algorithm>
#include <memory>
#include "ThreadBlockingQueue.h"
#include "RtAudio.h"
Expand Down

0 comments on commit fc1c1c3

Please sign in to comment.