| 81 | // ---------------------------------------------------------------------------------------------------- |
| 82 | |
| 83 | OutputDeviceNode::OutputDeviceNode( const DeviceRef &device, const Format &format ) |
| 84 | : OutputNode( format ), mDevice( device ) |
| 85 | { |
| 86 | if( ! mDevice ) { |
| 87 | string errorMsg = "Empty DeviceRef."; |
| 88 | if( ! audio::Device::getDefaultOutput() ) |
| 89 | errorMsg += " Also, no default output Device so perhaps there is no available hardware output."; |
| 90 | |
| 91 | throw AudioDeviceExc( errorMsg ); |
| 92 | } |
| 93 | |
| 94 | // listen to the notifications sent by device property changes in order to update the audio graph. |
| 95 | mWillChangeConn = mDevice->getSignalParamsWillChange().connect( bind( &OutputDeviceNode::deviceParamsWillChange, this ) ); |
| 96 | mDidChangeConn = mDevice->getSignalParamsDidChange().connect( bind( &OutputDeviceNode::deviceParamsDidChange, this ) ); |
| 97 | |
| 98 | mInterruptionBeganConn = Context::deviceManager()->getSignalInterruptionBegan().connect( [this] { disable(); } ); |
| 99 | mInterruptionEndedConn = Context::deviceManager()->getSignalInterruptionEnded().connect( [this] { enable(); } ); |
| 100 | |
| 101 | size_t deviceNumChannels = mDevice->getNumOutputChannels(); |
| 102 | |
| 103 | // If number of channels hasn't been specified, default to 2 (or 1 if that is all that is available). |
| 104 | if( getChannelMode() != ChannelMode::SPECIFIED ) { |
| 105 | setChannelMode( ChannelMode::SPECIFIED ); |
| 106 | setNumChannels( std::min( deviceNumChannels, (size_t)2 ) ); |
| 107 | } |
| 108 | |
| 109 | // Double check the device has enough channels to support what was requested, which may not be the case if the user asked for more than what is available. |
| 110 | if( deviceNumChannels < getNumChannels() ) |
| 111 | throw AudioFormatExc( string( "Device can not accommodate " ) + to_string( deviceNumChannels ) + " output channels." ); |
| 112 | } |
| 113 | |
| 114 | void OutputDeviceNode::deviceParamsWillChange() |
| 115 | { |
nothing calls this directly
no test coverage detected