sad

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

commit 11635dc7aac6260c2eda12d73c757502a0a8c293
parent 0fe91cde15bfd54b0f866639a41ab806eb3c48cf
Author: sin <sin@2f30.org>
Date:   Fri Dec 26 18:19:58 +0000

Use ov_fopen()

Diffstat:
Makefile | 4++--
vorbis.c | 24+++++-------------------
2 files changed, 7 insertions(+), 21 deletions(-)
diff --git a/Makefile b/Makefile @@ -11,8 +11,8 @@ OBJ = sndio.o cmd.o mp3.o wav.o vorbis.o playlist.o sad.o tokenizer.o decoder.o BIN = sad # non-OpenBSD -OBJ += compat/reallocarray.o -CFLAGS += -DCOMPAT +#OBJ += compat/reallocarray.o +#CFLAGS += -DCOMPAT all: $(BIN) diff --git a/vorbis.c b/vorbis.c @@ -8,7 +8,6 @@ #include "sad.h" -static FILE *fp; static OggVorbis_File vf; static int cursect; @@ -24,36 +23,27 @@ vorbisopen(const char *name) int r; vorbis_info *vi; - fp = fopen(name, "r"); - if (!fp) { - warn("fopen %s", name); - return -1; - } - cursect = 0; - r = ov_open_callbacks(fp, &vf, NULL, 0, OV_CALLBACKS_NOCLOSE); + r = ov_fopen(name, &vf); if (r < 0) { - warnx("ov_open_callbacks: failed"); + warnx("ov_fopen: failed"); goto err0; } vi = ov_info(&vf, -1); if (!vi) { warnx("ov_info: failed"); - goto err1; + goto err0; } r = output->open(16, vi->rate, vi->channels); if (r < 0) - goto err1; + goto err0; return 0; -err1: - ov_clear(&vf); err0: - fclose(fp); - fp = NULL; + ov_clear(&vf); return -1; } @@ -76,10 +66,6 @@ vorbisclose(void) { int r; - if (fp) { - fclose(fp); - fp = NULL; - } if (ov_clear(&vf) < 0) r = -1; if (output->close() < 0)