libogg documentation | libogg release 1.0 - 20000615

# ogg_sync_pageout

declared in "ogg/ogg.h";

This function takes the data stored in the buffer of the ogg_sync_state struct and inserts them into an ogg_page.

In an actual decoding loop, this function should be called first to ensure that the buffer is cleared. The example code below illustrates a clean reading loop which will fill and output pages.

Caution:This function should be called before reading into the buffer to ensure that data does not remain in the ogg_sync_state struct. Failing to do so may result in a memory leak. See the example code below for details.

    int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);

### Parameters

oy
  Pointer to a previously declared ogg_sync_state struct. Normally, the internal storage of this struct should be filled with newly read data and verified using ogg_sync_wrote.
og
  Pointer to page struct filled by this function.

### Return Values

> - -1 if we were not properly synced and had to skip some bytes.
> - 0 if we need more data to verify a page.
> - 1 if we have a page.

### Example Usage

    if (ogg_sync_pageout(&oy, &og) != 1) {
            buffer = ogg_sync_buffer(&oy, 8192);
            bytes = fread(buffer, 1, 8192, stdin);
            ogg_sync_wrote(&oy, bytes);
    }

copyright © 2000 xiph.org | Ogg Vorbis team@xiph.org
libogg documentation | libogg release 1.0 - 20000615