From 03dfd2b48e036f242acd9bb5d97fb7a5f1adc079 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Wed, 6 Apr 2016 11:52:05 -0700 Subject: [PATCH] ...and more AudioThread cleanup. --- firmware/application/audio_thread.hpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/firmware/application/audio_thread.hpp b/firmware/application/audio_thread.hpp index 7290a3de..7474c43d 100644 --- a/firmware/application/audio_thread.hpp +++ b/firmware/application/audio_thread.hpp @@ -102,23 +102,24 @@ private: } msg_t run() { - bool success = true; - while( success && !chThdShouldTerminate() ) { + auto fifo = reinterpret_cast*>(shared_memory.FIFO_HACK); + if( !fifo ) { + return false; + } + + StreamOutput stream { fifo }; + + while( !chThdShouldTerminate() ) { chEvtWaitAny(EVT_FIFO_HIGHWATER); - auto fifo = reinterpret_cast*>(shared_memory.FIFO_HACK); - if( !fifo ) { - break; - } - - StreamOutput stream { fifo }; - - while( success && (stream.available() >= write_buffer->size()) ) { - success = transfer(stream, write_buffer.get()); + while( stream.available() >= write_buffer->size() ) { + if( !transfer(stream, write_buffer.get()) ) { + return false; + } } } - - return success; + + return true; } bool transfer(StreamOutput& stream, std::array* const write_buffer) {