Skip to content

Commit 977abea

Browse files
m0dBm0dB
authored andcommitted
always call Pa_CloseStream , even when error occurs
1 parent 528f92d commit 977abea

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/soundio/sounddeviceportaudio.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,6 @@ SoundDeviceStatus SoundDevicePortAudio::close() {
461461
if (err < 0) {
462462
qWarning() << "PortAudio: Pa_IsStreamStopped returned error:"
463463
<< Pa_GetErrorText(err) << m_deviceId;
464-
return SoundDeviceStatus::Error;
465464
}
466465
if (err == 1) {
467466
qWarning() << "PortAudio: Stream already stopped";
@@ -472,24 +471,23 @@ SoundDeviceStatus SoundDevicePortAudio::close() {
472471

473472
// We can now safely call Pa_StopStream, which should not block as the
474473
// stream has become inactive.
475-
err = Pa_StopStream(m_pStream);
474+
err = Pa_StopStream(pStream);
476475
if (err != paNoError) {
477476
qWarning() << "PortAudio: Stop stream error:"
478477
<< Pa_GetErrorText(err) << m_deviceId;
479-
return SoundDeviceStatus::Error;
480478
}
481479
}
482480

483-
// We can now safely set m_pStream to null
484-
m_pStream.store(nullptr, std::memory_order_release);
485-
486481
// Close stream
487482
err = Pa_CloseStream(pStream);
488483
if (err != paNoError) {
489484
qWarning() << "PortAudio: Close stream error:"
490485
<< Pa_GetErrorText(err) << m_deviceId;
491486
return SoundDeviceStatus::Error;
492487
}
488+
489+
// We can now safely set m_pStream to null
490+
m_pStream.store(nullptr, std::memory_order_release);
493491
}
494492

495493
m_outputFifo.reset();

0 commit comments

Comments
 (0)