MPD
chunk.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2003-2010 The Music Player Daemon Project
3  * http://www.musicpd.org
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 along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef MPD_CHUNK_H
21 #define MPD_CHUNK_H
22 
23 #include "replay_gain_info.h"
24 
25 #ifndef NDEBUG
26 #include "audio_format.h"
27 #endif
28 
29 #include <stdbool.h>
30 #include <stdint.h>
31 #include <stddef.h>
32 
33 enum {
34  CHUNK_SIZE = 4096,
35 };
36 
37 struct audio_format;
38 
43 struct music_chunk {
45  struct music_chunk *next;
46 
51  struct music_chunk *other;
52 
57  float mix_ratio;
58 
60  uint16_t length;
61 
63  uint16_t bit_rate;
64 
66  float times;
67 
74  struct tag *tag;
75 
81 
88 
91 
92 #ifndef NDEBUG
94 #endif
95 };
96 
97 void
98 music_chunk_init(struct music_chunk *chunk);
99 
100 void
101 music_chunk_free(struct music_chunk *chunk);
102 
103 static inline bool
104 music_chunk_is_empty(const struct music_chunk *chunk)
105 {
106  return chunk->length == 0 && chunk->tag == NULL;
107 }
108 
109 #ifndef NDEBUG
110 
114 bool
115 music_chunk_check_format(const struct music_chunk *chunk,
116  const struct audio_format *audio_format);
117 #endif
118 
131 void *
132 music_chunk_write(struct music_chunk *chunk,
133  const struct audio_format *audio_format,
134  float data_time, uint16_t bit_rate,
135  size_t *max_length_r);
136 
147 bool
148 music_chunk_expand(struct music_chunk *chunk,
149  const struct audio_format *audio_format, size_t length);
150 
151 #endif