+ void reset_resampler(DeviceSpec device_spec);
+ void reset_meters();
+
+ // Add audio (or silence) to the given device's queue. Can return false if
+ // the lock wasn't successfully taken; if so, you should simply try again.
+ // (This is to avoid a deadlock where a card hangs on the mutex in add_audio()
+ // while we are trying to shut it down from another thread that also holds
+ // the mutex.) frame_length is in TIMEBASE units.
+ bool add_audio(DeviceSpec device_spec, const uint8_t *data, unsigned num_samples, bmusb::AudioFormat audio_format, int64_t frame_length, std::chrono::steady_clock::time_point frame_time);
+ bool add_silence(DeviceSpec device_spec, unsigned samples_per_frame, unsigned num_frames, int64_t frame_length);
+
+ // If a given device is offline for whatever reason and cannot deliver audio
+ // (by means of add_audio() or add_silence()), you can call put it in silence mode,
+ // where it will be taken to only output silence. Note that when taking it _out_
+ // of silence mode, the resampler will be reset, so that old audio will not
+ // affect it. Same true/false behavior as add_audio().
+ bool silence_card(DeviceSpec device_spec, bool silence);
+
+ std::vector<float> get_output(std::chrono::steady_clock::time_point ts, unsigned num_samples, ResamplingQueue::RateAdjustmentPolicy rate_adjustment_policy);
+
+ float get_fader_volume(unsigned bus_index) const { return fader_volume_db[bus_index]; }
+ void set_fader_volume(unsigned bus_index, float level_db) { fader_volume_db[bus_index] = level_db; }
+
+ bool get_mute(unsigned bus_index) const { return mute[bus_index]; }
+ void set_mute(unsigned bus_index, bool muted) { mute[bus_index] = muted; }
+
+ // Note: This operation holds all ALSA devices (see ALSAPool::get_devices()).
+ // You will need to call set_input_mapping() to get the hold state correctly,
+ // or every card will be held forever.
+ std::map<DeviceSpec, DeviceInfo> get_devices();
+
+ // See comments on ALSAPool::get_card_state().
+ ALSAPool::Device::State get_alsa_card_state(unsigned index)
+ {
+ return alsa_pool.get_card_state(index);
+ }
+
+ // See comments on ALSAPool::create_dead_card().
+ DeviceSpec create_dead_card(const std::string &name, const std::string &info, unsigned num_channels)
+ {
+ unsigned dead_card_index = alsa_pool.create_dead_card(name, info, num_channels);
+ return DeviceSpec{InputSourceType::ALSA_INPUT, dead_card_index};
+ }
+
+ void set_display_name(DeviceSpec device_spec, const std::string &name);
+
+ // Note: The card should be held (currently this isn't enforced, though).
+ void serialize_device(DeviceSpec device_spec, DeviceSpecProto *device_spec_proto);
+
+ enum class MappingMode {
+ // A single bus, only from a video card (no ALSA devices),
+ // only channel 1 and 2, locked to +0 dB. Note that this is
+ // only an UI abstraction around exactly the same audio code
+ // as MULTICHANNEL; it's just less flexible.
+ SIMPLE,
+
+ // Full, arbitrary mappings.
+ MULTICHANNEL
+ };
+
+ // Automatically sets mapping mode to MappingMode::SIMPLE.
+ void set_simple_input(unsigned card_index);