Android Play PCM byte array from Converted from Base64 String Slow Sounds

前端 未结 1 493
天命终不由人
天命终不由人 2020-12-21 15:21

As the very long title suggests, I\'m having trouble playing the audio from a audio that I send over the network through PubNunb. What I do is I send the audio while recordi

相关标签:
1条回答
  • 2020-12-21 15:51

    pubnub delivers data through tcp (not udp). http://www.pubnub.com/knowledge-base/discussion/263/does-pubnub-support-the-udp-protocol

    There should be no need to handle packet loss in your application.

    You may need to handle jitter by creating a buffer of some sort. Since there would be no rigid realtime constraint, I will discuss an approach rather than pasting code.

    You can make a buffer using a queue. I suggest having two threads. One for your reader (your player) and one for writer (the network stream). Let the writer queue up some data (maybe a few seconds of data) before letting the reader read. On paper, with a very simply proof of concept, you should not have issues with simultaneous reads and writes since the writer is writing to the end of the queue and the reader is reading at the beginning of the queue.

    Think of it as a bucket that is halfway full. You pour water in and let water leak out at the same rate.

    0 讨论(0)
提交回复
热议问题