Digital Input on USB Interface & Automatic Input Switching

I’m doing some programming with Portaudio. I’m using a USB audio interface with an ADC providing 2 analogue input channels and also an S/P DIF input.
When using Audacity there is some automatic input switching going on. I select the USB interface as the chosen capture device. If there is audio present on the digital input then this is recorded, if not then the analogue inputs are used. This switching occurs automatically and even switches during recording.
I initially assumed this switch was in my USB audio interface rather than in software such as audacity but in my own Portaudio application I am only reading the analogue inputs.
The PaDeviceInfo for my audio interface reveals that the maximum number of inputs is 2. I open a stream on this device with the input parameter PaStreamParameters::channelCount set to 2 and it reads from the analogue inputs. I can’t see anywhere how to select which input channels you access in the Portaudio API.
If anyone can help me or point me to the part of audacity source code which selects which input channels it reads I would much appreciate it.
Thanks
Chris

Here is the output from the pa_devs app for this device:
--------------------------------------- device #3
Name = USB Audio CODEC : USB Audio (hw:1,0)
Host API = ALSA
Max inputs = 2, Max outputs = 2
Default low input latency = 0.012
Default low output latency = 0.012
Default high input latency = 0.046
Default high output latency = 0.046
Default sample rate = 44100.00
Supported standard sample rates
for half-duplex 16 bit 2 channel input =
11025.00, 16000.00, 22050.00, 32000.00,
44100.00, 48000.00
Supported standard sample rates
for half-duplex 16 bit 2 channel output =
32000.00, 44100.00, 48000.00
Supported standard sample rates
for full-duplex 16 bit 2 channel input, 2 channel output =
32000.00, 44100.00, 48000.00

What version number of Audacity? What make of USB interface? Is it a mixer device (can you choose between analogue and S/PDIF in Mixer Toolbar)? Can you choose between them in ALSAmixer?

The best place to ask about PortAudio and Audacity is on the audacity-devel subscription mailing list.



Gale