map

minimalist audio player
git clone https://git.porkepik.fr/map
Log | Files | Refs | README | LICENSE

commit 07c1af9b2f94b82dc0f5485b0a4c494ffd5a51be
parent 39b7e6d492714558693c84de8d60a90758dfbedf
Author: Thomas Philippe <dev@porkepik.fr>
Date:   Tue, 15 Sep 2020 05:44:12 +0200

fix gapless playback

Diffstat:
Mmap.c | 29+++++------------------------
1 file changed, 5 insertions(+), 24 deletions(-)

diff --git a/map.c b/map.c @@ -1,7 +1,7 @@ /* TODO * - add cli args to set seek_sec and default_vol * - fix seeking - * - fix gapless playback + * - fix next track skipped */ #include <dirent.h> @@ -233,22 +233,19 @@ static void play(void) { int trackid = 0, cursorid = 1, toptrack = 0, timersec; - int gapless = 0; - long done, bufsize, tmpbuf_len; - float *buf, *newbuf; + long done, bufsize; + float *buf; time_t start, pause; struct track curtrack; while (trackid < ntracks) { -next: pause = timersec = 0; start = time(NULL); curtrack = *tracks[trackid]; tracks[trackid]->current = 1; bufsize = opentrack(&curtrack); - if (!gapless) - buf = malloc(bufsize * sizeof(float)); + buf = malloc(bufsize * sizeof(float)); print_playlist(tracks, toptrack, cursorid); print_info(curtrack); print_volume(volume); @@ -351,23 +348,7 @@ next: continue; } - if (!gapless) { - done = decode(buf, bufsize); - if (trackid+1 < ntracks && done < bufsize) { - tmpbuf_len = done; - gapless = 1; - close_file(); - tracks[trackid]->current = 0; - trackid++; - goto next; - } - } else { - newbuf = malloc((bufsize - tmpbuf_len) * sizeof(float)); - done = decode(newbuf, bufsize - tmpbuf_len); - memcpy(buf + tmpbuf_len, newbuf, done * sizeof(float)); - free(newbuf); - gapless = 0; - } + done = decode(buf, bufsize); if (done < 0 || (done = alsa_play(buf, done)) < 0) { alsa_close();