Repository navigation
fix: allow --out to target FIFOs and char devices (e.g. /dev/stdout) - #796
Merged
Merged
Conversation
Owner
|
@trappedinspacetime Thanks! PR merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
--outcannot target a pipe, FIFO, or character device such as/dev/stdout. Piping TTS output directly into a player (e.g.audiocpp_cli ... --out /dev/stdout | aplay -t wav -) silentlyproduces no audio on the reader side.
Root cause
write_wav_output()inapp/workflow/file_sink.cppalways writes toa sibling
<path>.tmpfile and then callsstd::filesystem::rename(tmp, path)to move it into place atomically. When
pathis a FIFO or a chardevice,
rename()unlinks that special file and replaces it with aplain regular file instead of writing into it — so nothing ever
reaches whatever has the other end open (e.g. a reader blocked on
open()for a named pipe, or the process on the other end of a shellpipe).
WavSink::write()/write_wav()itself is not the problem: it's asingle sequential pass with no seeking (the RIFF/data chunk sizes are
computed up front from the in-memory sample buffer, not patched in
after the fact), so writing straight to a special file is safe.
Fix
Detect when the target path is a FIFO, character device, or socket
(
std::filesystem::statusfollows symlinks, so this also covers/dev/stdoutwhen it resolves to a pipe) and skip the temp-file +rename step for those targets, writing directly instead. Regular
files keep the existing temp+rename behavior unchanged.
Build