2525
2626// #define DEBUG_DBLBUFSTREAM 1
2727#if DEBUG_DBLBUFSTREAM
28- #define pr_dbg printf
28+ #define dbs_pr_err printf
2929#else
30- #define pr_dbg (...)
30+ #define dbs_pr_err (...)
3131#endif
3232
3333template <typename T, size_t Size>
@@ -51,16 +51,16 @@ struct DoubleBufferStream {
5151 for (auto d : word)
5252 inactive_buf.push_back (d);
5353
54- pr_dbg (" DBS::transmit: queued tx data in buffer %u\n " , inactive_idx);
54+ // pr_dbg("DBS::transmit: queued tx data in buffer %u\n", inactive_idx);
5555
5656 // Start a new transmission if one isn't in progress
5757 if (!in_progress_idx.has_value ()) {
58- pr_dbg (" DBS::transmit: not tx in progress, so starting new tx \n " );
58+ // pr_dbg("DBS::transmit(): no tx in progress, so starting now \n");
5959 return start_tx (inactive_idx);
6060 }
6161
6262 // tx_done_callback() will transmit our data when it's called
63- pr_dbg (" DBS::transmit: tx is progress, so not starting new tx\n " );
63+ // pr_dbg("DBS::transmit() : tx is progress, so not starting new tx\n");
6464 return true ;
6565 } else {
6666 return false ;
@@ -69,19 +69,19 @@ struct DoubleBufferStream {
6969
7070 void tx_done_callback () {
7171 if (!in_progress_idx.has_value ()) {
72- pr_dbg (" MIDI Host internal error: tx_done_callback called but no buffer is in progress\n " );
72+ dbs_pr_err (" MIDI Host internal error: tx_done_callback called but no buffer is in progress\n " );
7373 return ;
7474 }
7575
7676 tx_buffer[in_progress_idx.value ()].clear ();
7777
78- pr_dbg (" DBS::tx_done_callback: finished tx of buffer[%u]\n " , in_progress_idx.value ());
78+ // pr_dbg("DBS::tx_done_callback() : finished tx of buffer[%u]\n", in_progress_idx.value());
7979
8080 // Check if we should start transmitting the other buffer
8181 auto other_buffer = 1 - in_progress_idx.value ();
8282
8383 if (tx_buffer[other_buffer].size ()) {
84- pr_dbg (" DBS: tx_done_callback starting tx for %u \n " , other_buffer);
84+ // pr_dbg("DBS: tx_done_callback(): starting tx for buffer[%u] \n", other_buffer);
8585 start_tx (other_buffer);
8686 } else {
8787 in_progress_idx = std::nullopt ;
@@ -91,7 +91,7 @@ struct DoubleBufferStream {
9191private:
9292 bool start_tx (unsigned idx) {
9393 in_progress_idx = idx;
94- pr_dbg (" DBS::start_tx: starting tx of buffer[%u]\n " , idx);
94+ // pr_dbg("DBS::start_tx() : starting tx of buffer[%u]\n", idx);
9595 auto &active_buf = tx_buffer[idx];
9696 auto res = transmit_func ({active_buf.begin (), active_buf.size ()});
9797 return res;
0 commit comments