#include <mutex>
#include <set>
#include <string>
+#include <utility>
#include <vector>
#include "alsa_pool.h"
+#include "card_type.h"
#include "correlation_measurer.h"
#include "decibel.h"
#include "defs.h"
#include "input_mapping.h"
#include "resampling_queue.h"
#include "stereocompressor.h"
+#include "shared/shared_defs.h"
class DeviceSpecProto;
struct AudioFormat;
} // namespace bmusb
+// Convert the given audio from {16,24,32}-bit M-channel to 32-bit N-channel PCM.
+// Assumes little-endian and chunky, signed PCM throughout.
+std::vector<int32_t> convert_audio_to_fixed32(const uint8_t *data, unsigned num_samples, bmusb::AudioFormat audio_format, unsigned num_destination_channels);
+
enum EQBand {
EQ_BAND_BASS = 0,
EQ_BAND_MID,
class AudioMixer {
public:
- AudioMixer(unsigned num_capture_cards, unsigned num_ffmpeg_inputs);
+ AudioMixer();
void reset_resampler(DeviceSpec device_spec);
void reset_meters();
return DeviceSpec{InputSourceType::ALSA_INPUT, dead_card_index};
}
- void set_display_name(DeviceSpec device_spec, const std::string &name);
+ // NOTE: The display name is not overridden if active == false.
+ void set_device_parameters(DeviceSpec device_spec, const std::string &display_name, CardType card_type, unsigned num_channels, bool active);
+ bool get_active(DeviceSpec device_spec);
// Note: The card should be held (currently this isn't enforced, though).
void serialize_device(DeviceSpec device_spec, DeviceSpecProto *device_spec_proto);
// Which channels we consider interesting (ie., are part of some input_mapping).
std::set<unsigned> interesting_channels;
bool silenced = false;
+ CardType card_type;
+ unsigned num_channels = 2; // Ignored for ALSA cards, which check the device directly.
+ bool active = false; // Only really relevant for capture cards (not ALSA cards).
};
const AudioDevice *find_audio_device(DeviceSpec device_spec) const
void send_audio_level_callback();
std::vector<DeviceSpec> get_active_devices() const;
void set_input_mapping_lock_held(const InputMapping &input_mapping);
-
- unsigned num_capture_cards, num_ffmpeg_inputs;
+ std::string spec_to_string(DeviceSpec device_spec) const;
mutable std::timed_mutex audio_mutex;
ALSAPool alsa_pool;
AudioDevice video_cards[MAX_VIDEO_CARDS]; // Under audio_mutex.
AudioDevice alsa_inputs[MAX_ALSA_CARDS]; // Under audio_mutex.
- std::unique_ptr<AudioDevice[]> ffmpeg_inputs; // Under audio_mutex.
std::atomic<float> locut_cutoff_hz{120};
StereoFilter locut[MAX_BUSES]; // Default cutoff 120 Hz, 24 dB/oct.