1 /* 2 * flac123 a command-line flac player 3 * Copyright (C) 2003-2007 Jake Angerman 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 20 #include <stdio.h> 21 #include <ao/ao.h> 22 #include <limits.h> 23 #include <FLAC/all.h> 24 25 /* by LEGACY_FLAC we mean pre-1.1.3 before FLAC__FileDecoder was merged into FLAC__StreamDecoder */ 26 #if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8 27 #define LEGACY_FLAC 28 #else 29 #undef LEGACY_FLAC 30 #endif 31 32 /* string widths for printing ID3 (vorbis) data in remote mode */ 33 #define VORBIS_TAG_LEN 30 34 #define VORBIS_YEAR_LEN 4 35 36 /* the main data structure of the program */ 37 typedef struct { 38 #ifdef LEGACY_FLAC 39 FLAC__FileDecoder *decoder; 40 #else 41 FLAC__StreamDecoder *decoder; 42 #endif 43 44 /* bits, rate, channels, byte_format */ 45 ao_sample_format sam_fmt; /* input sample's true format */ 46 ao_sample_format ao_fmt; /* libao output format */ 47 48 ao_device *ao_dev; 49 char filename[PATH_MAX]; 50 unsigned long total_samples; 51 unsigned long current_sample; 52 float total_time; /* seconds */ 53 float elapsed_time; /* seconds */ 54 FLAC__bool is_loaded; /* loaded or not? */ 55 FLAC__bool is_playing; /* playing or not? */ 56 char title[VORBIS_TAG_LEN+1]; 57 char artist[VORBIS_TAG_LEN+1]; 58 char album[VORBIS_TAG_LEN+1]; /* +1 for \0 */ 59 char genre[VORBIS_TAG_LEN+1]; 60 char comment[VORBIS_TAG_LEN+1]; 61 char year[VORBIS_YEAR_LEN+1]; 62 } file_info_struct; 63 64 extern file_info_struct file_info; 65 66 extern FLAC__bool decoder_constructor(const char *filename); 67 extern void decoder_destructor(void); 68 extern int remote_get_input_wait(void); 69 extern int remote_get_input_nowait(void); 70 extern FLAC__bool get_vorbis_comments(const char *filename); 71 72 extern float scale; 73