Skip to content
Snippets Groups Projects
Commit 53477661 authored by Andreas Traczyk's avatar Andreas Traczyk
Browse files

portaudiolayer: increase lock guard scope to enclose Pa_CloseStream

- Pa_CloseStream and Pa_StopStream are not thread safe and may
  (shouldn't) be called asynchronously.

Gitlab: #120
Change-Id: Ieafae4d76912c67a5803230e40960ceb8e76dbfb
parent dbcb0e6d
No related branches found
No related tags found
No related merge requests found
......@@ -169,26 +169,27 @@ PortAudioLayer::startStream(AudioDeviceType stream)
void
PortAudioLayer::stopStream(AudioDeviceType stream)
{
if (status_ != Status::Started)
return;
{
std::lock_guard<std::mutex> lock {mutex_};
JAMI_DBG("Stop PortAudio Streams");
if (status_ != Status::Started)
return;
for (auto& st_ptr : pimpl_->streams_) {
if (!st_ptr)
continue;
JAMI_DBG("Stop PortAudio Streams");
auto err = Pa_StopStream(st_ptr);
if (err != paNoError)
JAMI_ERR("Pa_StopStream error : %s", Pa_GetErrorText(err));
for (auto& st_ptr : pimpl_->streams_) {
if (!st_ptr)
continue;
err = Pa_CloseStream(st_ptr);
if (err != paNoError)
JAMI_ERR("Pa_StopStream error : %s", Pa_GetErrorText(err));
}
auto err = Pa_StopStream(st_ptr);
if (err != paNoError)
JAMI_ERR("Pa_StopStream error : %s", Pa_GetErrorText(err));
err = Pa_CloseStream(st_ptr);
if (err != paNoError)
JAMI_ERR("Pa_StopStream error : %s", Pa_GetErrorText(err));
}
{
std::lock_guard<std::mutex> lock {mutex_};
status_ = Status::Idle;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment