mirror of https://github.com/drowe67/librtlsdr.git
Add "volatile" to two fields of rtlsdr_dev
librtlsdr uses two fileds of struct rtlsdr_dev to communicate between threads. On hardware with weak memory model it is not guaranteed that it will work, as C memory model guarantees nothing for simple variables. Using C11 atomics seems to be overkill here, but async_status and async_cancel better be marked as "volatile".development
parent
b09c635885
commit
037d192d76
|
@ -191,8 +191,8 @@ struct rtlsdr_dev {
|
||||||
unsigned char **xfer_buf;
|
unsigned char **xfer_buf;
|
||||||
rtlsdr_read_async_cb_t cb;
|
rtlsdr_read_async_cb_t cb;
|
||||||
void *cb_ctx;
|
void *cb_ctx;
|
||||||
enum rtlsdr_async_status async_status;
|
volatile enum rtlsdr_async_status async_status;
|
||||||
int async_cancel;
|
volatile int async_cancel;
|
||||||
int use_zerocopy;
|
int use_zerocopy;
|
||||||
/* rtl demod context */
|
/* rtl demod context */
|
||||||
uint32_t rate; /* Hz */
|
uint32_t rate; /* Hz */
|
||||||
|
@ -3539,7 +3539,7 @@ int rtlsdr_read_async(rtlsdr_dev_t *dev, rtlsdr_read_async_cb_t cb, void *ctx,
|
||||||
|
|
||||||
while (RTLSDR_INACTIVE != dev->async_status) {
|
while (RTLSDR_INACTIVE != dev->async_status) {
|
||||||
r = libusb_handle_events_timeout_completed(dev->ctx, &tv,
|
r = libusb_handle_events_timeout_completed(dev->ctx, &tv,
|
||||||
&dev->async_cancel);
|
(int *)&dev->async_cancel);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
/*fprintf(stderr, "handle_events returned: %d\n", r);*/
|
/*fprintf(stderr, "handle_events returned: %d\n", r);*/
|
||||||
if (r == LIBUSB_ERROR_INTERRUPTED) /* stray signal */
|
if (r == LIBUSB_ERROR_INTERRUPTED) /* stray signal */
|
||||||
|
|
Loading…
Reference in New Issue