aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-04-25 15:07:22 +0200
committerMax Kellermann <max@duempel.org>2009-04-25 15:07:22 +0200
commitceb00f787e2e0ea149a411dc7f2e1102e458dfba (patch)
treecf13aa5a1439ff550ce6b9efd8f2a0f5798a6b96
parentd01d1ccad2cf9be20fb6fc3e84af6cd7d6febd9f (diff)
downloadmpd-ceb00f787e2e0ea149a411dc7f2e1102e458dfba.tar.gz
mpd-ceb00f787e2e0ea149a411dc7f2e1102e458dfba.tar.xz
mpd-ceb00f787e2e0ea149a411dc7f2e1102e458dfba.zip
decoder: added assertions on dc.pipe
dc.pipe must be non-NULL while the decoder thread is running. Ensure that with a load of assertions.
-rw-r--r--src/decoder_api.c11
-rw-r--r--src/decoder_control.c2
2 files changed, 13 insertions, 0 deletions
diff --git a/src/decoder_api.c b/src/decoder_api.c
index c777084c8..ee80c471f 100644
--- a/src/decoder_api.c
+++ b/src/decoder_api.c
@@ -42,6 +42,7 @@ void decoder_initialized(G_GNUC_UNUSED struct decoder * decoder,
bool seekable, float total_time)
{
assert(dc.state == DECODE_STATE_START);
+ assert(dc.pipe != NULL);
assert(decoder != NULL);
assert(decoder->stream_tag == NULL);
assert(decoder->decoder_tag == NULL);
@@ -73,11 +74,15 @@ void decoder_initialized(G_GNUC_UNUSED struct decoder * decoder,
char *decoder_get_uri(G_GNUC_UNUSED struct decoder *decoder)
{
+ assert(dc.pipe != NULL);
+
return song_get_uri(dc.current_song);
}
enum decoder_command decoder_get_command(G_GNUC_UNUSED struct decoder * decoder)
{
+ assert(dc.pipe != NULL);
+
return dc.command;
}
@@ -86,6 +91,7 @@ void decoder_command_finished(G_GNUC_UNUSED struct decoder * decoder)
assert(dc.command != DECODE_COMMAND_NONE);
assert(dc.command != DECODE_COMMAND_SEEK ||
dc.seek_error || decoder->seeking);
+ assert(dc.pipe != NULL);
if (dc.command == DECODE_COMMAND_SEEK) {
/* delete frames from the old song position */
@@ -105,6 +111,7 @@ void decoder_command_finished(G_GNUC_UNUSED struct decoder * decoder)
double decoder_seek_where(G_GNUC_UNUSED struct decoder * decoder)
{
assert(dc.command == DECODE_COMMAND_SEEK);
+ assert(dc.pipe != NULL);
decoder->seeking = true;
@@ -114,6 +121,7 @@ double decoder_seek_where(G_GNUC_UNUSED struct decoder * decoder)
void decoder_seek_error(struct decoder * decoder)
{
assert(dc.command == DECODE_COMMAND_SEEK);
+ assert(dc.pipe != NULL);
dc.seek_error = true;
decoder_command_finished(decoder);
@@ -128,6 +136,7 @@ size_t decoder_read(struct decoder *decoder,
assert(decoder == NULL ||
dc.state == DECODE_STATE_START ||
dc.state == DECODE_STATE_DECODE);
+ assert(dc.pipe != NULL);
assert(is != NULL);
assert(buffer != NULL);
@@ -219,6 +228,7 @@ decoder_data(struct decoder *decoder,
const char *data = _data;
assert(dc.state == DECODE_STATE_DECODE);
+ assert(dc.pipe != NULL);
assert(length % audio_format_frame_size(&dc.in_audio_format) == 0);
if (dc.command == DECODE_COMMAND_STOP ||
@@ -322,6 +332,7 @@ decoder_tag(G_GNUC_UNUSED struct decoder *decoder, struct input_stream *is,
enum decoder_command cmd;
assert(dc.state == DECODE_STATE_DECODE);
+ assert(dc.pipe != NULL);
assert(tag != NULL);
/* save the tag */
diff --git a/src/decoder_control.c b/src/decoder_control.c
index 4e7ade22c..7aa80c2c6 100644
--- a/src/decoder_control.c
+++ b/src/decoder_control.c
@@ -60,6 +60,7 @@ static void dc_command_async(enum decoder_command cmd)
void
dc_start(struct notify *notify, struct song *song)
{
+ assert(dc.pipe != NULL);
assert(song != NULL);
dc.next_song = song;
@@ -69,6 +70,7 @@ dc_start(struct notify *notify, struct song *song)
void
dc_start_async(struct song *song)
{
+ assert(dc.pipe != NULL);
assert(song != NULL);
dc.next_song = song;