sad

simple audio daemon
git clone git://git.2f30.org/sad
Log | Files | Refs | LICENSE

commit 82fc866891a8b87eac7e60df1fa10e2e4f3894c9
parent 5d78b0d76d470f1425c0a0053f54597794a9ea5f
Author: sin <sin@2f30.org>
Date:   Sat, 27 Dec 2014 10:43:41 +0000

Keep the output open

We can handle volume changes even if a song is not playing and also
allows us to do gapless playback and potentially stream stuff over a
FIFO.

Diffstat:
Mmp3.c | 15+++------------
Msad.c | 1+
Msndio.c | 12++++--------
Mvorbis.c | 12+-----------
Mwav.c | 5-----
5 files changed, 9 insertions(+), 36 deletions(-)

diff --git a/mp3.c b/mp3.c @@ -44,10 +44,6 @@ mp3open(const char *name) goto err0; } - r = output->open(mpg123_encsize(encoding) * 8, rate, channels); - if (r < 0) - goto err0; - return 0; err0: mpg123_close(hdl); @@ -73,16 +69,11 @@ mp3decode(void *buf, int nbytes) static int mp3close(void) { - int r = 0; - - r = mpg123_close(hdl); - if (r != MPG123_OK) { + if (mpg123_close(hdl) != MPG123_OK) { warnx("mpg123_close: failed"); - r = -1; + return -1; } - if (output->close() < 0) - r = -1; - return r; + return 0; } static void diff --git a/sad.c b/sad.c @@ -104,6 +104,7 @@ main(void) fdmax = listenfd; initdecoders(); + output->open(16, 44100, 2); while (1) { rfds = master; diff --git a/sndio.c b/sndio.c @@ -12,15 +12,11 @@ static struct sio_hdl *hdl; static int sndiovol(int vol) { - /* TODO: allow volume changes even if there is no active song */ - if (hdl) { - if (!sio_setvol(hdl, (SIO_MAXVOL * vol) / 100)) { - warnx("sio_setvol: failed"); - return -1; - } - return 0; + if (hdl && !sio_setvol(hdl, (SIO_MAXVOL * vol) / 100)) { + warnx("sio_setvol: failed"); + return -1; } - return -1; + return 0; } static int diff --git a/vorbis.c b/vorbis.c @@ -35,10 +35,6 @@ vorbisopen(const char *name) goto err0; } - r = output->open(16, vi->rate, vi->channels); - if (r < 0) - goto err0; - return 0; err0: @@ -70,13 +66,7 @@ vorbisdecode(void *buf, int nbytes) static int vorbisclose(void) { - int r = 0; - - if (ov_clear(&vf) < 0) - r = -1; - if (output->close() < 0) - r = -1; - return r; + return ov_clear(&vf); } static void diff --git a/wav.c b/wav.c @@ -51,9 +51,6 @@ wavopen(const char *name) goto err0; } - if (output->open(bits, sfinfo.samplerate, sfinfo.channels) < 0) - goto err0; - return 0; err0: sf_close(sf); @@ -80,8 +77,6 @@ wavclose(void) } } sf = NULL; - if (output->close() < 0) - r = -1; return r; }