]> git.sesse.net Git - nageru/commitdiff
Small cleanup in AudioMixer::set_input_mapping().
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 7 Aug 2016 18:28:04 +0000 (20:28 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 19 Oct 2016 22:55:44 +0000 (00:55 +0200)
audio_mixer.cpp
audio_mixer.h

index 88ca8c617a8559ce771e21f1e337133bba51296c..db4b24d9bb0fdd6d3186b56daf968572911c2b26 100644 (file)
@@ -419,13 +419,12 @@ void AudioMixer::set_input_mapping(const InputMapping &new_input_mapping)
 {
        lock_guard<mutex> lock(audio_mutex);
 
-       // FIXME: This needs to be keyed on DeviceSpec.
-       map<unsigned, set<unsigned>> interesting_channels;
+       map<DeviceSpec, set<unsigned>> interesting_channels;
        for (const InputMapping::Bus &bus : new_input_mapping.buses) {
                if (bus.device.type == InputSourceType::CAPTURE_CARD) {
                        for (unsigned channel = 0; channel < 2; ++channel) {
                                if (bus.source_channel[channel] != -1) {
-                                       interesting_channels[bus.device.index].insert(bus.source_channel[channel]);
+                                       interesting_channels[bus.device].insert(bus.source_channel[channel]);
                                }
                        }
                }
@@ -433,9 +432,10 @@ void AudioMixer::set_input_mapping(const InputMapping &new_input_mapping)
 
        // Reset resamplers for all cards that don't have the exact same state as before.
        for (unsigned card_index = 0; card_index < num_cards; ++card_index) {
+               DeviceSpec device_spec{InputSourceType::CAPTURE_CARD, card_index};
                AudioDevice *device = &cards[card_index];
-               if (device->interesting_channels != interesting_channels[card_index]) {
-                       device->interesting_channels = interesting_channels[card_index];
+               if (device->interesting_channels != interesting_channels[device_spec]) {
+                       device->interesting_channels = interesting_channels[device_spec];
                        reset_device_mutex_held(DeviceSpec{InputSourceType::CAPTURE_CARD, card_index});
                }
        }
index 93c9beb375768c3ed1707b8c8fec764bda017400..5ea79dea73713c82c6400c7855d53380cd3d844f 100644 (file)
@@ -35,6 +35,12 @@ enum class InputSourceType { SILENCE, CAPTURE_CARD };
 struct DeviceSpec {
        InputSourceType type;
        unsigned index;
+
+       bool operator< (const DeviceSpec &other) const {
+               if (type != other.type)
+                       return type < other.type;
+               return index < other.index;
+       }
 };
 
 struct InputMapping {