aboutsummaryrefslogtreecommitdiffstats
path: root/src/MusicChunk.hxx
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/MusicChunk.hxx (renamed from src/chunk.h)104
1 files changed, 53 insertions, 51 deletions
diff --git a/src/chunk.h b/src/MusicChunk.hxx
index a06a203eb..c03e45517 100644
--- a/src/chunk.h
+++ b/src/MusicChunk.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_CHUNK_H
-#define MPD_CHUNK_H
+#ifndef MPD_MUSIC_CHUNK_HXX
+#define MPD_MUSIC_CHUNK_HXX
#include "replay_gain_info.h"
@@ -26,7 +26,6 @@
#include "audio_format.h"
#endif
-#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
@@ -92,60 +91,63 @@ struct music_chunk {
#ifndef NDEBUG
struct audio_format audio_format;
#endif
-};
-void
-music_chunk_init(struct music_chunk *chunk);
+ music_chunk()
+ :other(nullptr),
+ length(0),
+ tag(nullptr),
+ replay_gain_serial(0) {}
-void
-music_chunk_free(struct music_chunk *chunk);
+ ~music_chunk();
-static inline bool
-music_chunk_is_empty(const struct music_chunk *chunk)
-{
- return chunk->length == 0 && chunk->tag == NULL;
-}
+ bool IsEmpty() const {
+ return length == 0 && tag == nullptr;
+ }
#ifndef NDEBUG
-/**
- * Checks if the audio format if the chunk is equal to the specified
- * audio_format.
- */
-bool
-music_chunk_check_format(const struct music_chunk *chunk,
- const struct audio_format *audio_format);
+ /**
+ * Checks if the audio format if the chunk is equal to the
+ * specified audio_format.
+ */
+ gcc_pure
+ bool CheckFormat(const struct audio_format &audio_format) const;
#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);
+ /**
+ * 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 *Write(const struct audio_format &af,
+ 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);
+ /**
+ * 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 Expand(const struct audio_format &af, size_t length);
+};
+
+void
+music_chunk_init(struct music_chunk *chunk);
+
+void
+music_chunk_free(struct music_chunk *chunk);
#endif