X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Falsa%2Fapi.c;h=0f54eb48cc228384f6257eeb73ef6a145d59478e;hb=2a0f6924d2c8f3b203560ba0086e9d297855677a;hp=2d4da2631ec4c4dff483795dcc72d43cb74004b9;hpb=f6beaac55ca58c406d6621038abe57c16a47e87f;p=libsigrok.git diff --git a/hardware/alsa/api.c b/hardware/alsa/api.c index 2d4da263..0f54eb48 100644 --- a/hardware/alsa/api.c +++ b/hardware/alsa/api.c @@ -43,10 +43,13 @@ static void clear_helper(void *priv) devc = priv; snd_pcm_hw_params_free(devc->hw_params); + devc->hw_params = NULL; + g_free((void *)devc->samplerates); + devc->samplerates = NULL; } -static int clear_instances(void) +static int dev_clear(void) { return std_dev_clear(di, clear_helper); } @@ -108,12 +111,11 @@ static int dev_close(struct sr_dev_inst *sdi) if (devc->capture_handle) { sr_dbg("Closing PCM device."); - if ((ret = snd_pcm_close(devc->capture_handle)) < 0) { + if ((ret = snd_pcm_close(devc->capture_handle)) < 0) sr_err("Failed to close device: %s.", snd_strerror(ret)); - devc->capture_handle = NULL; - sdi->status = SR_ST_INACTIVE; - } + devc->capture_handle = NULL; + sdi->status = SR_ST_INACTIVE; } else { sr_dbg("No capture handle, no need to close audio device."); } @@ -123,13 +125,16 @@ static int dev_close(struct sr_dev_inst *sdi) static int cleanup(void) { - return clear_instances(); + return dev_clear(); } -static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi) +static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, + const struct sr_probe_group *probe_group) { struct dev_context *devc; + (void)probe_group; + switch (id) { case SR_CONF_SAMPLERATE: devc = sdi->priv; @@ -142,10 +147,13 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi) return SR_OK; } -static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) +static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi, + const struct sr_probe_group *probe_group) { struct dev_context *devc; + (void)probe_group; + if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; @@ -165,13 +173,16 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi) return SR_OK; } -static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi) +static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, + const struct sr_probe_group *probe_group) { struct dev_context *devc; GVariant *gvar; GVariantBuilder gvb; int i; + (void)probe_group; + switch (key) { case SR_CONF_DEVICE_OPTIONS: *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, @@ -325,7 +336,7 @@ SR_PRIV struct sr_dev_driver alsa_driver_info = { .cleanup = cleanup, .scan = scan, .dev_list = dev_list, - .dev_clear = clear_instances, + .dev_clear = dev_clear, .config_get = config_get, .config_set = config_set, .config_list = config_list,