From 84b540f435e90fff5b13f295b1a0927cbcb5d744 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 10 Nov 2008 15:02:26 +0100 Subject: decoder: added more assertions Added a lot of assertions checking the state of the decoder plugin. --- src/decoder_api.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/decoder_api.c b/src/decoder_api.c index e0bdb6eb4..934c7d811 100644 --- a/src/decoder_api.c +++ b/src/decoder_api.c @@ -35,7 +35,11 @@ void decoder_initialized(struct decoder * decoder, bool seekable, float total_time) { assert(dc.state == DECODE_STATE_START); + assert(decoder != NULL); + assert(!decoder->stream_tag_sent); + assert(!decoder->seeking); assert(audio_format != NULL); + assert(audio_format_defined(audio_format)); pcm_convert_init(&decoder->conv_state); @@ -96,6 +100,8 @@ size_t decoder_read(struct decoder *decoder, { size_t nbytes; + assert(dc.state == DECODE_STATE_START || + dc.state == DECODE_STATE_DECODE); assert(is != NULL); assert(buffer != NULL); @@ -175,6 +181,8 @@ decoder_data(struct decoder *decoder, size_t nbytes; char *data; + assert(dc.state == DECODE_STATE_DECODE); + if (is != NULL && !decoder->stream_tag_sent) { const struct tag *src; struct tag *tag1, *tag2; @@ -254,6 +262,8 @@ decoder_tag(mpd_unused struct decoder *decoder, struct input_stream *is, { struct tag *tag2 = is != NULL ? tag_add_stream_tags(tag, is) : NULL; + assert(dc.state == DECODE_STATE_DECODE); + if (tag2 != NULL) tag = tag2; -- cgit v1.2.3