commit 27ca3577ee8f7d295af940e7b66b99ef4996d079
parent f5d1284c5a39bc5fff33639a9f2c5c1432ac7cf1
Author: sin <sin@2f30.org>
Date:   Fri, 26 Dec 2014 16:56:50 +0000
Pull rate and chans from the file itself
Diffstat:
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/vorbis.c b/vorbis.c
@@ -22,6 +22,7 @@ static int
 vorbisopen(const char *name)
 {
 	int r;
+	vorbis_info *vi;
 
 	fp = fopen(name, "r");
 	if (!fp) {
@@ -36,8 +37,20 @@ vorbisopen(const char *name)
 		return -1;
 	}
 
-	/* TODO: pull out params from file */
-	return output->open(16, 44100, 2);
+	vi = ov_info(&vf, -1);
+	if (!vi) {
+		warnx("ov_info: failed");
+		goto err0;
+	}
+
+	r = output->open(16, vi->rate, vi->channels);
+	if (r < 0)
+		goto err0;
+
+	return 0;
+err0:
+	ov_clear(&vf);
+	return -1;
 }
 
 static int