allow to scan for half-duplex ALSA devices
[ardour.git] / libs / ardouralsautil / devicelist.cc
index b20df100dbd49aa37d08a9f60828805e8082b647..3fdb1401af17338fabc8cb98597145d4af9359f5 100644 (file)
@@ -24,7 +24,7 @@
 using namespace std;
 
 void
-ARDOUR::get_alsa_audio_device_names (std::map<std::string, std::string>& devices)
+ARDOUR::get_alsa_audio_device_names (std::map<std::string, std::string>& devices, AlsaDuplex duplex)
 {
        snd_ctl_t *handle;
        snd_ctl_card_info_t *info;
@@ -35,6 +35,8 @@ ARDOUR::get_alsa_audio_device_names (std::map<std::string, std::string>& devices
        int cardnum = -1;
        int device = -1;
 
+       assert (duplex > 0);
+
        while (snd_card_next (&cardnum) >= 0 && cardnum >= 0) {
 
                devname = "hw:";
@@ -63,7 +65,7 @@ ARDOUR::get_alsa_audio_device_names (std::map<std::string, std::string>& devices
                                snd_pcm_info_set_subdevice (pcminfo, 0);
                                snd_pcm_info_set_stream (pcminfo, SND_PCM_STREAM_CAPTURE);
 
-                               if (snd_ctl_pcm_info (handle, pcminfo) < 0) {
+                               if (snd_ctl_pcm_info (handle, pcminfo) < 0 && (duplex & HalfDuplexIn)) {
                                        continue;
                                }
 
@@ -71,7 +73,7 @@ ARDOUR::get_alsa_audio_device_names (std::map<std::string, std::string>& devices
                                snd_pcm_info_set_subdevice (pcminfo, 0);
                                snd_pcm_info_set_stream (pcminfo, SND_PCM_STREAM_PLAYBACK);
 
-                               if (snd_ctl_pcm_info (handle, pcminfo) < 0) {
+                               if (snd_ctl_pcm_info (handle, pcminfo) < 0 && (duplex & HalfDuplexOut)) {
                                        continue;
                                }
                                devname += ',';