00001 /* 00002 * Copyright (C) 2003-2011 The Music Player Daemon Project 00003 * http://www.musicpd.org 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, write to the Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00018 */ 00019 00020 #ifndef MPD_CHUNK_H 00021 #define MPD_CHUNK_H 00022 00023 #include "replay_gain_info.h" 00024 00025 #ifndef NDEBUG 00026 #include "audio_format.h" 00027 #endif 00028 00029 #include <stdbool.h> 00030 #include <stdint.h> 00031 #include <stddef.h> 00032 00033 enum { 00034 CHUNK_SIZE = 4096, 00035 }; 00036 00037 struct audio_format; 00038 00043 struct music_chunk { 00045 struct music_chunk *next; 00046 00051 struct music_chunk *other; 00052 00057 float mix_ratio; 00058 00060 uint16_t length; 00061 00063 uint16_t bit_rate; 00064 00066 float times; 00067 00074 struct tag *tag; 00075 00080 struct replay_gain_info replay_gain_info; 00081 00087 unsigned replay_gain_serial; 00088 00090 char data[CHUNK_SIZE]; 00091 00092 #ifndef NDEBUG 00093 struct audio_format audio_format; 00094 #endif 00095 }; 00096 00097 void 00098 music_chunk_init(struct music_chunk *chunk); 00099 00100 void 00101 music_chunk_free(struct music_chunk *chunk); 00102 00103 static inline bool 00104 music_chunk_is_empty(const struct music_chunk *chunk) 00105 { 00106 return chunk->length == 0 && chunk->tag == NULL; 00107 } 00108 00109 #ifndef NDEBUG 00110 00114 bool 00115 music_chunk_check_format(const struct music_chunk *chunk, 00116 const struct audio_format *audio_format); 00117 #endif 00118 00131 void * 00132 music_chunk_write(struct music_chunk *chunk, 00133 const struct audio_format *audio_format, 00134 float data_time, uint16_t bit_rate, 00135 size_t *max_length_r); 00136 00147 bool 00148 music_chunk_expand(struct music_chunk *chunk, 00149 const struct audio_format *audio_format, size_t length); 00150 00151 #endif