openalbridge/loaders.h
author nemo
Sun, 28 Jun 2009 18:47:55 +0000
changeset 2204 526f8165acce
parent 2200 8192be6e3aef
child 2212 6b5da1a2765a
permissions -rw-r--r--
Smaxx' idea of timers, reworked just a tad. Might need variable for offset, but seems ok for now
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2191
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     1
/*
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     2
 * OpenAL Bridge - a simple portable library for OpenAL interface
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     3
 * Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com>
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     4
 *
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     8
 *
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    12
 * GNU General Public License for more details.
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    13
 *
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    17
 */
2200
8192be6e3aef koda/Smaxx changes to openal for crossplatform building
nemo
parents: 2191
diff changeset
    18
#include <stdio.h>
8192be6e3aef koda/Smaxx changes to openal for crossplatform building
nemo
parents: 2191
diff changeset
    19
#include <stdlib.h>
8192be6e3aef koda/Smaxx changes to openal for crossplatform building
nemo
parents: 2191
diff changeset
    20
#include "al.h"
8192be6e3aef koda/Smaxx changes to openal for crossplatform building
nemo
parents: 2191
diff changeset
    21
#include "alc.h"
8192be6e3aef koda/Smaxx changes to openal for crossplatform building
nemo
parents: 2191
diff changeset
    22
#include "endianness.h"
8192be6e3aef koda/Smaxx changes to openal for crossplatform building
nemo
parents: 2191
diff changeset
    23
#include "wrappers.h"
8192be6e3aef koda/Smaxx changes to openal for crossplatform building
nemo
parents: 2191
diff changeset
    24
8192be6e3aef koda/Smaxx changes to openal for crossplatform building
nemo
parents: 2191
diff changeset
    25
#ifndef _WIN32
8192be6e3aef koda/Smaxx changes to openal for crossplatform building
nemo
parents: 2191
diff changeset
    26
#include <stdint.h>
8192be6e3aef koda/Smaxx changes to openal for crossplatform building
nemo
parents: 2191
diff changeset
    27
#else
8192be6e3aef koda/Smaxx changes to openal for crossplatform building
nemo
parents: 2191
diff changeset
    28
#include "winstdint.h"
8192be6e3aef koda/Smaxx changes to openal for crossplatform building
nemo
parents: 2191
diff changeset
    29
#endif
2191
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    30
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    31
#ifdef __CPLUSPLUS
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    32
extern "C" {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    33
#endif 
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    34
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    35
#pragma once
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    36
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    37
#pragma pack(1)
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    38
	typedef struct _WAV_header_t {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    39
		uint32_t ChunkID;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    40
		uint32_t ChunkSize;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    41
		uint32_t Format;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    42
		uint32_t Subchunk1ID;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    43
		uint32_t Subchunk1Size;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    44
		uint16_t AudioFormat;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    45
		uint16_t NumChannels;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    46
		uint32_t SampleRate;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    47
		uint32_t ByteRate;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    48
		uint16_t BlockAlign;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    49
		uint16_t BitsPerSample;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    50
		uint32_t Subchunk2ID;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    51
		uint32_t Subchunk2Size;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    52
	} WAV_header_t;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    53
#pragma pack()
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    54
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    55
	/*data types for ogg and vorbis*/
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    56
#ifndef ogg_int64_t	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    57
#define ogg_int64_t int64_t
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    58
#endif
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    59
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    60
	typedef struct {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    61
		unsigned char *data;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    62
		int storage;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    63
		int fill;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    64
		int returned;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    65
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    66
		int unsynced;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    67
		int headerbytes;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    68
		int bodybytes;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    69
	} ogg_sync_state;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    70
	typedef struct vorbis_info{
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    71
		int version;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    72
		int channels;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    73
		long rate;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    74
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    75
		/* The below bitrate declarations are *hints*.
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    76
		 Combinations of the three values carry the following implications:
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    77
		 
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    78
		 all three set to the same value:
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    79
		 implies a fixed rate bitstream
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    80
		 only nominal set:
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    81
		 implies a VBR stream that averages the nominal bitrate.  No hard
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    82
		 upper/lower limit
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    83
		 upper and or lower set:
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    84
		 implies a VBR bitstream that obeys the bitrate limits. nominal
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    85
		 may also be set to give a nominal rate.
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    86
		 none set:
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    87
		 the coder does not care to speculate.
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    88
		 */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    89
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    90
		long bitrate_upper;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    91
		long bitrate_nominal;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    92
		long bitrate_lower;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    93
		long bitrate_window;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    94
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    95
		void *codec_setup;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    96
	} vorbis_info;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    97
	typedef struct vorbis_comment{
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    98
		/* unlimited user comment fields.  libvorbis writes 'libvorbis'
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    99
		 whatever vendor is set to in encode */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   100
		char **user_comments;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   101
		int   *comment_lengths;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   102
		int    comments;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   103
		char  *vendor;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   104
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   105
	} vorbis_comment;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   106
	typedef struct {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   107
		unsigned char   *body_data;    /* bytes from packet bodies */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   108
		long    body_storage;          /* storage elements allocated */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   109
		long    body_fill;             /* elements stored; fill mark */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   110
		long    body_returned;         /* elements of fill returned */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   111
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   112
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   113
		int     *lacing_vals;      /* The values that will go to the segment table */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   114
		ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   115
		 this way, but it is simple coupled to the
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   116
		 lacing fifo */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   117
		long    lacing_storage;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   118
		long    lacing_fill;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   119
		long    lacing_packet;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   120
		long    lacing_returned;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   121
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   122
		unsigned char    header[282];      /* working space for header encode */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   123
		int              header_fill;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   124
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   125
		int     e_o_s;          /* set when we have buffered the last packet in the
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   126
		 logical bitstream */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   127
		int     b_o_s;          /* set after we've written the initial page
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   128
		 of a logical bitstream */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   129
		long    serialno;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   130
		long    pageno;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   131
		ogg_int64_t  packetno;      /* sequence number for decode; the framing
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   132
		 knows where there's a hole in the data,
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   133
		 but we need coupling so that the codec
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   134
		 (which is in a seperate abstraction
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   135
		 layer) also knows about the gap */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   136
		ogg_int64_t   granulepos;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   137
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   138
	} ogg_stream_state;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   139
	typedef struct vorbis_dsp_state{
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   140
		int analysisp;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   141
		vorbis_info *vi;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   142
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   143
		float **pcm;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   144
		float **pcmret;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   145
		int      pcm_storage;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   146
		int      pcm_current;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   147
		int      pcm_returned;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   148
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   149
		int  preextrapolate;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   150
		int  eofflag;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   151
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   152
		long lW;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   153
		long W;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   154
		long nW;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   155
		long centerW;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   156
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   157
		ogg_int64_t granulepos;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   158
		ogg_int64_t sequence;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   159
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   160
		ogg_int64_t glue_bits;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   161
		ogg_int64_t time_bits;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   162
		ogg_int64_t floor_bits;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   163
		ogg_int64_t res_bits;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   164
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   165
		void       *backend_state;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   166
	} vorbis_dsp_state;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   167
	typedef struct {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   168
		long endbyte;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   169
		int  endbit;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   170
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   171
		unsigned char *buffer;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   172
		unsigned char *ptr;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   173
		long storage;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   174
	} oggpack_buffer;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   175
	typedef struct vorbis_block{
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   176
		/* necessary stream state for linking to the framing abstraction */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   177
		float  **pcm;       /* this is a pointer into local storage */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   178
		oggpack_buffer opb;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   179
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   180
		long  lW;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   181
		long  W;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   182
		long  nW;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   183
		int   pcmend;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   184
		int   mode;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   185
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   186
		int         eofflag;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   187
		ogg_int64_t granulepos;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   188
		ogg_int64_t sequence;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   189
		vorbis_dsp_state *vd; /* For read-only access of configuration */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   190
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   191
		/* local storage to avoid remallocing; it's up to the mapping to
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   192
		 structure it */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   193
		void               *localstore;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   194
		long                localtop;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   195
		long                localalloc;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   196
		long                totaluse;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   197
		struct alloc_chain *reap;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   198
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   199
		/* bitmetrics for the frame */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   200
		long glue_bits;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   201
		long time_bits;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   202
		long floor_bits;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   203
		long res_bits;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   204
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   205
		void *internal;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   206
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   207
	} vorbis_block;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   208
	typedef struct {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   209
		size_t (*read_func)  (void *ptr, size_t size, size_t nmemb, void *datasource);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   210
		int    (*seek_func)  (void *datasource, ogg_int64_t offset, int whence);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   211
		int    (*close_func) (void *datasource);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   212
		long   (*tell_func)  (void *datasource);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   213
	} ov_callbacks;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   214
	typedef struct OggVorbis_File {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   215
		void            *datasource; /* Pointer to a FILE *, etc. */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   216
		int              seekable;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   217
		ogg_int64_t      offset;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   218
		ogg_int64_t      end;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   219
		ogg_sync_state   oy;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   220
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   221
		/* If the FILE handle isn't seekable (eg, a pipe), only the current
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   222
		 stream appears */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   223
		int              links;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   224
		ogg_int64_t     *offsets;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   225
		ogg_int64_t     *dataoffsets;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   226
		long            *serialnos;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   227
		ogg_int64_t     *pcmlengths; /* overloaded to maintain binary
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   228
		 compatability; x2 size, stores both
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   229
		 beginning and end values */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   230
		vorbis_info     *vi;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   231
		vorbis_comment  *vc;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   232
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   233
		/* Decoding working state local storage */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   234
		ogg_int64_t      pcm_offset;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   235
		int              ready_state;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   236
		long             current_serialno;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   237
		int              current_link;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   238
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   239
		double           bittrack;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   240
		double           samptrack;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   241
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   242
		ogg_stream_state os; /* take physical pages, weld into a logical
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   243
		 stream of packets */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   244
		vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   245
		vorbis_block     vb; /* local working space for packet->PCM decode */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   246
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   247
		ov_callbacks callbacks;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   248
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   249
	} OggVorbis_File;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   250
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   251
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   252
	int load_WavPcm		(const char *filename, ALenum *format, uint8_t **data, ALsizei *bitsize, ALsizei *freq);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   253
	int load_OggVorbis	(const char *filename, ALenum *format, uint8_t **data, ALsizei *bitsize, ALsizei *freq);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   254
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   255
#ifdef __CPLUSPLUS
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   256
}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   257
#endif