fixup Rework on audio buffer management
This commit is contained in:
parent
9dda9e1efc
commit
6e0e0c9ce8
|
@ -297,6 +297,9 @@ cant_recover:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
|
/* limit to our buffer */
|
||||||
|
if (count > latspl)
|
||||||
|
count = latspl;
|
||||||
/* loop through all channels */
|
/* loop through all channels */
|
||||||
for (i = 0, inst = sender; inst; i++, inst = inst->slave) {
|
for (i = 0, inst = sender; inst; i++, inst = inst->slave) {
|
||||||
/* load TX data from audio loop or from sender instance */
|
/* load TX data from audio loop or from sender instance */
|
||||||
|
|
|
@ -32,8 +32,8 @@ SoapySDRStream *rxStream = NULL;
|
||||||
SoapySDRStream *txStream = NULL;
|
SoapySDRStream *txStream = NULL;
|
||||||
static int tx_samps_per_buff, rx_samps_per_buff;
|
static int tx_samps_per_buff, rx_samps_per_buff;
|
||||||
static double samplerate;
|
static double samplerate;
|
||||||
static long long rx_count = 0;
|
static uint64_t rx_count = 0;
|
||||||
static long long tx_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)
|
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) {
|
while (1) {
|
||||||
if (max < rx_samps_per_buff) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
/* read RX stream */
|
/* 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 we have not yet sent any data, we set initial tx time stamp */
|
||||||
if (tx_count == 0)
|
if (tx_count == 0)
|
||||||
tx_count = rx_count + latspl;
|
tx_count = rx_count;
|
||||||
|
|
||||||
/* we check how advance our transmitted time stamp is */
|
/* we check how advance our transmitted time stamp is */
|
||||||
tosend = latspl - (tx_count - rx_count);
|
tosend = latspl - (tx_count - rx_count);
|
||||||
/* in case of underrun: */
|
/* in case of underrun: */
|
||||||
if (tosend < 0)
|
if (tosend < 0) {
|
||||||
|
PDEBUG(DUHD, DEBUG_ERROR, "SDR TX underrun!\n");
|
||||||
tosend = 0;
|
tosend = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return tosend;
|
return tosend;
|
||||||
}
|
}
|
||||||
|
|
|
@ -369,7 +369,8 @@ int uhd_receive(float *buff, int max)
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (max < (int)rx_samps_per_buff) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
/* read RX stream */
|
/* read RX stream */
|
||||||
|
|
Loading…
Reference in New Issue