diff options
author | Andreas Eversberg <jolly@eversberg.eu> | 2017-03-18 09:57:38 +0100 |
---|---|---|
committer | Andreas Eversberg <jolly@eversberg.eu> | 2017-05-15 21:46:28 +0200 |
commit | 6e0e0c9ce8d6e885d0dee658eb5a7195f764e8d5 (patch) | |
tree | 3565c3185e5cb21b1285da3d0da4cecd73116e43 /src | |
parent | 9dda9e1efc2ff5b820438524c666900f93fe3a72 (diff) |
fixup Rework on audio buffer management
Diffstat (limited to 'src')
-rw-r--r-- | src/common/sender.c | 3 | ||||
-rw-r--r-- | src/common/soapy.c | 13 | ||||
-rw-r--r-- | src/common/uhd.c | 3 |
3 files changed, 13 insertions, 6 deletions
diff --git a/src/common/sender.c b/src/common/sender.c index ca73496..da7822b 100644 --- a/src/common/sender.c +++ b/src/common/sender.c @@ -297,6 +297,9 @@ cant_recover: return; } if (count > 0) { + /* limit to our buffer */ + if (count > latspl) + count = latspl; /* loop through all channels */ for (i = 0, inst = sender; inst; i++, inst = inst->slave) { /* load TX data from audio loop or from sender instance */ diff --git a/src/common/soapy.c b/src/common/soapy.c index 1f56456..a653b76 100644 --- a/src/common/soapy.c +++ b/src/common/soapy.c @@ -32,8 +32,8 @@ SoapySDRStream *rxStream = NULL; SoapySDRStream *txStream = NULL; static int tx_samps_per_buff, rx_samps_per_buff; static double samplerate; -static long long rx_count = 0; -static long long tx_count = 0; +static uint64_t rx_count = 0; +static uint64_t tx_count = 0; int soapy_open(const char *device_args, double tx_frequency, double rx_frequency, double rate, double rx_gain, double tx_gain, double bandwidth) { @@ -266,7 +266,8 @@ int soapy_receive(float *buff, int max) while (1) { if (max < rx_samps_per_buff) { - PDEBUG(DUHD, DEBUG_ERROR, "SDR rx buffer overflow!\n"); + /* no more space this time */ + PDEBUG(DUHD, DEBUG_ERROR, "SDR RX overflow!\n"); break; } /* read RX stream */ @@ -299,13 +300,15 @@ int soapy_get_tosend(int latspl) /* if we have not yet sent any data, we set initial tx time stamp */ if (tx_count == 0) - tx_count = rx_count + latspl; + tx_count = rx_count; /* we check how advance our transmitted time stamp is */ tosend = latspl - (tx_count - rx_count); /* in case of underrun: */ - if (tosend < 0) + if (tosend < 0) { + PDEBUG(DUHD, DEBUG_ERROR, "SDR TX underrun!\n"); tosend = 0; + } return tosend; } diff --git a/src/common/uhd.c b/src/common/uhd.c index dcbc390..c968798 100644 --- a/src/common/uhd.c +++ b/src/common/uhd.c @@ -369,7 +369,8 @@ int uhd_receive(float *buff, int max) while (1) { if (max < (int)rx_samps_per_buff) { - PDEBUG(DUHD, DEBUG_ERROR, "SDR rx buffer overflow!\n"); + /* no more space this time */ + PDEBUG(DUHD, DEBUG_ERROR, "SDR RX overflow!\n"); break; } /* read RX stream */ |