music_chunk: added assertions on the audio format

In !NDEBUG, remember which audio_format is stored in every chunk and
every pipe.  Check the audio_format of every new data block appended
to the music_chunk, and the format of every new chunk appended to the
music_pipe.
This commit is contained in:
Max Kellermann
2009-03-08 13:45:24 +01:00
parent 359f9871b2
commit 94d1a87d04
5 changed files with 89 additions and 0 deletions

View File

@@ -19,6 +19,10 @@
#ifndef MPD_CHUNK_H
#define MPD_CHUNK_H
#ifndef NDEBUG
#include "audio_format.h"
#endif
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
@@ -57,6 +61,10 @@ struct music_chunk {
/** the data (probably PCM) */
char data[CHUNK_SIZE];
#ifndef NDEBUG
struct audio_format audio_format;
#endif
};
void
@@ -71,6 +79,16 @@ music_chunk_is_empty(const struct music_chunk *chunk)
return chunk->length == 0 && chunk->tag == NULL;
}
#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);
#endif
/**
* Prepares appending to the music chunk. Returns a buffer where you
* may write into. After you are finished, call music_chunk_expand().