Don't directly read static device

This commit is contained in:
Greg Shuflin 2021-02-28 23:52:03 -08:00
parent 8f544cfa95
commit 7fbcba54fd
1 changed files with 13 additions and 4 deletions

17
radio.c
View File

@ -61,7 +61,15 @@ radio_tab_t* get_radio_tab() {
return radio_tab;
}
static radio_device_t *device; // Device-dependent interface
static radio_device_t *active_device; // Device-dependent interface
radio_device_t* get_active_device() {
return active_device;
}
void set_active_device(radio_device_t* d) {
active_device = d;
}
unsigned char radio_mem [1024*1024*2]; // Radio memory contents, up to 2 Mbytes
int radio_progress; // Read/write progress counter
@ -113,7 +121,7 @@ radio_device_t* radio_connect()
}
fprintf(stderr, "Connect to %s.\n", dev->name);
device = dev;
set_active_device(dev);
return dev;
}
@ -235,7 +243,7 @@ radio_device_t* radio_read_image(const char *filename)
dev->read_image(dev, img);
fclose(img);
device = dev;
set_active_device(dev);
return dev;
}
@ -400,11 +408,12 @@ void radio_write_csv(radio_device_t* device, const char *filename)
//
int radio_is_compatible(const char *name)
{
radio_device_t* dev = get_active_device();
int i;
for (i=0; radio_tab[i].ident; i++) {
// Radio is compatible when it has the same parse routine.
if (device->parse_parameter == radio_tab[i].device->parse_parameter &&
if (dev->parse_parameter == radio_tab[i].device->parse_parameter &&
strcasecmp(name, radio_tab[i].device->name) == 0) {
return 1;
}