Skip to content

fix the audio rtp av issue on flushing - #163

Merged
b3by merged 5 commits into
meetecho:mainfrom
GaijinKa:hotfix/audio-rtp-av-flushing
Apr 20, 2026
Merged

fix the audio rtp av issue on flushing#163
b3by merged 5 commits into
meetecho:mainfrom
GaijinKa:hotfix/audio-rtp-av-flushing

Conversation

@GaijinKa

Copy link
Copy Markdown
Member

Description

This PR fixes the AudioRtpAv node to enhance its stability and data integrity during streaming.
The primary focus is replacing the internal PyAV FIFO with a manual NumPy-based buffering system.
This change allows the node to handle partial audio chunks more gracefully, specifically by providing the option to flush and pad remaining data with zeros when a stream is interrupted or closed.
Additionally, this update introduces robust timeout management to prevent the node from hanging during network failures and corrects the timestamp calculation logic in the emitted payloads.

PR type
Select all the labels that apply to this PR.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test update
  • Build/CI configuration change
  • Other (please describe):

Key modifications and changes

  • Buffering Logic: Replaced av.audio.fifo.AudioFifo with a NumPy `_pending[ array to store incoming samples.
  • Partial Flush Support: Added flush_partial_on_error parameter and _flush_pending method to ensure no data is lost upon exit; partial chunks are now padded with zeros to match the expected block size.
  • Timeout Implementation: Added rw_timeout to the default options and integrated JUTURNA_THREAD_JOIN_TIMEOUT into the av.open call to ensure the node can recover from unresponsive network resources.
  • Accurate Timestamps: Refactored the _emit_chunk method to calculate start and end times based on the actual number of samples processed (elapsed time) rather than simple block indices.
  • Error Handling: Added specific catching for av.error.ExitError and upgraded "source unavailable" logs from INFO to ERROR level for better visibility during failures.
  • Configuration: Updated config.toml to include the partial flush toggle by default

Affected components

Built-in Node: juturna.nodes.source._audio_rtp_av

- Replace av.audio.fifo.AudioFifo with a NumPy-based pending buffer for better control over partial chunks.
- Add `flush_partial_on_error` parameter to allow emitting zero-padded final chunks when a stream ends or fails.
- Implement proper read/write timeouts (rw_timeout) and JUTURNA_THREAD_JOIN_TIMEOUT in av.open to prevent hanging.
- Update timestamp logic to use elapsed time instead of purely block-based indexing.
- Improve error logging and handling of ExitError during demuxing.
- Add configuration support for `flush_partial` in config.toml.
@GaijinKa
GaijinKa requested a review from b3by April 17, 2026 15:46
@GaijinKa GaijinKa added the type:bug Something isn't working label Apr 17, 2026
Comment thread juturna/nodes/source/_audio_rtp_av/audio_rtp_av.py
@b3by

b3by commented Apr 20, 2026

Copy link
Copy Markdown
Collaborator

Looking good!

@b3by
b3by merged commit 1464f3d into meetecho:main Apr 20, 2026
2 checks passed
@GaijinKa
GaijinKa deleted the hotfix/audio-rtp-av-flushing branch April 20, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants