thread safety + stop recorder on audio stream deselect

This commit is contained in:
AlexandreRouma 2022-09-26 15:08:01 +02:00
parent 3421aae9a2
commit 869b3e0abd

View File

@ -180,6 +180,7 @@ public:
} }
void selectStream(std::string name) { void selectStream(std::string name) {
std::lock_guard<std::recursive_mutex> lck(recMtx);
deselectStream(); deselectStream();
audioStream = sigpath::sinkManager.bindStream(name); audioStream = sigpath::sinkManager.bindStream(name);
if (!audioStream) { return; } if (!audioStream) { return; }
@ -188,7 +189,9 @@ public:
} }
void deselectStream() { void deselectStream() {
std::lock_guard<std::recursive_mutex> lck(recMtx);
if (selectedStreamName.empty() || !audioStream) { return; } if (selectedStreamName.empty() || !audioStream) { return; }
if (recording && recMode == RECORDER_MODE_AUDIO) { stop(); }
splitter.stop(); splitter.stop();
sigpath::sinkManager.unbindStream(selectedStreamName, audioStream); sigpath::sinkManager.unbindStream(selectedStreamName, audioStream);
selectedStreamName = ""; selectedStreamName = "";