f4exb / sdrangel

SDR Rx/Tx software for Airspy, Airspy HF+, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay and FunCube
GNU General Public License v3.0
2.72k stars 421 forks source link

Problem with multiple audio demods on different devices #2102

Closed srcejon closed 1 month ago

srcejon commented 1 month ago

If on Windows we have two SDRs each with a BFM Demod, it seems stopping the second can interfere with playback of the first. To recreate:

Problem doesn't seem to happen if we stop first device rather than the second. Doesn't seem to be a problem on Linux. Doesn't seem to be a problem for NFM or AM Demods.

srcejon commented 1 month ago

AM/NFM demods both delete the baseband object when stop() is called, the BFM Demod doesn't.

 DSPEngine::instance()->getAudioDeviceManager()->removeAudioSink(m_sink.getAudioFifo());

is in the destructor for each of these basebands. This isn't therefore getting called for the BFM demod when stop() is called.

srcejon commented 1 month ago

Actually, it seems the AM and NFM demods do have a problem, it just manifests in a different way. If you just start one device, without having started the other, then wait a few seconds, you'll eventually get AudioFIFO::write overflows.

srcejon commented 1 month ago

The problem with the AM & NFM demods, appears to relate to the fact they call start() from within the Demod's constructor. If I remove those calls to start(), so start() is only called when the device starts, the problem appears to go away.

So it looks like the problem will occur if we have an audio sink connected to the AudioDeviceManager, when the corresponding device isn't running.