| 56 | // ---------------------------------------------------------------------------------------------------- |
| 57 | |
| 58 | InputDeviceNode::InputDeviceNode( const DeviceRef &device, const Format &format ) |
| 59 | : InputNode( format ), mDevice( device ), mLastOverrun( 0 ), mLastUnderrun( 0 ) |
| 60 | { |
| 61 | if( ! mDevice ) { |
| 62 | string errorMsg = "Empty DeviceRef."; |
| 63 | if( ! audio::Device::getDefaultInput() ) |
| 64 | errorMsg += " Also, no default input Device so perhaps there is no available hardware input."; |
| 65 | |
| 66 | throw AudioDeviceExc( errorMsg ); |
| 67 | } |
| 68 | |
| 69 | size_t deviceNumChannels = mDevice->getNumInputChannels(); |
| 70 | |
| 71 | // If number of channels hasn't been specified, default to 2. |
| 72 | if( getChannelMode() != ChannelMode::SPECIFIED ) { |
| 73 | setChannelMode( ChannelMode::SPECIFIED ); |
| 74 | setNumChannels( std::min( deviceNumChannels, (size_t)2 ) ); |
| 75 | } |
| 76 | |
| 77 | // TODO: this doesn't always mean a failing cause, need Device::supportsNumInputChannels( mNumChannels ) to be sure |
| 78 | // - on iOS, the RemoteIO audio unit can have 2 input channels, while the AVAudioSession reports only 1 input channel. |
| 79 | // if( deviceNumChannels < mNumChannels ) |
| 80 | // throw AudioFormatExc( string( "Device can not accommodate " ) + to_string( deviceNumChannels ) + " output channels." ); |
| 81 | } |
| 82 | |
| 83 | InputDeviceNode::~InputDeviceNode() |
| 84 | { |
nothing calls this directly
no test coverage detected