Handle streams separately in tree_add_track()
[cmus.git] / nomad.h
blob44253426c763c5c1e68bfd6e6c327a7f049aa3d7
1 /*
2 * Copyright 2004 Timo Hirvonen
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17 * 02111-1307, USA.
20 #ifndef _NOMAD_H
21 #define _NOMAD_H
23 #include <mad.h>
24 #include <sys/types.h>
26 #define INPUT_BUFFER_SIZE (5 * 8192)
28 #define SEEK_IDX_INTERVAL 15
30 /* default callbacks use read, lseek, close */
31 struct nomad_callbacks {
32 ssize_t (*read)(void *datasource, void *buffer, size_t count);
33 off_t (*lseek)(void *datasource, off_t offset, int whence);
34 int (*close)(void *datasource);
37 /* always 16-bit signed little-endian */
38 struct nomad_info {
39 double duration;
40 int sample_rate;
41 int channels;
42 int nr_frames;
43 int layer;
44 /* -1 if fast = 1 */
45 int vbr;
46 /* -1 if fast = 1 */
47 int avg_bitrate;
48 /* -1 if file not seekable */
49 int filesize;
50 unsigned int joint_stereo : 1;
51 unsigned int dual_channel : 1;
54 enum {
55 NOMAD_ERROR_SUCCESS,
56 NOMAD_ERROR_ERRNO,
57 NOMAD_ERROR_FILE_FORMAT
60 struct nomad;
62 /* -NOMAD_ERROR_ERRNO -NOMAD_ERROR_FILE_FORMAT */
63 int nomad_open(struct nomad **nomadp, int fd, int fast);
64 int nomad_open_callbacks(struct nomad **nomadp, void *datasource, int fast,
65 struct nomad_callbacks *cbs);
67 void nomad_close(struct nomad *nomad);
68 void nomad_info(struct nomad *nomad, struct nomad_info *info);
70 /* -NOMAD_ERROR_ERRNO */
71 int nomad_read(struct nomad *nomad, char *buffer, int count);
73 /* -NOMAD_ERROR_ERRNO */
74 int nomad_time_seek(struct nomad *nomad, double pos);
76 double nomad_time_tell(struct nomad *nomad);
77 double nomad_time_total(struct nomad *nomad);
79 #endif