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

Method loadPipeSink

src/core/PipeWireAudioBridge.cpp:295–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

293}
294
295bool PipeWireAudioBridge::loadPipeSink()
296{
297 // FIFO lives in the per-user XDG runtime directory with mode 0600.
298 // See GHSA-x8xf-4g5v-ppf9.
299 const QString fifoDir = daxFifoDir();
300 if (fifoDir.isEmpty()) return false;
301 auto pipePath = QStringLiteral("%1/tx.pipe").arg(fifoDir);
302 auto sinkName = QStringLiteral("aethersdr-tx");
303 auto sinkDesc = QStringLiteral("AetherSDR TX");
304
305 if (!makeOwnedFifo(pipePath)) return false;
306
307 // Use a small pipe buffer (2048 bytes ~ 42ms at 24kHz mono s16le)
308 // to keep latency low for digital modes like FT8/FT4.
309 uint32_t modIdx = runPactl({
310 "load-module", "module-pipe-sink",
311 QStringLiteral("file=%1").arg(pipePath),
312 QStringLiteral("sink_name=%1").arg(sinkName),
313 // Single-quoted — see loadPipeSource(): unquoted, the space in
314 // "AetherSDR TX" truncates device.description to "AetherSDR".
315 QStringLiteral("sink_properties='device.description=\"%1\"'").arg(sinkDesc),
316 QStringLiteral("format=s16le"),
317 QStringLiteral("rate=%1").arg(TX_RATE),
318 QStringLiteral("channels=%1").arg(TX_CHANNELS),
319 QStringLiteral("pipe_size=2048"),
320 });
321
322 if (modIdx == 0) {
323 ::unlink(pipePath.toUtf8().constData());
324 return false;
325 }
326
327 // Open the pipe for reading (non-blocking)
328 int fd = ::open(pipePath.toUtf8().constData(), O_RDONLY | O_NONBLOCK);
329 if (fd < 0) {
330 qCWarning(lcDax) << "PipeWireAudioBridge: open TX pipe failed:" << strerror(errno);
331 runPactl({"unload-module", QString::number(modIdx)});
332 ::unlink(pipePath.toUtf8().constData());
333 return false;
334 }
335
336 m_tx.fd = fd;
337 m_tx.moduleIndex = modIdx;
338 m_tx.pipePath = pipePath;
339
340 qCDebug(lcDax) << "PipeWireAudioBridge: TX pipe sink loaded, module" << modIdx;
341 return true;
342}
343
344void PipeWireAudioBridge::unloadModules()
345{

Callers

nothing calls this directly

Calls 4

daxFifoDirFunction · 0.85
runPactlFunction · 0.85
makeOwnedFifoFunction · 0.70
isEmptyMethod · 0.45

Tested by

no test coverage detected