annotate src/tta/ttalib.h @ 3178:4634dab72608

alsa-ng: Add get_volume() implementation.
author William Pitcock <nenolod@atheme.org>
date Wed, 10 Jun 2009 00:06:15 -0500
parents 3134a0987162
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
290
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
1 /*
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
2 * ttalib.h
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
3 *
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
4 * Description: TTAv1 player library prototypes
1012
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
5 * Developed by: Alexander Djourik <ald@true-audio.com>
290
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
6 *
1012
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
7 * Copyright (c) 1999-2007 Alexander Djourik. All rights reserved.
290
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
8 *
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
9 */
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
10
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
11 /*
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
12 * This library is free software; you can redistribute it and/or
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
13 * modify it under the terms of the GNU Lesser General Public
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
14 * License as published by the Free Software Foundation; either
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
15 * version 2.1 of the License, or (at your option) any later version.
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
16 *
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
17 * This library is distributed in the hope that it will be useful,
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
20 * Lesser General Public License for more details.
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
21 *
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
22 * You should have received a copy of the GNU Lesser General Public
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
23 * License along with this library; if not, write to the Free Software
2835
f1b6f1b2cdb3 fixed FSF address
Andrew O. Shadoura <bugzilla@tut.by>
parents: 1980
diff changeset
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
290
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
25 *
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
26 * Please see the file COPYING in this directory for full copyright
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
27 * information.
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
28 */
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
29
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
30 #ifndef TTALIB_H_
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
31 #define TTALIB_H_
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
32
2971
3134a0987162 - changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2835
diff changeset
33 #include <audlegacy/plugin.h>
290
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
34
1012
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
35 // audacious support
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
36 #define FILE VFSFile
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1237
diff changeset
37 #define fopen aud_vfs_fopen
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1237
diff changeset
38 #define fclose aud_vfs_fclose
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1237
diff changeset
39 #define fwrite aud_vfs_fwrite
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1237
diff changeset
40 #define fread aud_vfs_fread
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1237
diff changeset
41 #define frewind aud_vfs_frewind
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1237
diff changeset
42 #define ftell aud_vfs_ftell
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1237
diff changeset
43 #define fseek aud_vfs_fseek
1012
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
44
290
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
45 #define MAX_BPS 24 // Max supported Bit resolution
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
46 #define MAX_NCH 8 // Max supported number of channels
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
47
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
48 // return codes
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
49 #define NO_ERROR 0
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
50 #define OPEN_ERROR 1 // Can't open file
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
51 #define FORMAT_ERROR 2 // Unknown TTA format version
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
52 #define PLAYER_ERROR 3 // Not supported file format
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
53 #define FILE_ERROR 4 // File is corrupted
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
54 #define READ_ERROR 5 // Can't read from file
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
55 #define MEMORY_ERROR 6 // Insufficient memory available
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
56
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
57 #define FRAME_TIME 1.04489795918367346939
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
58 #define SEEK_STEP (int)(FRAME_TIME * 1000)
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
59
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
60 #define ISO_BUFFER_LENGTH (1024*32)
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
61 #define ISO_NBUFFERS (8)
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
62 #define ISO_BUFFERS_SIZE (ISO_BUFFER_LENGTH*ISO_NBUFFERS)
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
63 #define PCM_BUFFER_LENGTH (4608)
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
64
1012
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
65 #define MAX_LINE 4096
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
66 #define MAX_YEAR 5
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
67 #define MAX_TRACK 3
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
68 #define MAX_GENRE 256
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
69
290
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
70 typedef struct {
1012
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
71 unsigned char name[MAX_LINE];
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
72 unsigned char title[MAX_LINE];
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
73 unsigned char artist[MAX_LINE];
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
74 unsigned char album[MAX_LINE];
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
75 unsigned char comment[MAX_LINE];
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
76 unsigned char year[MAX_YEAR];
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
77 unsigned char track[MAX_TRACK];
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
78 unsigned char genre[MAX_GENRE];
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
79 unsigned char id3has;
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
80 } id3_info;
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
81
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
82 typedef struct {
1237
0d5b0f861bf0 - quick fix for link breakage to libaudid3tag.so when --prefix is specified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1190
diff changeset
83 VFSFile *HANDLE; // file handle
1012
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
84 unsigned short NCH; // number of channels
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
85 unsigned short BPS; // bits per sample
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
86 unsigned short BSIZE; // byte size
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
87 unsigned short FORMAT; // audio format
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
88 unsigned int SAMPLERATE; // samplerate (sps)
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
89 unsigned int DATALENGTH; // data length in samples
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
90 unsigned int FRAMELEN; // frame length
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
91 unsigned int LENGTH; // playback time (sec)
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
92 unsigned int STATE; // return code
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
93 unsigned int DATAPOS; // size of ID3v2 header
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
94 id3_info ID3;
290
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
95 } tta_info;
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
96
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
97 /*********************** Library functions *************************/
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
98
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
99 #ifdef LIBTEST
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
100 #ifndef DPRINTF
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
101 #define DPRINTF(x) fprintf(stderr, (x))
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
102 #endif /* DPRINTF */
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
103
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
104 static void tta_error (int error) {
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
105 DPRINTF("TTA Decoder Error - ");
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
106 switch (error) {
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
107 case OPEN_ERROR: DPRINTF("Can't open file\n"); break;
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
108 case FORMAT_ERROR: DPRINTF("Not supported file format\n"); break;
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
109 case FILE_ERROR: DPRINTF("File is corrupted\n"); break;
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
110 case READ_ERROR: DPRINTF("Can't read from file\n"); break;
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
111 case MEMORY_ERROR: DPRINTF("Insufficient memory available\n"); break;
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
112 }
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
113 }
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
114 #endif /* LIBTEST */
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
115
1012
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
116 int open_tta_file ( // FUNCTION: opens TTA file
290
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
117 const char *filename, // file to open
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
118 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
119 unsigned int offset); // ID3v2 header size
290
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
120 /*
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
121 * RETURN VALUE
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
122 * This function returns 0 if success. Otherwise, -1 is returned
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
123 * and the variable STATE of the currently using info structure
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
124 * is set to indicate the error.
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
125 *
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
126 */
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
127
1012
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
128 void close_tta_file ( // FUNCTION: closes currently playing file
290
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
129 tta_info *info); // file info structure
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
130
1012
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
131 int set_position ( // FUNCTION: sets playback position
551
c0f69d57483b [svn] - change some references for long to int, reported by and patch by
nenolod
parents: 290
diff changeset
132 unsigned int pos); // seek position = seek_time_ms / SEEK_STEP
290
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
133 /*
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
134 * RETURN VALUE
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
135 * This function returns 0 if success. Otherwise, -1 is returned
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
136 * and the variable STATE of the currently using info structure
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
137 * is set to indicate the error.
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
138 *
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
139 */
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
140
1012
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
141 int player_init ( // FUNCTION: initializes TTA player
290
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
142 tta_info *info); // file info structure
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
143 /*
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
144 * RETURN VALUE
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
145 * This function returns 0 if success. Otherwise, -1 is returned
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
146 * and the variable STATE of the currently using info structure
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
147 * is set to indicate the error.
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
148 *
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
149 */
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
150
1012
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
151 void player_stop (void); // FUNCTION: destroys memory pools
290
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
152
1012
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
153 int get_samples ( // FUNCTION: decode PCM_BUFFER_LENGTH samples
290
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
154 unsigned char *buffer); // into the current PCM buffer position
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
155 /*
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
156 * RETURN VALUE
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
157 * This function returns the number of samples successfully decoded.
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
158 * Otherwise, -1 is returned and the variable STATE of the currently
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
159 * using info structure is set to indicate the error.
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
160 *
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
161 */
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
162
1012
d0d99b22e393 [svn] import major update by Aleksander Djuric (the original author).
yaz
parents: 551
diff changeset
163 int get_bitrate (void); // RETURN VALUE: TTA dynamic bitrate
290
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
164
1190
ed2d7787779e more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1012
diff changeset
165 int get_id3_tags (const char *filename, tta_info *ttainfo);
ed2d7787779e more warning elimination.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1012
diff changeset
166
290
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
167 #endif /* TTALIB_H_ */
fbd06b4aa776 [svn] - add TrueAudio plugin
yaz
parents:
diff changeset
168