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