webrtc-java icon indicating copy to clipboard operation
webrtc-java copied to clipboard

Cannot customize the push voice stream

Open vipzipp opened this issue 5 months ago • 3 comments

Describe the bug I am unable to hear clear sound on the device using CustomAudioSource.pushAudio, and it often reports errors

To Reproduce Steps to reproduce the behavior: The audio stream returned by calling TTS byte[] data = new byte[buffer.remaining()]; buffer.get(data); audio = ByteUtils.concat(audio, data); // play tts audio MediaManager bean = ApplicationContextUtil.getBean(MediaManager.class); CustomAudioSource customAudioSource = bean.getCustomAudioSource();

            customAudioSource.pushAudio(audio, 16, 16000, 1, 160);

Expected behavior I expect the streaming voice to be played normally

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS] macos
  • Version [e.g. 22] 15.6.1 (24G90)

Additional context I hope to use WebRTC Java to implement a JavaScript request for Java, and then Java calls ASR, LLM synthesizes TTS speech stream, and then plays it, similar to a robot

vipzipp avatar Sep 22 '25 07:09 vipzipp

Frequently prompt this error Image

vipzipp avatar Sep 22 '25 07:09 vipzipp

Duplicate of #118.

You are not alone running into this issue. The problem here is that you are using the CustomAudioSource from multiple threads and then you are running into race conditions as the error states. To handle the CustomAudioSource properly, please wrap its usage into a single thread.

devopvoid avatar Oct 19 '25 12:10 devopvoid

Duplicate of #118.

You are not alone running into this issue. The problem here is that you are using the CustomAudioSource from multiple threads and then you are running into race conditions as the error states. To handle the CustomAudioSource properly, please wrap its usage into a single thread.

Thanks! I redirected to the link to see the content. I had also added synchronized before and only came to seek advice after it was not resolved. I noticed that the issue # 118 has not been resolved, and several developers have encountered this problem @devopvoid

ziyoushu avatar Oct 24 '25 03:10 ziyoushu