Slightly modified basicRX example fails on MacOS Mojave

I took the basic basicRX example and made it close and re-open the stream. This works Ok on Windows 7 and Ubuntu 18.04, but fails on Mojave. I did this test, because CubicSDR 0.2.6a also fails when it does this. The program and the output follow with a few thousand “Received 5000 samples” removed. The receive fails after it is reopened.

/**
@file basicRX.cpp
@author Lime Microsystems (www.limemicro.com)
@brief minimal RX example
*/

// g++ -std=c++11 -o basicRX basicRX.cpp -lLimeSuite

#include “lime/LimeSuite.h”
#include
#include
#ifdef USE_GNU_PLOT
#include “gnuPlotPipe.h”
#endif

using namespace std;

//Device structure, should be initialize to NULL
lms_device_t* device = NULL;

int error()
{
if (device != NULL)
LMS_Close(device);
exit(-1);
}

int main(int argc, char** argv)
{
//Find devices
int n;
lms_info_str_t list[8]; //should be large enough to hold all detected devices
if ((n = LMS_GetDeviceList(list)) < 0) //NULL can be passed to only get number of devices
error();

cout << "Devices found: " << n << endl; //print number of devices
if (n < 1)
    return -1;

//open the first device
if (LMS_Open(&device, list[0], NULL))
    error();

//Initialize device with default configuration
//Do not use if you want to keep existing configuration
//Use LMS_LoadConfig(device, "/path/to/file.ini") to load config from INI
if (LMS_Init(device) != 0)
    error();

//Enable RX channel
//Channels are numbered starting at 0
if (LMS_EnableChannel(device, LMS_CH_RX, 0, true) != 0)
    error();

//Set center frequency to 800 MHz
if (LMS_SetLOFrequency(device, LMS_CH_RX, 0, 800e6) != 0)
    error();

//Set sample rate to 8 MHz, ask to use 2x oversampling in RF
//This set sampling rate for all channels
if (LMS_SetSampleRate(device, 8e6, 2) != 0)
    error();

//Streaming Setup

//Initialize stream
lms_stream_t streamId; //stream structure
streamId.channel = 0; //channel number
streamId.fifoSize = 1024 * 1024; //fifo size in samples
streamId.throughputVsLatency = 1.0; //optimize for max throughput
streamId.isTx = false; //RX channel
streamId.dataFmt = lms_stream_t::LMS_FMT_I12; //12-bit integers
if (LMS_SetupStream(device, &streamId) != 0)
    error();

//Initialize data buffers
const int sampleCnt = 5000; //complex samples per buffer
int16_t buffer[sampleCnt * 2]; //buffer to hold complex values (2*samples))

//Start streaming
LMS_StartStream(&streamId);

//Streaming

#ifdef USE_GNU_PLOT
GNUPlotPipe gp;
gp.write(“set size square\n set xrange[-2050:2050]\n set yrange[-2050:2050]\n”);
#endif
auto t1 = chrono::high_resolution_clock::now();
while (chrono::high_resolution_clock::now() - t1 < chrono::seconds(2)) //run for 5 seconds
{
//Receive samples
int samplesRead = LMS_RecvStream(&streamId, buffer, sampleCnt, NULL, 1000);
//I and Q samples are interleaved in buffer: IQIQIQ…
printf(“Received %d samples\n”, samplesRead);
/*
INSERT CODE FOR PROCESSING RECEIVED SAMPLES
*/
#ifdef USE_GNU_PLOT
//Plot samples
gp.write(“plot ‘-’ with points\n”);
for (int j = 0; j < samplesRead; ++j)
gp.writef("%i %i\n", buffer[2 * j], buffer[2 * j + 1]);
gp.write(“e\n”);
gp.flush();
#endif
}
//Stop streaming
LMS_StopStream(&streamId); //stream is stopped but can be started again with LMS_StartStream()
LMS_DestroyStream(device, &streamId); //stream is deallocated and can no longer be used

//Set sample rate to 8 MHz, ask to use 2x oversampling in RF
//This set sampling rate for all channels
if (LMS_SetSampleRate(device, 8e6, 2) != 0)
    error();


//Streaming Setup

//Initialize stream
streamId.channel = 0; //channel number
streamId.fifoSize = 1024 * 1024; //fifo size in samples
streamId.throughputVsLatency = 1.0; //optimize for max throughput
streamId.isTx = false; //RX channel
streamId.dataFmt = lms_stream_t::LMS_FMT_I12; //12-bit integers
if (LMS_SetupStream(device, &streamId) != 0)
    error();


//Start streaming
LMS_StartStream(&streamId);

//Streaming

#ifdef USE_GNU_PLOT
GNUPlotPipe gp;
gp.write(“set size square\n set xrange[-2050:2050]\n set yrange[-2050:2050]\n”);
#endif
t1 = chrono::high_resolution_clock::now();
while (chrono::high_resolution_clock::now() - t1 < chrono::seconds(2)) //run for 5 seconds
{
//Receive samples
int samplesRead = LMS_RecvStream(&streamId, buffer, sampleCnt, NULL, 1000);
//I and Q samples are interleaved in buffer: IQIQIQ…
printf(“Received %d samples\n”, samplesRead);
/*
INSERT CODE FOR PROCESSING RECEIVED SAMPLES
*/
#ifdef USE_GNU_PLOT
//Plot samples
gp.write(“plot ‘-’ with points\n”);
for (int j = 0; j < samplesRead; ++j)
gp.writef("%i %i\n", buffer[2 * j], buffer[2 * j + 1]);
gp.write(“e\n”);
gp.flush();
#endif
}
//Stop streaming
LMS_StopStream(&streamId); //stream is stopped but can be started again with LMS_StartStream()
LMS_DestroyStream(device, &streamId); //stream is deallocated and can no longer be used

//Close device
LMS_Close(device);

return 0;

}[dir:SoftwareDefinedRadio/NetsdrSend-0192/LimeSDR] dir% g++ -std=c++11 -o basicRX basicRX.cpp -lLimeSuite
[dir:SoftwareDefinedRadio/NetsdrSend-0192/LimeSDR] dir% basicRX
Devices found: 1
Reference clock 40.00 MHz
Selected RX path: LNAW
Received 5000 samples
Received 5000 samples
Received 5000 samples
Received 5000 samples
Received 5000 samples
Received 5000 samples
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
Received 0 samples
Received 0 samples
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
libusb: warning [darwin_abort_transfers] aborting all transactions on interface 1 pipe 4
[dir:SoftwareDefinedRadio/NetsdrSend-0192/LimeSDR] dir%