Fix name_to_device

Add "direction" argument to to SoundPort::name_to_device() to ensure
that it returns the right type of device.
pull/2/head
Stelios Bounanos 2010-02-24 01:02:19 +00:00
rodzic 1c18ad2c7b
commit df7caff4c2
2 zmienionych plików z 6 dodań i 6 usunięć

Wyświetl plik

@ -200,7 +200,7 @@ private:
void src_data_reset(unsigned dir);
static long src_read_cb(void* arg, float** data);
size_t resample_write(float* buf, size_t count);
device_iterator name_to_device(const std::string& name);
device_iterator name_to_device(const std::string& name, unsigned dir);
void init_stream(unsigned dir);
void start_stream(unsigned dir);
void pause_stream(unsigned dir);

Wyświetl plik

@ -863,10 +863,10 @@ int SoundPort::Open(int mode, int freq)
// initialize stream if it is a JACK device, regardless of mode
device_iterator idev;
if (mode == O_WRONLY && (idev = name_to_device(sd[0].device)) != devs.end() &&
if (mode == O_WRONLY && (idev = name_to_device(sd[0].device, 0)) != devs.end() &&
Pa_GetHostApiInfo((*idev)->hostApi)->type == paJACK)
mode = O_RDWR;
if (mode == O_RDONLY && (idev = name_to_device(sd[1].device)) != devs.end() &&
if (mode == O_RDONLY && (idev = name_to_device(sd[1].device, 1)) != devs.end() &&
Pa_GetHostApiInfo((*idev)->hostApi)->type == paJACK)
mode = O_RDWR;
@ -1255,11 +1255,11 @@ long SoundPort::src_read_cb(void* arg, float** data)
return vec[0].len / sd[0].params.channelCount;
}
SoundPort::device_iterator SoundPort::name_to_device(const string& name)
SoundPort::device_iterator SoundPort::name_to_device(const string& name, unsigned dir)
{
device_iterator i;
for (i = devs.begin(); i != devs.end(); ++i)
if (name == (*i)->name)
if (name == (*i)->name && (dir ? (*i)->maxOutputChannels : (*i)->maxInputChannels))
break;
return i;
}
@ -1271,7 +1271,7 @@ void SoundPort::init_stream(unsigned dir)
LOG_DEBUG("looking for device \"%s\"", sd[dir].device.c_str());
if ((sd[dir].idev = name_to_device(sd[dir].device)) != devs.end())
if ((sd[dir].idev = name_to_device(sd[dir].device, dir)) != devs.end())
idx = sd[dir].idev - devs.begin();
if (idx == paNoDevice) { // no match
LOG_ERROR("Could not find device \"%s\", using default device", sd[dir].device.c_str());