- // TODO: Worry about hotplug.
- struct Device {
- std::string address; // E.g. “hw:0,0”.
- std::string name, info;
- unsigned num_channels;
- };
- static std::vector<Device> enumerate_devices();
+ // Set access, sample rate and format parameters on the given ALSA PCM handle.
+ // Returns the computed parameter set and the chosen sample rate. Note that
+ // sample_rate is an in/out parameter; you send in the desired rate,
+ // and ALSA picks one as close to that as possible.
+ static bool set_base_params(const char *device_name, snd_pcm_t *pcm_handle, snd_pcm_hw_params_t *hw_params, unsigned *sample_rate);