MCPcopy Create free account
hub / github.com/aethersdr/AetherSDR / createRxAudioStream

Method createRxAudioStream

src/models/RadioModel.cpp:3621–3678  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3619}
3620
3621void RadioModel::createRxAudioStream()
3622{
3623 if (m_rxAudio.streamId != 0) {
3624 logRemoteAudioRxSummary(QStringLiteral("create skipped: stream already known"));
3625 return;
3626 }
3627 if (m_rxAudio.createPending) {
3628 logRemoteAudioRxSummary(QStringLiteral("create skipped: request already pending"));
3629 return;
3630 }
3631
3632 m_rxAudio.createPending = true;
3633 m_rxAudio.removeRequested = false;
3634 resetAudioStreamDiagnostics();
3635 logRemoteAudioRxSummary(QStringLiteral("create requested"));
3636 // Push our mute preference before opening the stream. Firmware defaults
3637 // mute_local_audio_when_remote=1, silencing hardware outputs whenever any
3638 // remote_audio_rx stream exists. Overriding here covers multi-client
3639 // scenarios where another client (e.g. SmartSDR) has set it to 1. (#1069)
3640 sendCmd(QString("radio set mute_local_audio_when_remote=%1")
3641 .arg(m_muteLocalWhenRemote ? 1 : 0));
3642 sendCmd(QString("stream create type=remote_audio_rx compression=%1").arg(audioCompressionParam()),
3643 [this](int code, const QString& body) {
3644 m_rxAudio.createPending = false;
3645 if (code == 0) {
3646 const quint32 streamId = RadioStatusOwnership::parseCreateResponseStreamId(body);
3647 if (streamId == 0) {
3648 qCWarning(lcProtocol) << "RadioModel: stream create remote_audio_rx returned unparseable body:"
3649 << body;
3650 logRemoteAudioRxSummary(QStringLiteral("create response unparseable"));
3651 return;
3652 }
3653
3654 if (m_rxAudio.streamId != 0 && m_rxAudio.streamId != streamId) {
3655 const quint32 oldStreamId = m_rxAudio.streamId;
3656 qCDebug(lcProtocol) << "RadioModel: replacing restored remote_audio_rx"
3657 << RadioStatusOwnership::hexId(oldStreamId)
3658 << "with create response"
3659 << RadioStatusOwnership::hexId(streamId);
3660 sendCmd(QString("stream remove %1").arg(RadioStatusOwnership::hexId(oldStreamId)));
3661 }
3662
3663 m_rxAudio.streamId = streamId;
3664 m_rxAudio.clientHandle = clientHandle();
3665 m_rxAudio.compression = audioCompressionParam();
3666 resetAudioStreamDiagnostics();
3667 qCDebug(lcProtocol) << "RadioModel: remote_audio_rx stream created, id:"
3668 << RadioStatusOwnership::hexId(streamId);
3669 logRemoteAudioRxSummary(QStringLiteral("create response adopted"));
3670 if (m_rxAudio.removeRequested)
3671 removeRxAudioStream();
3672 } else {
3673 qCWarning(lcProtocol) << "RadioModel: stream create remote_audio_rx failed, code"
3674 << Qt::hex << code << "body:" << body;
3675 logRemoteAudioRxSummary(QStringLiteral("create failed"));
3676 }
3677 });
3678}

Callers 3

MainWindowMethod · 0.80
onSliceAddedMethod · 0.80

Calls 2

hexIdFunction · 0.70

Tested by

no test coverage detected