+static size_t ogg_read_func(void *ptr, size_t size, size_t nmemb, void *datasource) {
+ struct hreader *h = datasource;
+
+ int n = hreader_read(h, ptr, size * nmemb);
+ if(n < 0) n = 0;
+ return n / size;
+}
+
+static int ogg_seek_func(void *datasource, ogg_int64_t offset, int whence) {
+ struct hreader *h = datasource;
+
+ return hreader_seek(h, offset, whence) < 0 ? -1 : 0;
+}
+
+static int ogg_close_func(void attribute((unused)) *datasource) {
+ return 0;
+}
+
+static long ogg_tell_func(void *datasource) {
+ struct hreader *h = datasource;
+
+ return hreader_seek(h, 0, SEEK_CUR);
+}
+
+static const ov_callbacks ogg_callbacks = {
+ ogg_read_func,
+ ogg_seek_func,
+ ogg_close_func,
+ ogg_tell_func,
+};
+