Crapola - this is an experimental performance hack that must be reverted.
[ardour.git] / libs / ardouralsautil / devicelist.cc
index b20df100dbd49aa37d08a9f60828805e8082b647..f642733182f1926e8f025620498e83f32b53a705 100644 (file)
  */
 
 #include <alsa/asoundlib.h>
+#include <glib.h>
+
 #include "pbd/convert.h"
 #include "ardouralsautil/devicelist.h"
 
 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;
@@ -34,6 +36,14 @@ ARDOUR::get_alsa_audio_device_names (std::map<std::string, std::string>& devices
        string devname;
        int cardnum = -1;
        int device = -1;
+       const char* fixed_name;
+
+       if ((fixed_name = g_getenv ("ARDOUR_ALSA_DEVICE"))) {
+               devices.insert (make_pair<string,string> (fixed_name, fixed_name));
+               return;
+       }
+
+       assert (duplex > 0);
 
        while (snd_card_next (&cardnum) >= 0 && cardnum >= 0) {
 
@@ -63,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_CAPTURE);
 
-                               if (snd_ctl_pcm_info (handle, pcminfo) < 0) {
+                               if (snd_ctl_pcm_info (handle, pcminfo) < 0 && (duplex & HalfDuplexIn)) {
                                        continue;
                                }
 
@@ -71,7 +81,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 += ',';