00001 /* 00002 * Copyright (C) 2003-2009 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 #ifndef NDEBUG 00024 #include "audio_format.h" 00025 #endif 00026 00027 #include <stdbool.h> 00028 #include <stdint.h> 00029 #include <stddef.h> 00030 00031 enum { 00032 CHUNK_SIZE = 4096, 00033 }; 00034 00035 struct audio_format; 00036 00041 struct music_chunk { 00043 struct music_chunk *next; 00044 00046 uint16_t length; 00047 00049 uint16_t bit_rate; 00050 00052 float times; 00053 00060 struct tag *tag; 00061 00063 char data[CHUNK_SIZE]; 00064 00065 #ifndef NDEBUG 00066 struct audio_format audio_format; 00067 #endif 00068 }; 00069 00070 void 00071 music_chunk_init(struct music_chunk *chunk); 00072 00073 void 00074 music_chunk_free(struct music_chunk *chunk); 00075 00076 static inline bool 00077 music_chunk_is_empty(const struct music_chunk *chunk) 00078 { 00079 return chunk->length == 0 && chunk->tag == NULL; 00080 } 00081 00082 #ifndef NDEBUG 00083 00087 bool 00088 music_chunk_check_format(const struct music_chunk *chunk, 00089 const struct audio_format *audio_format); 00090 #endif 00091 00104 void * 00105 music_chunk_write(struct music_chunk *chunk, 00106 const struct audio_format *audio_format, 00107 float data_time, uint16_t bit_rate, 00108 size_t *max_length_r); 00109 00120 bool 00121 music_chunk_expand(struct music_chunk *chunk, 00122 const struct audio_format *audio_format, size_t length); 00123 00124 #endif