Mercurial > audlegacy-plugins
annotate src/tta/ttalib.h @ 805:1ba5f86aeac9 trunk
[svn] - should check data != NULL before clear data->playing.
author | yaz |
---|---|
date | Mon, 12 Mar 2007 09:12:26 -0700 |
parents | c0f69d57483b |
children | d0d99b22e393 |
rev | line source |
---|---|
290 | 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 | |
551
c0f69d57483b
[svn] - change some references for long to int, reported by and patch by
nenolod
parents:
290
diff
changeset
|
63 unsigned int SAMPLERATE; // samplerate (sps) |
c0f69d57483b
[svn] - change some references for long to int, reported by and patch by
nenolod
parents:
290
diff
changeset
|
64 unsigned int DATALENGTH; // data length in samples |
c0f69d57483b
[svn] - change some references for long to int, reported by and patch by
nenolod
parents:
290
diff
changeset
|
65 unsigned int FRAMELEN; // frame length |
c0f69d57483b
[svn] - change some references for long to int, reported by and patch by
nenolod
parents:
290
diff
changeset
|
66 unsigned int LENGTH; // playback time (sec) |
c0f69d57483b
[svn] - change some references for long to int, reported by and patch by
nenolod
parents:
290
diff
changeset
|
67 unsigned int STATE; // return code |
c0f69d57483b
[svn] - change some references for long to int, reported by and patch by
nenolod
parents:
290
diff
changeset
|
68 unsigned int DATAPOS; // size of ID3v2 header |
290 | 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 | |
551
c0f69d57483b
[svn] - change some references for long to int, reported by and patch by
nenolod
parents:
290
diff
changeset
|
92 int open_tta_file ( // FUNCTION: opens TTA file |
290 | 93 const char *filename, // file to open |
94 tta_info *info, // file info structure | |
551
c0f69d57483b
[svn] - change some references for long to int, reported by and patch by
nenolod
parents:
290
diff
changeset
|
95 unsigned int offset); // ID3v2 header size |
290 | 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 | |
551
c0f69d57483b
[svn] - change some references for long to int, reported by and patch by
nenolod
parents:
290
diff
changeset
|
107 int set_position ( // FUNCTION: sets playback position |
c0f69d57483b
[svn] - change some references for long to int, reported by and patch by
nenolod
parents:
290
diff
changeset
|
108 unsigned int pos); // seek position = seek_time_ms / SEEK_STEP |
290 | 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 | |
551
c0f69d57483b
[svn] - change some references for long to int, reported by and patch by
nenolod
parents:
290
diff
changeset
|
117 int player_init ( // FUNCTION: initializes TTA player |
290 | 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 | |
551
c0f69d57483b
[svn] - change some references for long to int, reported by and patch by
nenolod
parents:
290
diff
changeset
|
129 int get_samples ( // FUNCTION: decode PCM_BUFFER_LENGTH samples |
290 | 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 | |
551
c0f69d57483b
[svn] - change some references for long to int, reported by and patch by
nenolod
parents:
290
diff
changeset
|
139 int get_bitrate (void); // RETURN VALUE: TTA dynamic bitrate |
290 | 140 |
141 #endif /* TTALIB_H_ */ | |
142 |