SR_PRIV struct sr_dev_driver alsa_driver_info;
static struct sr_dev_driver *di = &alsa_driver_info;
-static int clear_instances(void)
+static void clear_helper(void *priv)
{
- struct drv_context *drvc;
+ struct dev_context *devc;
- if (!(drvc = di->priv))
- return SR_OK;
+ devc = priv;
- g_slist_free_full(drvc->instances, (GDestroyNotify)alsa_dev_inst_clear);
- drvc->instances = NULL;
+ snd_pcm_hw_params_free(devc->hw_params);
+ g_free((void *)devc->samplerates);
+}
- return SR_OK;
+static int clear_instances(void)
+{
+ return std_dev_clear(di, clear_helper);
}
static int init(struct sr_context *sr_ctx)
static int cleanup(void)
{
- clear_instances();
-
- return SR_OK;
+ return clear_instances();
}
static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi)
return devices;
}
-/*
- * Helper to be used with g_slist_free_full(); for properly freeing an alsa
- * dev instance.
- */
-SR_PRIV void alsa_dev_inst_clear(struct sr_dev_inst *sdi)
-{
- struct dev_context *devc;
-
- if (!(devc = sdi->priv))
- return;
-
- snd_pcm_hw_params_free(devc->hw_params);
- g_free((void*)devc->samplerates);
- sr_dev_inst_free(sdi);
-}
-
/**
* Set the samplerate of the ALSA device.
*
};
SR_PRIV GSList *alsa_scan(GSList *options, struct sr_dev_driver *di);
-SR_PRIV void alsa_dev_inst_clear(struct sr_dev_inst *sdi);
-
SR_PRIV int alsa_set_samplerate(const struct sr_dev_inst *sdi,
uint64_t newrate);
-
SR_PRIV int alsa_receive_data(int fd, int revents, void *cb_data);
#endif