I found the fix to the code to make it playback live stream continously.
It needs to add following codes
rc = snd_pcm_writei(playback_handle, out_buffer2, outframes);
+ if (rc < 0) {
+ snd_pcm_recover(playback_handle, rc, 0);
+ }
Which means, there are errors during stream playing, it needs to recover the ALSA from error.
Now, it can playback live stream continously, but I hit another problem: the is slight break when link is changing, as follows,
[http @ 0x6eaba0] Opening 'http://broadcast.tx.xmcdn.com/live/2730_64_241107_000014_1e5b.aac' for reading
ALSA lib pcm.c:8675:(snd_pcm_recover) underrun occurred
[http @ 0x7665d0] Opening 'http://live.ximalaya.com/radio-first-page-app/live/2730/64.m3u8' for reading
[hls @ 0x6db020] Skip ('#EXT-X-VERSION:3')
[http @ 0x707c40] Opening 'http://broadcast.tx.xmcdn.com/live/2730_64_241107_000014_1e5c.aac' for reading
ALSA lib pcm.c:8675:(snd_pcm_recover) underrun occurred
[http @ 0x7665d0] Opening 'http://live.ximalaya.com/radio-first-page-app/live/2730/64.m3u8' for reading
[hls @ 0x6db020] Skip ('#EXT-X-VERSION:3')
[http @ 0x6eaba0] Opening 'http://broadcast.tx.xmcdn.com/live/2730_64_241107_000014_1e5d.aac' for reading
ALSA lib pcm.c:8675:(snd_pcm_recover) underrun occurred
It seemed something wrong in my buffer/period settings, what is the right value to set???