2 * Copyright (C) 2003-2010 The Music Player Daemon Project
3 * http://www.musicpd.org
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.
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.
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.
23 #include "replay_gain_info.h"
26 #include "audio_format.h"
40 * A chunk of music data. Its format is defined by the
41 * music_pipe_append() caller.
44 /** the next chunk in a linked list */
45 struct music_chunk
*next
;
47 /** number of bytes stored in this chunk */
50 /** current bit rate of the source file */
53 /** the time stamp within the song */
57 * An optional tag associated with this chunk (and the
58 * following chunks); appears at song boundaries. The tag
59 * object is owned by this chunk, and must be freed when this
60 * chunk is deinitialized in music_chunk_free()
65 * Replay gain information associated with this chunk.
66 * Only valid if the serial is not 0.
68 struct replay_gain_info replay_gain_info
;
71 * A serial number for checking if replay gain info has
72 * changed since the last chunk. The magic value 0 indicates
73 * that there is no replay gain info available.
75 unsigned replay_gain_serial
;
77 /** the data (probably PCM) */
78 char data
[CHUNK_SIZE
];
81 struct audio_format audio_format
;
86 music_chunk_init(struct music_chunk
*chunk
);
89 music_chunk_free(struct music_chunk
*chunk
);
92 music_chunk_is_empty(const struct music_chunk
*chunk
)
94 return chunk
->length
== 0 && chunk
->tag
== NULL
;
99 * Checks if the audio format if the chunk is equal to the specified
103 music_chunk_check_format(const struct music_chunk
*chunk
,
104 const struct audio_format
*audio_format
);
108 * Prepares appending to the music chunk. Returns a buffer where you
109 * may write into. After you are finished, call music_chunk_expand().
111 * @param chunk the music_chunk object
112 * @param audio_format the audio format for the appended data; must
113 * stay the same for the life cycle of this chunk
114 * @param data_time the time within the song
115 * @param bit_rate the current bit rate of the source file
116 * @param max_length_r the maximum write length is returned here
117 * @return a writable buffer, or NULL if the chunk is full
120 music_chunk_write(struct music_chunk
*chunk
,
121 const struct audio_format
*audio_format
,
122 float data_time
, uint16_t bit_rate
,
123 size_t *max_length_r
);
126 * Increases the length of the chunk after the caller has written to
127 * the buffer returned by music_chunk_write().
129 * @param chunk the music_chunk object
130 * @param audio_format the audio format for the appended data; must
131 * stay the same for the life cycle of this chunk
132 * @param length the number of bytes which were appended
133 * @return true if the chunk is full
136 music_chunk_expand(struct music_chunk
*chunk
,
137 const struct audio_format
*audio_format
, size_t length
);