mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-23 20:28:40 -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;
|
std::cout << "Application termination complete." << std::endl << std::flush;
|
||||||
|
|
||||||
#ifdef __APPLE__
|
//TODO ?
|
||||||
AudioThread::deviceCleanup();
|
AudioThread::deviceCleanup();
|
||||||
#endif
|
|
||||||
|
|
||||||
return wxApp::OnExit();
|
return wxApp::OnExit();
|
||||||
}
|
}
|
||||||
|
@ -81,24 +81,10 @@ void AudioThread::removeThread(AudioThread *other) {
|
|||||||
void AudioThread::deviceCleanup() {
|
void AudioThread::deviceCleanup() {
|
||||||
|
|
||||||
std::lock_guard<std::recursive_mutex> lock(m_device_mutex);
|
std::lock_guard<std::recursive_mutex> lock(m_device_mutex);
|
||||||
|
// only notify, let the thread die by itself.
|
||||||
auto it = deviceController.begin();
|
for (auto i = deviceController.begin(); i != deviceController.end(); i++) {
|
||||||
|
i->second->terminate();
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int audioCallback(void *outputBuffer, void * /* inputBuffer */, unsigned int nBufferFrames, double /* streamTime */, RtAudioStreamStatus status,
|
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] = new AudioThread();
|
||||||
|
|
||||||
deviceController[parameters.deviceId]->setInitOutputDevice(parameters.deviceId, sampleRate);
|
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]->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) {
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <algorithm>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "ThreadBlockingQueue.h"
|
#include "ThreadBlockingQueue.h"
|
||||||
#include "RtAudio.h"
|
#include "RtAudio.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user