- int ret;
- struct oggdec_filter_args_info *ogg_conf;
-
- ogg_conf = para_calloc(sizeof(*ogg_conf));
- ret = -E_OGGDEC_SYNTAX;
- if (oggdec_cmdline_parser(argc, argv, ogg_conf))
- goto err;
- ret = -ERRNO_TO_PARA_ERROR(EINVAL);
- if (ogg_conf->bufsize_arg < 0)
- goto err;
- if (ogg_conf->bufsize_arg >= INT_MAX / 1024)
- goto err;
- if (ogg_conf->initial_buffer_arg < 0)
- goto err;
- if (ogg_conf->initial_buffer_arg >= INT_MAX / 1024)
- goto err;
- *config = ogg_conf;
- return 1;
-err:
- free(ogg_conf);
+ struct private_oggdec_data *pod = fn->private_data;
+ struct btr_node *btrn = fn->btrn;
+ int ret, oret;
+ size_t iqs;
+
+ 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;
+ }
+ ret = (oret == OV_ENOTVORBIS)?
+ -E_OGGDEC_NOTVORBIS : -E_OGGDEC_BADHEADER;
+ goto out;
+ }
+ ret = -E_OGGDEC_READ;
+ if (oret == OV_EREAD)
+ goto out;
+ ret = -E_OGGDEC_VERSION;
+ if (oret == OV_EVERSION)
+ goto out;
+ ret = -E_OGGDEC_FAULT;
+ if (oret < 0)
+ goto out;
+ pod->channels = ov_info(pod->vf, 0)->channels;
+ pod->samplerate = ov_info(pod->vf, 0)->rate;
+ PARA_NOTICE_LOG("%d channels, %d Hz\n", pod->channels,
+ pod->samplerate);
+ ret = 1;
+out:
+ if (ret <= 0) {
+ free(pod->vf);
+ pod->vf = NULL;
+ } else {
+ btr_consume(btrn, pod->converted);
+ pod->converted = 0;
+ fn->min_iqs = 0;
+ }