Commit f1e6b168 authored by Joanne Hugé's avatar Joanne Hugé

No segfault when doing nothing

parent 097b23c2
......@@ -34,7 +34,7 @@
#define DEBUG
//#define DISABLE_SEND
#define DISABLE_RECV
//#define DISABLE_RECV
#include "utils.c"
#include "ring_buffer.c"
......@@ -424,6 +424,7 @@ static void *encode_thread(void *p) {
// And if there are frames from trx_write callback to encode
to_write = rbuf_write_amount(&tx_rbuf);
to_read = rbuf_read_amount(&trxw_rbuf[0]);
usleep(1);
if(!to_write || !to_read)
continue;
......@@ -724,6 +725,7 @@ int start(TRXEcpriState * s) {
init_rbuf(&rx_rbuf, "RX ring buffer", s->txrx_buf_size, PACKET_SIZE);
init_rbuf(&tx_rbuf, "TX ring buffer", s->txrx_buf_size, PACKET_SIZE);
log_debug("DEBUG", "rbuf_read_amount(tx_rbuf) = %d", rbuf_read_amount(&tx_rbuf));
for(int i = 0; i < s->tx_n_channel; i++) {
char name[256];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment