alsa: Use std_dev_clear().

This commit is contained in:
Uwe Hermann 2013-05-31 15:28:43 +02:00
parent fa85f37630
commit c43cf4d40e
3 changed files with 12 additions and 31 deletions

View File

@ -36,17 +36,19 @@ static const int32_t hwcaps[] = {
SR_PRIV struct sr_dev_driver alsa_driver_info;
static struct sr_dev_driver *di = &alsa_driver_info;
static void clear_helper(void *priv)
{
struct dev_context *devc;
devc = priv;
snd_pcm_hw_params_free(devc->hw_params);
g_free((void *)devc->samplerates);
}
static int clear_instances(void)
{
struct drv_context *drvc;
if (!(drvc = di->priv))
return SR_OK;
g_slist_free_full(drvc->instances, (GDestroyNotify)alsa_dev_inst_clear);
drvc->instances = NULL;
return SR_OK;
return std_dev_clear(di, clear_helper);
}
static int init(struct sr_context *sr_ctx)
@ -121,9 +123,7 @@ static int dev_close(struct sr_dev_inst *sdi)
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)

View File

@ -282,22 +282,6 @@ SR_PRIV GSList *alsa_scan(GSList *options, struct sr_dev_driver *di)
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.
*

View File

@ -52,11 +52,8 @@ struct dev_context {
};
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