From 7fa3b7a267e2e42c06a8350a807b2445b9588372 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 26 Sep 2013 22:41:07 +0200 Subject: PlayerThread: simplify "buffer empty" assertion --- src/MusicBuffer.hxx | 11 +++++++++++ src/PlayerThread.cxx | 8 +------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/MusicBuffer.hxx b/src/MusicBuffer.hxx index fe14fe300..d2b23d43a 100644 --- a/src/MusicBuffer.hxx +++ b/src/MusicBuffer.hxx @@ -43,6 +43,17 @@ public: */ MusicBuffer(unsigned num_chunks); +#ifndef NDEBUG + /** + * Check whether the buffer is empty. This call is not + * protected with the mutex, and may only be used while this + * object is inaccessible to other threads. + */ + bool IsEmptyUnsafe() const { + return buffer.IsEmpty(); + } +#endif + /** * Returns the total number of reserved chunks in this buffer. This * is the same value which was passed to the constructor diff --git a/src/PlayerThread.cxx b/src/PlayerThread.cxx index 6cf8e556b..3e03e5978 100644 --- a/src/PlayerThread.cxx +++ b/src/PlayerThread.cxx @@ -1143,13 +1143,7 @@ player_task(gpointer arg) pc->Lock(); player_command_finished_locked(pc); -#ifndef NDEBUG - /* in the DEBUG build, check for leaked - music_chunk objects by freeing the - music_buffer */ - delete player_buffer; - player_buffer = new MusicBuffer(pc->buffer_chunks); -#endif + assert(player_buffer->IsEmptyUnsafe()); break; -- cgit v1.2.3