- while (1) {
- result = ogg_sync_pageout (&state->oy, &ogout);
-
- if (!result)
- break;
-
- if (result >= 0) {
- /* Don't bother going through the rest, we can just
- * write the page out now
- */
- tmp = fwrite (ogout.header, 1, ogout.header_len, out);
- if (tmp != (size_t) ogout.header_len)
- goto cleanup;
-
- tmp = fwrite (ogout.body, 1, ogout.body_len, out);
- if (tmp != (size_t) ogout.body_len)
- goto cleanup;
- }
- }
-
- buffer = ogg_sync_buffer (&state->oy, CHUNKSIZE);
- bytes = fread (buffer, 1, CHUNKSIZE, state->in);
- ogg_sync_wrote (&state->oy, bytes);
+ while ((result = ogg_sync_pageout (&s->oy, &page_out)))
+ if (result == 1 && !write_page (out, &page_out))
+ goto cleanup;