+ } else if (ret == 0 && !ctx->have_more) /* nothing to do */
+ goto out;
+ if (btr_get_output_queue_size(btrn) > OPUSDEC_MAX_OUTPUT_SIZE)
+ return 0;
+ for (;;) {
+ int serial;
+ if (ctx->stream_init) {
+ ret = ogg_stream_packetout(&ctx->os, &op);
+ if (ret == 1)
+ break;
+ }
+ while (ogg_sync_pageout(&ctx->oy, &ctx->ogg_page) != 1) {
+ char *btr_buf, *data;
+ size_t nbytes = btr_next_buffer(btrn, &btr_buf);
+ nbytes = PARA_MIN(nbytes, (size_t)24 * 1024);
+ //PARA_CRIT_LOG("nbytes: %d\n", nbytes);
+ ctx->have_more = false;
+ if (nbytes == 0)
+ return 0;
+ data = ogg_sync_buffer(&ctx->oy, nbytes);
+ memcpy(data, btr_buf, nbytes);
+ btr_consume(btrn, nbytes);
+ ogg_sync_wrote(&ctx->oy, nbytes);
+ }
+ ctx->have_more = true;
+ serial = ogg_page_serialno(&ctx->ogg_page);
+ if (ctx->stream_init) {
+ if (serial != ctx->os.serialno)
+ ogg_stream_reset_serialno(&ctx->os, serial);
+ } else {
+ ogg_stream_init(&ctx->os, serial);