Skip to content

fix: Push-to-Talk audio distortion when re-recording after deletion

ashritha kunjeti requested to merge push-to-talk into feat/develop-pro

Summary

Fixed an issue where audio recorded in Push-to-Talk mode became choppy or distorted after deleting a recording and creating a new one within the same session.

Root Cause

The previous recording session was not fully cleaned up when recording stopped. While microphone tracks were being stopped, the associated AudioContext and audio processing nodes remained active.

As a result, when a new recording started:

  • The new session reset the audio chunk buffer.
  • Stale audio processing listeners from the previous session continued running.
  • Old and new audio data were written to the same buffer simultaneously.
  • The final merged audio contained invalid/interleaved chunks, causing distorted and choppy playback.

Changes Made

  • Added explicit cleanup for audio processing listeners by setting processor.onaudioprocess = null.
  • Disconnected audio nodes (processor, source, and related nodes) when recording stops.
  • Added proper shutdown of AudioContext during recording cleanup.
  • Ensured all recording resources are fully released before a new recording session starts.
  • Prevented stale audio processing pipelines from persisting across recording sessions.

Expected Result

  • First recording works normally.
  • Delete → Re-record produces clear audio.
  • Multiple delete → re-record cycles work consistently.
  • No stale audio listeners or audio contexts remain active after recording stops.

Testing

  • Recorded audio in Push-to-Talk mode.
  • Deleted the recording and re-recorded multiple times.
  • Verified audio playback remains clear and consistent across all recording attempts.
  • Confirmed no regressions in existing recording functionality.

*Closes #55

Edited by ashritha kunjeti

Merge request reports

Loading