From 14d1b5fd727309e8389fab127a7b6e7b05743e12 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Wed, 6 Apr 2016 11:47:25 -0700 Subject: [PATCH] Further AudioThread cleanup. --- firmware/application/audio_thread.hpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/firmware/application/audio_thread.hpp b/firmware/application/audio_thread.hpp index 6f87c1df..7290a3de 100644 --- a/firmware/application/audio_thread.hpp +++ b/firmware/application/audio_thread.hpp @@ -72,7 +72,11 @@ public: ~AudioThread() { chThdTerminate(thread); chEvtSignal(thread, EVT_FIFO_HIGHWATER); - chThdWait(thread); + const auto success = chThdWait(thread); + + if( !success ) { + led_tx.on(); + } } static void check_fifo_isr() { @@ -94,12 +98,10 @@ private: static msg_t static_fn(void* arg) { auto obj = static_cast(arg); - obj->run(); - - return 0; + return obj->run(); } - void run() { + msg_t run() { bool success = true; while( success && !chThdShouldTerminate() ) { chEvtWaitAny(EVT_FIFO_HIGHWATER); @@ -115,10 +117,8 @@ private: success = transfer(stream, write_buffer.get()); } } - - if( !success ) { - led_tx.on(); - } + + return success; } bool transfer(StreamOutput& stream, std::array* const write_buffer) {