aboutsummaryrefslogtreecommitdiffstats
path: root/src/chunk.h
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-03-05 17:37:11 +0100
committerMax Kellermann <max@duempel.org>2009-03-05 17:37:11 +0100
commit74a2813d781ec2bc2c0f5e4534552d4d8e99557b (patch)
tree21b7e5088d540b9974290ae2ad9a1544553d534e /src/chunk.h
parentc655f804a92d82416b62d541c528b615e2ce27f6 (diff)
downloadmpd-74a2813d781ec2bc2c0f5e4534552d4d8e99557b.tar.gz
mpd-74a2813d781ec2bc2c0f5e4534552d4d8e99557b.tar.xz
mpd-74a2813d781ec2bc2c0f5e4534552d4d8e99557b.zip
music_chunk: added music_chunk_write(), music_chunk_expand()
Moved some code from music_pipe_write() and music_pipe_expand(). Only music_chunk.c should access the music_chunk internals.
Diffstat (limited to 'src/chunk.h')
-rw-r--r--src/chunk.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/chunk.h b/src/chunk.h
index 747d018ca..58ed7be6f 100644
--- a/src/chunk.h
+++ b/src/chunk.h
@@ -19,13 +19,17 @@
#ifndef MPD_CHUNK_H
#define MPD_CHUNK_H
+#include <stdbool.h>
#include <stdint.h>
+#include <stddef.h>
enum {
/* pick 1020 since its devisible for 8,16,24, and 32-bit audio */
CHUNK_SIZE = 1020,
};
+struct audio_format;
+
/**
* A chunk of music data. Its format is defined by the
* music_pipe_append() caller.
@@ -58,4 +62,36 @@ music_chunk_init(struct music_chunk *chunk);
void
music_chunk_free(struct music_chunk *chunk);
+/**
+ * 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