public static void oggpack_readinit(oggpack_buffer b, ArrayPointer buf, long bytes) { //memset(buf, 0, sizeof(*b)); b.buffer = b.ptr = buf; b.storage = bytes; }
/* The Vorbis header is in three packets; the initial small packet in * the first page that identifies basic parameters, a second packet * with bitstream comments and a third packet that holds the * codebook. */ public static int vorbis_synthesis_headerin(vorbis_info vi, vorbis_comment vc, ogg_packet op) { oggpack_buffer opb = new oggpack_buffer(); if (op != null) { oggpack_readinit(opb, op.packet, op.bytes); /* Which of the three types of header is this? */ /* Also verify header-ness, vorbis */ { var buffer = new ArrayPointer(); long packtype = oggpack_read(opb, 8); //memset(buffer, 0, 6); _v_readstring(opb, buffer, 6); if (memcmp(buffer, "vorbis", 6) != 0) { /* not a vorbis header */ return(OV_ENOTVORBIS); } switch (packtype) { case 0x01: /* least significant *bit* is read first */ if (op.b_o_s == 0) { /* Not the initial packet */ return(OV_EBADHEADER); } if (vi.rate != 0) { /* previously initialized info header */ return(OV_EBADHEADER); } return(_vorbis_unpack_info(vi, opb)); case 0x03: /* least significant *bit* is read first */ if (vi.rate == 0) { /* um... we didn't get the initial header */ return(OV_EBADHEADER); } if (vc.vendor != null) { /* previously initialized comment header */ return(OV_EBADHEADER); } return(_vorbis_unpack_comment(vc, opb)); case 0x05: /* least significant *bit* is read first */ if (vi.rate == 0 || vc.vendor == null) { /* um... we didn;t get the initial header or comments yet */ return(OV_EBADHEADER); } if (vi.codec_setup == null) { /* improperly initialized vorbis_info */ return(OV_EFAULT); } if (((codec_setup_info)vi.codec_setup).books > 0) { /* previously initialized setup header */ return(OV_EBADHEADER); } return(_vorbis_unpack_books(vi, opb)); default: /* Not a valid vorbis header type */ return(OV_EBADHEADER); //break; } } } return(OV_EBADHEADER); }