openalbridge/globals.h
author koda
Mon, 29 Jun 2009 23:03:25 +0000
changeset 2212 6b5da1a2765a
child 2213 bd51bbf06033
permissions -rw-r--r--
-openalbridge headers cleaned -static building of lib for non MSVC compilers
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2212
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
     1
/*
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
     2
 * OpenAL Bridge - a simple portable library for OpenAL interface
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
     3
 * Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
     4
 *
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
     8
 *
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    12
 * GNU General Public License for more details.
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    13
 *
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    17
 */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    18
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    19
#ifndef __OLAB_INCLUDES__
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    20
#define __OLAB_INCLUDES__
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    21
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    22
#include <stdio.h>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    23
#include <stdlib.h>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    24
#include "al.h"
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    25
#include "alc.h"
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    26
#include "loaders.h"
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    27
#include "wrappers.h"
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    28
#include "endianness.h"
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    29
#include "openalwrap.h"
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    30
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    31
#ifndef _WIN32
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    32
#include <pthread.h>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    33
#include <stdint.h>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    34
#else
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    35
#define WIN32_LEAN_AND_MEAN
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    36
#include <process.h>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    37
#include "winstdint.h"
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    38
#endif
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    39
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    40
#ifndef _SLEEP_H
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    41
#define _SLEEP_H
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    42
/** 1.0 02/03/10 - Defines cross-platform sleep, usleep, etc. * By Wu Yongwei **/
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    43
#ifdef _WIN32
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    44
# if defined(_NEED_SLEEP_ONLY) && (defined(_MSC_VER) || defined(__MINGW32__))
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    45
#  include <stdlib.h>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    46
#  define sleep(t) _sleep((t) * 1000)
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    47
# else
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    48
#  include <windows.h>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    49
#  define sleep(t)  Sleep((t) * 1000)
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    50
# endif
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    51
# ifndef _NEED_SLEEP_ONLY
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    52
#  define msleep(t) Sleep(t)
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    53
#  define usleep(t) Sleep((t) / 1000)
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    54
# endif
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    55
#else
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    56
# include <unistd.h>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    57
# ifndef _NEED_SLEEP_ONLY
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    58
#  define msleep(t) usleep((t) * 1000)
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    59
# endif
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    60
#endif
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    61
#endif /* _SLEEP_H */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    62
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    63
#ifdef HAVE_BYTESWAP_H
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    64
/* use byteswap macros from the host system, hopefully optimized ones ;-) */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    65
#include <byteswap.h>
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    66
#else
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    67
/* define our own version, simple, stupid, straight-forward... */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    68
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    69
#define bswap_16(x)	((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8))
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    70
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    71
#define bswap_32(x)	((((x) & 0xFF000000) >> 24) | \
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    72
(((x) & 0x00FF0000) >> 8)  | \
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    73
(((x) & 0x0000FF00) << 8)  | \
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    74
(((x) & 0x000000FF) << 24) )
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    75
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    76
#endif /* HAVE_BYTESWAP_H */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    77
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    78
#ifdef __CPLUSPLUS
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    79
extern "C" {
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    80
#endif 
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    81
	
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    82
	/*data type for WAV header*/
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    83
#pragma pack(1)
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    84
	typedef struct _WAV_header_t {
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    85
		uint32_t ChunkID;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    86
		uint32_t ChunkSize;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    87
		uint32_t Format;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    88
		uint32_t Subchunk1ID;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    89
		uint32_t Subchunk1Size;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    90
		uint16_t AudioFormat;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    91
		uint16_t NumChannels;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    92
		uint32_t SampleRate;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    93
		uint32_t ByteRate;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    94
		uint16_t BlockAlign;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    95
		uint16_t BitsPerSample;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    96
		uint32_t Subchunk2ID;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    97
		uint32_t Subchunk2Size;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    98
	} WAV_header_t;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
    99
#pragma pack()
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   100
	
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   101
	/*data type for passing data between threads*/
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   102
	typedef struct _fade_t {
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   103
		int index;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   104
		unsigned int quantity;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   105
	} fade_t;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   106
	
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   107
	/*other defines*/
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   108
#define FADE_IN		11
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   109
#define FADE_OUT	12
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   110
	
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   111
	
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   112
	/*data types for ogg and vorbis that are required to be external*/
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   113
#ifndef ogg_int64_t	
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   114
#define ogg_int64_t int64_t
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   115
#endif
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   116
	
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   117
	typedef struct {
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   118
		unsigned char *data;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   119
		int storage;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   120
		int fill;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   121
		int returned;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   122
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   123
		int unsynced;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   124
		int headerbytes;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   125
		int bodybytes;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   126
	} ogg_sync_state;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   127
	typedef struct vorbis_info{
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   128
		int version;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   129
		int channels;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   130
		long rate;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   131
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   132
		/* The below bitrate declarations are *hints*.
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   133
		 Combinations of the three values carry the following implications:
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   134
		 
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   135
		 all three set to the same value:
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   136
		 implies a fixed rate bitstream
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   137
		 only nominal set:
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   138
		 implies a VBR stream that averages the nominal bitrate.  No hard
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   139
		 upper/lower limit
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   140
		 upper and or lower set:
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   141
		 implies a VBR bitstream that obeys the bitrate limits. nominal
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   142
		 may also be set to give a nominal rate.
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   143
		 none set:
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   144
		 the coder does not care to speculate.
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   145
		 */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   146
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   147
		long bitrate_upper;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   148
		long bitrate_nominal;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   149
		long bitrate_lower;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   150
		long bitrate_window;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   151
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   152
		void *codec_setup;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   153
	} vorbis_info;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   154
	typedef struct vorbis_comment{
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   155
		/* unlimited user comment fields.  libvorbis writes 'libvorbis' whatever vendor is set to in encode */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   156
		char **user_comments;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   157
		int   *comment_lengths;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   158
		int    comments;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   159
		char  *vendor;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   160
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   161
	} vorbis_comment;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   162
	typedef struct {
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   163
		unsigned char   *body_data;    /* bytes from packet bodies */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   164
		long    body_storage;          /* storage elements allocated */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   165
		long    body_fill;             /* elements stored; fill mark */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   166
		long    body_returned;         /* elements of fill returned */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   167
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   168
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   169
		int     *lacing_vals;      /* The values that will go to the segment table */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   170
		ogg_int64_t *granule_vals; 
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   171
		/* granulepos values for headers. Not compact
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   172
		 this way, but it is simple coupled to the lacing fifo */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   173
		long    lacing_storage;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   174
		long    lacing_fill;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   175
		long    lacing_packet;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   176
		long    lacing_returned;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   177
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   178
		unsigned char    header[282];      /* working space for header encode */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   179
		int              header_fill;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   180
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   181
		int     e_o_s;          /* set when we have buffered the last packet in the logical bitstream */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   182
		int     b_o_s;          /* set after we've written the initial page of a logical bitstream */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   183
		long    serialno;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   184
		long    pageno;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   185
		ogg_int64_t  packetno;      
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   186
		/* sequence number for decode; the framing
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   187
		 knows where there's a hole in the data,
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   188
		 but we need coupling so that the codec
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   189
		 (which is in a seperate abstraction
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   190
		 layer) also knows about the gap */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   191
		ogg_int64_t   granulepos;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   192
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   193
	} ogg_stream_state;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   194
	typedef struct vorbis_dsp_state{
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   195
		int analysisp;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   196
		vorbis_info *vi;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   197
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   198
		float **pcm;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   199
		float **pcmret;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   200
		int      pcm_storage;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   201
		int      pcm_current;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   202
		int      pcm_returned;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   203
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   204
		int  preextrapolate;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   205
		int  eofflag;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   206
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   207
		long lW;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   208
		long W;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   209
		long nW;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   210
		long centerW;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   211
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   212
		ogg_int64_t granulepos;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   213
		ogg_int64_t sequence;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   214
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   215
		ogg_int64_t glue_bits;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   216
		ogg_int64_t time_bits;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   217
		ogg_int64_t floor_bits;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   218
		ogg_int64_t res_bits;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   219
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   220
		void       *backend_state;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   221
	} vorbis_dsp_state;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   222
	typedef struct {
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   223
		long endbyte;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   224
		int  endbit;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   225
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   226
		unsigned char *buffer;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   227
		unsigned char *ptr;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   228
		long storage;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   229
	} oggpack_buffer;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   230
	typedef struct vorbis_block{
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   231
		/* necessary stream state for linking to the framing abstraction */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   232
		float  **pcm;       /* this is a pointer into local storage */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   233
		oggpack_buffer opb;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   234
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   235
		long  lW;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   236
		long  W;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   237
		long  nW;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   238
		int   pcmend;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   239
		int   mode;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   240
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   241
		int         eofflag;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   242
		ogg_int64_t granulepos;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   243
		ogg_int64_t sequence;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   244
		vorbis_dsp_state *vd; /* For read-only access of configuration */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   245
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   246
		/* local storage to avoid remallocing; it's up to the mapping to structure it */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   247
		void               *localstore;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   248
		long                localtop;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   249
		long                localalloc;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   250
		long                totaluse;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   251
		struct alloc_chain *reap;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   252
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   253
		/* bitmetrics for the frame */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   254
		long glue_bits;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   255
		long time_bits;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   256
		long floor_bits;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   257
		long res_bits;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   258
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   259
		void *internal;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   260
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   261
	} vorbis_block;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   262
	typedef struct {
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   263
		size_t (*read_func)  (void *ptr, size_t size, size_t nmemb, void *datasource);
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   264
		int    (*seek_func)  (void *datasource, ogg_int64_t offset, int whence);
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   265
		int    (*close_func) (void *datasource);
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   266
		long   (*tell_func)  (void *datasource);
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   267
	} ov_callbacks;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   268
	typedef struct OggVorbis_File {
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   269
		void            *datasource; /* Pointer to a FILE *, etc. */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   270
		int              seekable;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   271
		ogg_int64_t      offset;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   272
		ogg_int64_t      end;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   273
		ogg_sync_state   oy;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   274
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   275
		/* If the FILE handle isn't seekable (eg, a pipe), only the current stream appears */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   276
		int              links;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   277
		ogg_int64_t     *offsets;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   278
		ogg_int64_t     *dataoffsets;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   279
		long            *serialnos;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   280
		ogg_int64_t     *pcmlengths; 
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   281
		/* overloaded to maintain binary
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   282
		 compatability; x2 size, stores both
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   283
		 beginning and end values */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   284
		vorbis_info     *vi;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   285
		vorbis_comment  *vc;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   286
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   287
		/* Decoding working state local storage */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   288
		ogg_int64_t      pcm_offset;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   289
		int              ready_state;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   290
		long             current_serialno;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   291
		int              current_link;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   292
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   293
		double           bittrack;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   294
		double           samptrack;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   295
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   296
		ogg_stream_state os; /* take physical pages, weld into a logical stream of packets */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   297
		vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   298
		vorbis_block     vb; /* local working space for packet->PCM decode */
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   299
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   300
		ov_callbacks callbacks;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   301
		
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   302
	} OggVorbis_File;
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   303
	
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   304
	extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   305
	extern long ov_read(OggVorbis_File *vf,char *buffer,int length,int bigendianp,int word,int sgned,int *bitstream);
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   306
	extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i);
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   307
	extern long ov_read(OggVorbis_File *vf,char *buffer,int length,int bigendianp,int word,int sgned,int *bitstream);
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   308
	extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   309
	extern vorbis_comment *ov_comment(OggVorbis_File *f, int num);
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   310
	
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   311
#ifdef __CPLUSPLUS
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   312
}
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   313
#endif
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   314
6b5da1a2765a -openalbridge headers cleaned
koda
parents:
diff changeset
   315
#endif /*__OLAB_INCLUDES__*/