summaryrefslogtreecommitdiffstats
path: root/mpeglib/lib/tplay/tplayfunctions.h
blob: 0c15984798e4ad64db25a356182835a82a22c330 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* 
 * tplay - buffered audio player header file
 *
 * (c) 1997 ilkka karvinen <ik@iki.fi>
 *
 * Copyright under the GNU GENERAL PUBLIC LICENSE
 *   (see the file COPYING in this directory)
 *
 */

#ifndef __TPLAYCONTROL_H
#define __TPLAYCONTROL_H

extern "C" {
#include <stdio.h>
#include <string.h>
}

/* tplay version */
#define MAJOR_VERSION 0
#define MINOR_VERSION 5
#define PATCHLEVEL    5

/* Default audio parameters */
#define DEFAULT_BITS     16
#define DEFAULT_SPEED    44100
#define DEFAULT_CHANNELS 2

/* Audio memory pool. 512k is the default. */
#define BUFFER_SIZE    0x80000

/* The minimum and maximum buffer block sizes. */
#if 0
#define MIN_BLOCK_SIZE 0x4000	/* 16k */
#else
#define MIN_BLOCK_SIZE 4096
#endif
#define MAX_BLOCK_SIZE 0x10000	/* 64k */

#ifndef TRUE
#define TRUE  1
#define FALSE 0
#endif

/* The maximum retry count for buffer fill tries. */
#define RETRY_COUNT 5

/* Magics. Little-endian. */
#define RIFF_MAGIC    0x46464952	/* ASCII: 'RIFF' */
#define WAVE_MAGIC    0x45564157	/* ASCII: 'WAVE' */
#define DATA_MAGIC    0x61746164	/* ASCII: 'data' */
#define INFO_MAGIC    0x4f464e49	/* ASCII: 'INFO' */
#define SUN_MAGIC     0x2e736e64	/* ASCII: '.snd' */

/* Magics. Big-endian. */
#define SUN_INV_MAGIC 0x646e732e	/* ASCII: '.snd' */

/* Sun headersize */
#define SUN_HDRSIZE 24

/* File types */
#define UNKNOWN_FILE  0
#define RIFF_FILE     1
#define SUN_FILE      2

typedef unsigned long DWORD;
typedef unsigned short WORD;

/* Circular buffer info structure of audio data blocks. */
/* declared in tplay.c                                  */
struct info_struct {
   char *buffer;		/* the audio data */
   char *firstblock;		/* pointer to the first block */
   int readblock, writeblock;	/* reading and writing block number */
   long readcount, writecount;
   int alldone;
   int in_seconds;
   double seconds;
   int blocksize;		/* size of one block */
   int buffer_size;		/* size of the buffer */
   int number_of_blocks;
   int last_block;		/* -1 if not the last block */
   int bytes_on_last_block;
   int overflow;
   int underflow;
   int swap;
   int forceraw;
   int force;
   int filetype;
   int headerskip;
   int audioset;
   int show_usage;
   DWORD speed;
   int channels;
   int bits;
   char *progname;
   char *device;		/* Audio device name */
   int loop;
   int verbose;
   int optind;
};

/* au.c */
 int read_au(struct info_struct* info, char * buffer);

/* wav.c */
 int read_wav(struct info_struct* info, char * buffer);

/* common.c */
 DWORD read_big_endian_long(char * buffer);
 void write_big_endian_long(char * buffer, DWORD value);
 DWORD read_little_endian_long(char * buffer);
 WORD read_little_endian_word(char * buffer);
 void errprintf(char *fmt,...);
 void warning(char *str);
 void warning2(char *str1, char *str2);
 void die(const char *str);
 void errdie(const char *str);
 void open_audio();
 void set_audio_parameters();
 void sync_audio(void);
 void reset_audio(void);
 void post_audio(void);
 void destroy_buffer(void);
 void nice_fputc(int c, FILE * fp);


#endif