1 /* 2 * madplay - MPEG audio decoder and player 3 * Copyright (C) 2000-2004 Robert Leslie 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * 19 * $Id: player.h,v 1.24 2004/02/23 21:34:53 rob Exp $ 20 */ 21 22 # ifndef PLAYER_H 23 # define PLAYER_H 24 25 # include <stdio.h> 26 # include <mad.h> 27 28 # include "audio.h" 29 # include "resample.h" 30 # include "filter.h" 31 # include "tag.h" 32 33 enum { 34 PLAYER_OPTION_SHUFFLE = 0x0001, 35 PLAYER_OPTION_DOWNSAMPLE = 0x0002, 36 PLAYER_OPTION_IGNORECRC = 0x0004, 37 PLAYER_OPTION_IGNOREVOLADJ = 0x0008, 38 39 PLAYER_OPTION_SKIP = 0x0010, 40 PLAYER_OPTION_TIMED = 0x0020, 41 PLAYER_OPTION_TTYCONTROL = 0x0040, 42 PLAYER_OPTION_STREAMID3 = 0x0080, 43 44 PLAYER_OPTION_FADEIN = 0x0100, 45 PLAYER_OPTION_FADEOUT = 0x0200, 46 PLAYER_OPTION_GAP = 0x0400, 47 PLAYER_OPTION_CROSSFADE = 0x0800, 48 49 # if defined(EXPERIMENTAL) 50 PLAYER_OPTION_EXTERNALMIX = 0x1000, 51 PLAYER_OPTION_EXPERIMENTAL = 0x2000, 52 # endif 53 54 PLAYER_OPTION_SHOWTAGSONLY = 0x4000 55 }; 56 57 enum player_control { 58 PLAYER_CONTROL_DEFAULT, 59 PLAYER_CONTROL_NEXT, 60 PLAYER_CONTROL_PREVIOUS, 61 PLAYER_CONTROL_REPLAY, 62 PLAYER_CONTROL_STOP 63 }; 64 65 enum player_channel { 66 PLAYER_CHANNEL_DEFAULT = 0, 67 PLAYER_CHANNEL_LEFT = 1, 68 PLAYER_CHANNEL_RIGHT = 2, 69 PLAYER_CHANNEL_MONO = 3, 70 PLAYER_CHANNEL_STEREO = 4 71 }; 72 73 enum stats_show { 74 STATS_SHOW_OVERALL, 75 STATS_SHOW_CURRENT, 76 STATS_SHOW_REMAINING 77 }; 78 79 enum { 80 DB_MIN = -175, /* minimum representable mad_fixed_t factor */ 81 DB_MAX = +18 /* maximum representable mad_fixed_t factor */ 82 }; 83 84 enum { 85 PLAYER_RGAIN_ENABLED = 0x0001, 86 PLAYER_RGAIN_SET = 0x0002, 87 PLAYER_RGAIN_AUDIOPHILE = 0x0010, 88 PLAYER_RGAIN_HARDLIMIT = 0x0020 89 }; 90 91 struct player { 92 int verbosity; 93 94 int options; 95 int repeat; 96 97 enum player_control control; 98 99 struct playlist { 100 char const **entries; 101 int length; 102 int current; 103 } playlist; 104 105 mad_timer_t global_start; 106 mad_timer_t global_stop; 107 108 mad_timer_t fade_in; 109 mad_timer_t fade_out; 110 mad_timer_t gap; 111 112 struct input { 113 char const *path; 114 115 int fd; 116 # if defined(HAVE_MMAP) 117 unsigned char *fdm; 118 # endif 119 120 unsigned char *data; 121 unsigned long length; 122 123 int eof; 124 125 struct tag tag; 126 } input; 127 128 struct output { 129 enum audio_mode mode; 130 131 double voladj_db; 132 double attamp_db; 133 mad_fixed_t gain; 134 135 int replay_gain; 136 137 struct filter *filters; 138 139 unsigned int channels_in; 140 unsigned int channels_out; 141 enum player_channel select; 142 143 unsigned int speed_in; 144 unsigned int speed_out; 145 unsigned int speed_request; 146 147 unsigned int precision_in; 148 unsigned int precision_out; 149 150 char const *path; 151 audio_ctlfunc_t *command; 152 153 struct resample_state resample[2]; 154 mad_fixed_t (*resampled)[2][MAX_NSAMPLES]; 155 } output; 156 157 struct ancillary { 158 char const *path; 159 FILE *file; 160 161 unsigned short buffer; 162 unsigned short length; 163 } ancillary; 164 165 struct stats { 166 enum stats_show show; 167 char const *label; 168 169 unsigned long total_bytes; 170 mad_timer_t total_time; 171 172 mad_timer_t global_timer; 173 mad_timer_t absolute_timer; 174 mad_timer_t play_timer; 175 176 unsigned long global_framecount; 177 unsigned long absolute_framecount; 178 unsigned long play_framecount; 179 180 unsigned long error_frame; 181 unsigned long mute_frame; 182 183 int vbr; 184 unsigned int bitrate; 185 unsigned long vbr_frames; 186 unsigned long vbr_rate; 187 188 signed long nsecs; 189 190 struct audio_stats audio; 191 } stats; 192 }; 193 194 void player_init(struct player *); 195 void player_finish(struct player *); 196 197 int player_run(struct player *, int, char const *[]); 198 199 # endif 200