Mercurial > audlegacy-plugins
comparison src/tta/ttalib.h @ 290:fbd06b4aa776 trunk
[svn] - add TrueAudio plugin
author | yaz |
---|---|
date | Wed, 22 Nov 2006 09:55:20 -0800 |
parents | |
children | c0f69d57483b |
comparison
equal
deleted
inserted
replaced
289:a60da24269dc | 290:fbd06b4aa776 |
---|---|
1 /* | |
2 * ttalib.h | |
3 * | |
4 * Description: TTAv1 player library prototypes | |
5 * Developed by: Alexander Djourik <sasha@iszf.irk.ru> | |
6 * Pavel Zhilin <pzh@iszf.irk.ru> | |
7 * | |
8 * Copyright (c) 1999-2004 Alexander Djourik. All rights reserved. | |
9 * | |
10 */ | |
11 | |
12 /* | |
13 * This library is free software; you can redistribute it and/or | |
14 * modify it under the terms of the GNU Lesser General Public | |
15 * License as published by the Free Software Foundation; either | |
16 * version 2.1 of the License, or (at your option) any later version. | |
17 * | |
18 * This library is distributed in the hope that it will be useful, | |
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
21 * Lesser General Public License for more details. | |
22 * | |
23 * You should have received a copy of the GNU Lesser General Public | |
24 * License along with this library; if not, write to the Free Software | |
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
26 * | |
27 * Please see the file COPYING in this directory for full copyright | |
28 * information. | |
29 */ | |
30 | |
31 #ifndef TTALIB_H_ | |
32 #define TTALIB_H_ | |
33 | |
34 #include "ttaid3tag.h" | |
35 | |
36 //#define _BIG_ENDIAN | |
37 #define MAX_BPS 24 // Max supported Bit resolution | |
38 #define MAX_NCH 8 // Max supported number of channels | |
39 | |
40 // return codes | |
41 #define NO_ERROR 0 | |
42 #define OPEN_ERROR 1 // Can't open file | |
43 #define FORMAT_ERROR 2 // Unknown TTA format version | |
44 #define PLAYER_ERROR 3 // Not supported file format | |
45 #define FILE_ERROR 4 // File is corrupted | |
46 #define READ_ERROR 5 // Can't read from file | |
47 #define MEMORY_ERROR 6 // Insufficient memory available | |
48 | |
49 #define FRAME_TIME 1.04489795918367346939 | |
50 #define SEEK_STEP (int)(FRAME_TIME * 1000) | |
51 | |
52 #define ISO_BUFFER_LENGTH (1024*32) | |
53 #define ISO_NBUFFERS (8) | |
54 #define ISO_BUFFERS_SIZE (ISO_BUFFER_LENGTH*ISO_NBUFFERS) | |
55 #define PCM_BUFFER_LENGTH (4608) | |
56 | |
57 typedef struct { | |
58 FILE *HANDLE; // file handle | |
59 unsigned short NCH; // number of channels | |
60 unsigned short BPS; // bits per sample | |
61 unsigned short BSIZE; // byte size | |
62 unsigned short FORMAT; // audio format | |
63 unsigned long SAMPLERATE; // samplerate (sps) | |
64 unsigned long DATALENGTH; // data length in samples | |
65 unsigned long FRAMELEN; // frame length | |
66 unsigned long LENGTH; // playback time (sec) | |
67 unsigned long STATE; // return code | |
68 unsigned long DATAPOS; // size of ID3v2 header | |
69 id3v1_data id3v1; | |
70 id3v2_data id3v2; | |
71 } tta_info; | |
72 | |
73 /*********************** Library functions *************************/ | |
74 | |
75 #ifdef LIBTEST | |
76 #ifndef DPRINTF | |
77 #define DPRINTF(x) fprintf(stderr, (x)) | |
78 #endif /* DPRINTF */ | |
79 | |
80 static void tta_error (int error) { | |
81 DPRINTF("TTA Decoder Error - "); | |
82 switch (error) { | |
83 case OPEN_ERROR: DPRINTF("Can't open file\n"); break; | |
84 case FORMAT_ERROR: DPRINTF("Not supported file format\n"); break; | |
85 case FILE_ERROR: DPRINTF("File is corrupted\n"); break; | |
86 case READ_ERROR: DPRINTF("Can't read from file\n"); break; | |
87 case MEMORY_ERROR: DPRINTF("Insufficient memory available\n"); break; | |
88 } | |
89 } | |
90 #endif /* LIBTEST */ | |
91 | |
92 long open_tta_file ( // FUNCTION: opens TTA file | |
93 const char *filename, // file to open | |
94 tta_info *info, // file info structure | |
95 unsigned long offset); // ID3v2 header size | |
96 /* | |
97 * RETURN VALUE | |
98 * This function returns 0 if success. Otherwise, -1 is returned | |
99 * and the variable STATE of the currently using info structure | |
100 * is set to indicate the error. | |
101 * | |
102 */ | |
103 | |
104 void close_tta_file ( // FUNCTION: closes currently playing file | |
105 tta_info *info); // file info structure | |
106 | |
107 long set_position ( // FUNCTION: sets playback position | |
108 unsigned long pos); // seek position = seek_time_ms / SEEK_STEP | |
109 /* | |
110 * RETURN VALUE | |
111 * This function returns 0 if success. Otherwise, -1 is returned | |
112 * and the variable STATE of the currently using info structure | |
113 * is set to indicate the error. | |
114 * | |
115 */ | |
116 | |
117 long player_init ( // FUNCTION: initializes TTA player | |
118 tta_info *info); // file info structure | |
119 /* | |
120 * RETURN VALUE | |
121 * This function returns 0 if success. Otherwise, -1 is returned | |
122 * and the variable STATE of the currently using info structure | |
123 * is set to indicate the error. | |
124 * | |
125 */ | |
126 | |
127 void player_stop (void); // FUNCTION: destroys memory pools | |
128 | |
129 long get_samples ( // FUNCTION: decode PCM_BUFFER_LENGTH samples | |
130 unsigned char *buffer); // into the current PCM buffer position | |
131 /* | |
132 * RETURN VALUE | |
133 * This function returns the number of samples successfully decoded. | |
134 * Otherwise, -1 is returned and the variable STATE of the currently | |
135 * using info structure is set to indicate the error. | |
136 * | |
137 */ | |
138 | |
139 long get_bitrate (void); // RETURN VALUE: TTA dynamic bitrate | |
140 | |
141 #endif /* TTALIB_H_ */ | |
142 |