map

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

commit 36ce73d3c47edd8684bcd9d078fec4481a8523a1
parent 84ee925d69736cf7bd3e97177b823b94c8a32331
Author: Thomas Philippe <dev@porkepik.fr>
Date:   Mon, 18 May 2020 09:56:42 +0200

fix track transition

Diffstat:
Mmap.c | 11++++++++++-
Msndio.c | 18+++++++++++++++---
2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/map.c b/map.c @@ -1,3 +1,7 @@ +/* TODO + - volume change +*/ + #include <dirent.h> #include <err.h> #include <stdio.h> @@ -38,8 +42,10 @@ void set_cursor(int, int); char poll_key_event(void); /* sndio.c */ +int sndio_init(void); int sndio_open(int, int, int); int sndio_play(void *, int); +void sndio_stop(void); void sndio_close(void); /* flac.c */ @@ -299,7 +305,7 @@ playtrack(struct track curtrack, struct player player, int trackid) curtrack.close(); trackid++; endtrack: - sndio_close(); + sndio_stop(); return trackid; } @@ -320,10 +326,13 @@ main(int argc, char **argv) qsort(player.tracks, ntracks, sizeof(*player.tracks), trackcmp); init_term(); + if (sndio_init() < 0) + errx(1, "Could not initialize sndio.\n"); while (trackid < ntracks) trackid = playtrack(*player.tracks[trackid], player, trackid); + sndio_close(); end_term(); return 0; diff --git a/sndio.c b/sndio.c @@ -13,13 +13,18 @@ sndio_vol(long vol) } int -sndio_open(int bits, int rate, int channels) +sndio_init(void) { - struct sio_par par; - hdl = sio_open(SIO_DEVANY, SIO_PLAY, 0); if (!hdl) return -1; + return 0; +} + +int +sndio_open(int bits, int rate, int channels) +{ + struct sio_par par; sio_initpar(&par); par.bits = bits; @@ -47,6 +52,13 @@ sndio_play(void *buf, size_t nbytes) } void +sndio_stop(void) +{ + if (hdl) + sio_stop(hdl); +} + +void sndio_close(void) { if (hdl)