]> sigrok.org Git - libsigrok.git/blobdiff - hardware/alsa/api.c
alsa: Find supported samplerates during device scan
[libsigrok.git] / hardware / alsa / api.c
index a8806fc2f6df044d6f8542fdfe3be6f7d03c26c6..48a97cd4319d445a35a2f230160236100a5d5feb 100644 (file)
 #include <unistd.h>
 #include <string.h>
 
-#define DEFAULT_PROBES         2
-#define SAMPLE_WIDTH           16
-#define DEFAULT_SAMPLERATE     44100
-
 static const int hwcaps[] = {
        SR_HWCAP_SAMPLERATE,
        SR_HWCAP_LIMIT_SAMPLES,
@@ -171,6 +167,13 @@ static int hw_info_get(int info_id, const void **data,
        case SR_DI_CUR_SAMPLERATE:
                *data = &devc->cur_samplerate;
                break;
+       case SR_DI_SAMPLERATES:
+               if (!devc->supp_rates.list) {
+                       sr_err("Instance did not contain a samplerate list");
+                       return SR_ERR_ARG;
+               }
+               *data = &devc->supp_rates;
+               break;
        default:
                sr_err("Invalid info_id: %d.", info_id);
                return SR_ERR_ARG;
@@ -188,7 +191,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
 
        switch (hwcap) {
        case SR_HWCAP_SAMPLERATE:
-               devc->cur_samplerate = *(const uint64_t *)value;
+               alsa_set_samplerate(sdi, *(const uint64_t *)value);
                break;
        case SR_HWCAP_LIMIT_SAMPLES:
                devc->limit_samples = *(const uint64_t *)value;