Skip to content

mod_shell_stream: fix file_open() blocking playback until child exits - #3104

Open
RameshJayamJ wants to merge 1 commit into
signalwire:masterfrom
RameshJayamJ:fix/mod_shell_stream-streaming-playback
Open

mod_shell_stream: fix file_open() blocking playback until child exits#3104
RameshJayamJ wants to merge 1 commit into
signalwire:masterfrom
RameshJayamJ:fix/mod_shell_stream-streaming-playback

Conversation

@RameshJayamJ

Copy link
Copy Markdown

Description

Removes the blocking wait() call in file_open() that prevented FreeSWITCH from calling file_read() until the entire external command had exited, defeating the purpose of the background buffering thread. Child process reaping is moved to file_close() instead, with a bounded grace period + SIGKILL fallback so playback being cut short (e.g. caller hangs up mid-stream) can't leave a zombie or hung process.

Before: audio from a streaming shell command (e.g. a script that generates and writes audio progressively, such as a real-time TTS engine) is completely silent until the script fully exits, then plays back all at once.

After: audio starts playing as soon as the first frame's worth of data is available in the buffer, and streams in naturally as the child process produces more.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Code cleanup / refactor

Related Issues

Fixes #3089

Testing

  • Added/updated unit tests
  • Tested manually
  • Tested with live SignalWire credentials (if applicable)

Manually tested against a Python script streaming PCM16LE audio to stdout from a real-time TTS API over several seconds — confirmed playback now starts within the first buffered chunk instead of waiting for full completion. Also tested short-lived scripts (tone generator, static WAV file playback) to confirm unchanged behavior for that case, and tested closing the channel (hangup) while the child was still mid-stream to confirm clean process reaping via the grace-period/SIGKILL path.

Removes the blocking wait() call in file_open() that prevented
FreeSWITCH from calling file_read() until the entire external command
had exited, defeating the purpose of the background buffering thread.
Child process reaping moved to file_close() instead, with a bounded
grace period + SIGKILL fallback.

Fixes signalwire#3089

Signed-off-by: Ramesh Jayam J <ramesh.jayam@karix.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mod_shell_stream: file_open() blocks on wait() until the child process exits, preventing streaming playback

1 participant