13
0

allow to scan for half-duplex ALSA devices

This commit is contained in:
Robin Gareus 2015-06-14 22:16:31 +02:00
parent 94c146c780
commit acd95215a4
2 changed files with 11 additions and 4 deletions

View File

@ -23,8 +23,13 @@
#include <string>
#include <map>
namespace ARDOUR {
enum AlsaDuplex {
HalfDuplexIn = 1,
HalfDuplexOut = 2,
FullDuplex = 3,
};
void get_alsa_audio_device_names (std::map<std::string, std::string>& devices);
void get_alsa_audio_device_names (std::map<std::string, std::string>& devices, AlsaDuplex duplex = FullDuplex);
void get_alsa_rawmidi_device_names (std::map<std::string, std::string>& devices);
void get_alsa_sequencer_names (std::map<std::string, std::string>& devices);
int card_to_num(const char* device_name);

View 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 += ',';