X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=alsa_input.h;h=84e46b0887707dd6b273419d29cf2fada00c43d7;hb=1fc8b5d92fce7ac0b7e87ed3087e393774fd4b3c;hp=724b64011749f01bc554cb720e3c095473113c3c;hpb=7460e2f2d678c9255afe914c1988f14c87798727;p=nageru diff --git a/alsa_input.h b/alsa_input.h index 724b640..84e46b0 100644 --- a/alsa_input.h +++ b/alsa_input.h @@ -22,7 +22,7 @@ class ALSAInput { public: - typedef std::function audio_callback_t; + typedef std::function audio_callback_t; ALSAInput(const char *device, unsigned sample_rate, unsigned num_channels, audio_callback_t audio_callback); ~ALSAInput(); @@ -34,10 +34,19 @@ public: void start_capture_thread(); void stop_capture_thread(); + // TODO: Worry about hotplug. + struct Device { + std::string address; // E.g. “hw:0,0”. + std::string name, info; + unsigned num_channels; + }; + static std::vector enumerate_devices(); + private: void capture_thread_func(); int64_t frames_to_pts(uint64_t n) const; void die_on_error(const char *func_name, int err); + static bool set_base_params(const char *device, snd_pcm_t *pcm_handle, snd_pcm_hw_params_t *hw_params, unsigned *sample_rate); std::string device; unsigned sample_rate, num_channels, num_periods;