aboutsummaryrefslogtreecommitdiff
path: root/src/chunk.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/chunk.h')
-rw-r--r--src/chunk.h45
1 files changed, 7 insertions, 38 deletions
diff --git a/src/chunk.h b/src/chunk.h
index a06a203e..c92e1fd1 100644
--- a/src/chunk.h
+++ b/src/chunk.h
@@ -30,6 +30,8 @@
#include <stdint.h>
#include <stddef.h>
+#include <libavutil/frame.h>
+
enum {
CHUNK_SIZE = 4096,
};
@@ -56,9 +58,6 @@ struct music_chunk {
*/
float mix_ratio;
- /** number of bytes stored in this chunk */
- uint16_t length;
-
/** current bit rate of the source file */
uint16_t bit_rate;
@@ -86,8 +85,8 @@ struct music_chunk {
*/
unsigned replay_gain_serial;
- /** the data (probably PCM) */
- char data[CHUNK_SIZE];
+ /** the audio frame */
+ AVFrame *frame;
#ifndef NDEBUG
struct audio_format audio_format;
@@ -97,13 +96,15 @@ struct music_chunk {
void
music_chunk_init(struct music_chunk *chunk);
+struct music_chunk *music_chunk_alloc(void);
+
void
music_chunk_free(struct music_chunk *chunk);
static inline bool
music_chunk_is_empty(const struct music_chunk *chunk)
{
- return chunk->length == 0 && chunk->tag == NULL;
+ return !chunk->frame && chunk->tag == NULL;
}
#ifndef NDEBUG
@@ -116,36 +117,4 @@ music_chunk_check_format(const struct music_chunk *chunk,
const struct audio_format *audio_format);
#endif
-/**
- * Prepares appending to the music chunk. Returns a buffer where you
- * may write into. After you are finished, call music_chunk_expand().
- *
- * @param chunk the music_chunk object
- * @param audio_format the audio format for the appended data; must
- * stay the same for the life cycle of this chunk
- * @param data_time the time within the song
- * @param bit_rate the current bit rate of the source file
- * @param max_length_r the maximum write length is returned here
- * @return a writable buffer, or NULL if the chunk is full
- */
-void *
-music_chunk_write(struct music_chunk *chunk,
- const struct audio_format *audio_format,
- float data_time, uint16_t bit_rate,
- size_t *max_length_r);
-
-/**
- * Increases the length of the chunk after the caller has written to
- * the buffer returned by music_chunk_write().
- *
- * @param chunk the music_chunk object
- * @param audio_format the audio format for the appended data; must
- * stay the same for the life cycle of this chunk
- * @param length the number of bytes which were appended
- * @return true if the chunk is full
- */
-bool
-music_chunk_expand(struct music_chunk *chunk,
- const struct audio_format *audio_format, size_t length);
-
#endif