psmokotnin / osm

Open sound meter. FFT based application for tuning sound systems.
GNU General Public License v3.0
222 stars 35 forks source link

Fix a deadlock in ALSA plugin #75

Closed lukaszmatczak closed 11 months ago

lukaszmatczak commented 12 months ago

When switching audio device on Linux with ALSA plugin, a deadlock in AlsaPlugin::open often occurs. m_deviceListMutex is supposed to be released after emitting AlsaPCMDevice::closed signal, but a connected slot is often not called.

As the signal is emitted from a different thread than a receiver is living, Qt::QueuedConnection is used by default. In such case the slot is called from the event loop of receiver object's thread. The thread is often blocked on locking mutex resulting in event loop not spinning and deadlock.

Connection type can be changed to Qt::DirectConnection so the slot is called immediately from the thread that emitted the signal. It should be safe as m_devices is protected by a mutex already.

This PR fixes #56 and also adds missing include in musicnoise.cpp that prevents from successful compilation on Linux.

psmokotnin commented 11 months ago

Thanks!