- if (!pod->vf) {
- int ib = 1024 * conf->initial_buffer_arg; /* initial buffer */
- if (len <ib && !*fn->fc->input_error) {
- PARA_DEBUG_LOG("initial input buffer %zd/%d, "
- "waiting for more data\n", len, ib);
- return 0;
+ if (!strcmp(cmd, "samplerate")) {
+ if (pod->samplerate == 0)
+ return -ERRNO_TO_PARA_ERROR(ENAVAIL);
+ *result = make_message("%u", pod->samplerate);
+ return 1;
+ }
+ if (!strcmp(cmd, "channels")) {
+ if (pod->channels == 0)
+ return -ERRNO_TO_PARA_ERROR(ENAVAIL);
+ *result = make_message("%u", pod->channels);
+ return 1;
+ }
+ return -ERRNO_TO_PARA_ERROR(ENOTSUP);
+}
+
+static int ogg_init(struct filter_node *fn)
+{
+ struct private_oggdec_data *pod = fn->private_data;
+ struct btr_node *btrn = fn->btrn;
+ int ret, oret;
+ size_t iqs;
+ struct timeval delay = {0, 500 * 1000};
+
+ pod->vf = para_malloc(sizeof(struct OggVorbis_File));
+ PARA_NOTICE_LOG("iqs: %zu, min_iqs: %zu, opening ov callbacks\n",
+ btr_get_input_queue_size(btrn), fn->min_iqs);
+open:
+ oret = ov_open_callbacks(fn, pod->vf,
+ NULL, /* no initial buffer */
+ 0, /* no initial bytes */
+ ovc); /* the ov_open_callbacks */
+ if (oret == OV_ENOTVORBIS || oret == OV_EBADHEADER) {
+ /* this might be due to the input buffer being too small */
+ if (!btr_no_parent(btrn)) {
+ fn->min_iqs += 1000;
+ iqs = btr_get_input_queue_size(btrn);
+ ret = 0;
+ if (iqs < fn->min_iqs)
+ goto out;
+ PARA_CRIT_LOG("iqs: %zu\n", iqs);
+ btr_merge(btrn, fn->min_iqs);
+ pod->converted = 0;
+ goto open;