开发者

Gap buffering in Android devices

I'm building a buffering engine to play streams from url.. I need to buffering both mp3 and aac ( on device that can support it ) so I can't pass directly the url to MediaPlayer.. I tried this method: I have 2 synchronized thread, one that running creates some file with data from buffer and the second playing files created: the problem is that when mediaplayer switch from a file to another, there is a little gap... how can I remove it?? is very annoying...

Mayb开发者_运维知识库e my method is wrong, if so can anyone provide a working method without chopping sound??

Thank you very much in advance..


It seems you are trying to implement Gapless Playback. (Right ? ) Towards this you need to define level of Gapless Playback you want to achieve. Should it be across fileformats / codecs, audio attributes like sample rate, number of channels etc.

With your approach, you ll surely see gaps across different streams. (Fileformats , compression, audio attributes).

To achive true Gapless playback at application level (My Approach) you need to do the following

  1. Implement custom stack, that would take the input files, decode it and produce pcm samples. This stack will have Parsers (MP3, AAC), and decoders (MP3, AAC..)

  2. Pass pcm samples through resampler, to produce pcm samples having same sample rate.

  3. Add buffering modules at input (File) and output (resampled pcm data).

  4. Use AudioTrack class of Android SDK for playout.

If you stick to one fileformat, Codec and audio attributes, then at application level, you can concatenate all the files in the playlist and provide it to MediaPLayer for playback. (Since audio streams have less size, this solution can be practical. Only obstacle would be streams attributes. If the Audio OMX Components within Android Multimedia stack support dynamic reconfiguration, then this should be no issue at all)

Shash

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜