X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Falsa%2Fapi.c;h=42f3210469a49a67c263ff534f3246ffb46691d0;hb=a1b9a9bf44b33ee9f3a6ac5ae59a1ced1e2c3281;hp=a8806fc2f6df044d6f8542fdfe3be6f7d03c26c6;hpb=729850c9e7dfa2c08c11a025d5a54b8e8e803f3c;p=libsigrok.git diff --git a/hardware/alsa/api.c b/hardware/alsa/api.c index a8806fc2..42f32104 100644 --- a/hardware/alsa/api.c +++ b/hardware/alsa/api.c @@ -20,17 +20,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "protocol.h" -#include "libsigrok.h" -#include "libsigrok-internal.h" - #include #include #include - -#define DEFAULT_PROBES 2 -#define SAMPLE_WIDTH 16 -#define DEFAULT_SAMPLERATE 44100 +#include "libsigrok.h" +#include "libsigrok-internal.h" +#include "protocol.h" static const int hwcaps[] = { SR_HWCAP_SAMPLERATE, @@ -171,6 +166,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 +190,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; @@ -209,7 +211,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi, struct sr_datafeed_meta_analog meta; struct dev_context *devc; int count, ret; - char *endianess; + char *endianness; devc = sdi->priv; devc->cb_data = cb_data; @@ -225,10 +227,10 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi, /* FIXME: Hardcoded for 16bits. */ if (SND_PCM_FORMAT_S16 == SND_PCM_FORMAT_S16_LE) - endianess = "lilltle endian"; + endianness = "little endian"; else - endianess = "big endian"; - sr_dbg("Setting audio sample format to signed 16bit (%s).", endianess); + endianness = "big endian"; + sr_dbg("Setting audio sample format to signed 16bit (%s).", endianness); ret = snd_pcm_hw_params_set_format(devc->capture_handle, devc->hw_params, SND_PCM_FORMAT_S16); @@ -274,7 +276,6 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi, sr_err("Unable to obtain poll descriptors count."); return SR_ERR; } - sr_spew("Obtained poll descriptor count: %d.", count); if (!(devc->ufds = g_try_malloc(count * sizeof(struct pollfd)))) { sr_err("Failed to malloc ufds.");