1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-02 06:04:39 -04:00

HackRF: use DeviceHackRF as a singleton to handle HackRF library init and exit only once

This commit is contained in:
f4exb
2017-09-01 00:46:43 +02:00
parent afe08a3547
commit ec3a99451c
4 changed files with 50 additions and 38 deletions
@@ -56,12 +56,12 @@ void HackRFOutputPlugin::initPlugin(PluginAPI* pluginAPI)
PluginInterface::SamplingDevices HackRFOutputPlugin::enumSampleSinks()
{
hackrf_error rc = (hackrf_error) hackrf_init();
if (rc != HACKRF_SUCCESS)
{
qCritical("HackRFOutputPlugin::enumSampleSinks: failed to initiate HackRF library: %s", hackrf_error_name(rc));
}
// hackrf_error rc = (hackrf_error) hackrf_init();
//
// if (rc != HACKRF_SUCCESS)
// {
// qCritical("HackRFOutputPlugin::enumSampleSinks: failed to initiate HackRF library: %s", hackrf_error_name(rc));
// }
SamplingDevices result;
hackrf_device_list_t *hackrf_devices = hackrf_device_list();
@@ -71,7 +71,7 @@ PluginInterface::SamplingDevices HackRFOutputPlugin::enumSampleSinks()
for (i=0; i < hackrf_devices->devicecount; i++)
{
rc = (hackrf_error) hackrf_device_list_open(hackrf_devices, i, &hackrf_ptr);
hackrf_error rc = (hackrf_error) hackrf_device_list_open(hackrf_devices, i, &hackrf_ptr);
if (rc == HACKRF_SUCCESS)
{
@@ -110,8 +110,8 @@ PluginInterface::SamplingDevices HackRFOutputPlugin::enumSampleSinks()
}
hackrf_device_list_free(hackrf_devices);
rc = (hackrf_error) hackrf_exit();
qDebug("HackRFOutputPlugin::enumSampleSinks: hackrf_exit: %s", hackrf_error_name(rc));
// rc = (hackrf_error) hackrf_exit();
// qDebug("HackRFOutputPlugin::enumSampleSinks: hackrf_exit: %s", hackrf_error_name(rc));
return result;
}