...and more AudioThread cleanup.

This commit is contained in:
Jared Boone 2016-04-06 11:52:05 -07:00
parent 14d1b5fd72
commit 03dfd2b48e

View File

@ -102,23 +102,24 @@ private:
} }
msg_t run() { msg_t run() {
bool success = true;
while( success && !chThdShouldTerminate() ) {
chEvtWaitAny(EVT_FIFO_HIGHWATER);
auto fifo = reinterpret_cast<FIFO<uint8_t>*>(shared_memory.FIFO_HACK); auto fifo = reinterpret_cast<FIFO<uint8_t>*>(shared_memory.FIFO_HACK);
if( !fifo ) { if( !fifo ) {
break; return false;
} }
StreamOutput stream { fifo }; StreamOutput stream { fifo };
while( success && (stream.available() >= write_buffer->size()) ) { while( !chThdShouldTerminate() ) {
success = transfer(stream, write_buffer.get()); chEvtWaitAny(EVT_FIFO_HIGHWATER);
while( stream.available() >= write_buffer->size() ) {
if( !transfer(stream, write_buffer.get()) ) {
return false;
}
} }
} }
return success; return true;
} }
bool transfer(StreamOutput& stream, std::array<uint8_t, write_size>* const write_buffer) { bool transfer(StreamOutput& stream, std::array<uint8_t, write_size>* const write_buffer) {