mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-23 12:18:37 -05:00
AudioThread: rollback deviceCleanup() to only doing terminate + TEST: apply to all platforms
This commit is contained in:
parent
36224defd7
commit
fc1c1c3b4d
@ -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();
|
||||
}
|
||||
|
@ -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++;
|
||||
// only notify, let the thread die by itself.
|
||||
for (auto i = deviceController.begin(); i != deviceController.end(); i++) {
|
||||
i->second->terminate();
|
||||
}
|
||||
|
||||
std::cout << "Final audio management cleanup complete..." << std::endl << std::flush;
|
||||
}
|
||||
|
||||
static int audioCallback(void *outputBuffer, void * /* inputBuffer */, unsigned int nBufferFrames, double /* streamTime */, RtAudioStreamStatus status,
|
||||
@ -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) {
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <atomic>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include "ThreadBlockingQueue.h"
|
||||
#include "RtAudio.h"
|
||||
|
Loading…
Reference in New Issue
Block a user