MCPcopy Create free account
hub / github.com/cinder/Cinder / OutputDeviceNode

Method OutputDeviceNode

src/cinder/audio/OutputNode.cpp:83–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81// ----------------------------------------------------------------------------------------------------
82
83OutputDeviceNode::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
114void OutputDeviceNode::deviceParamsWillChange()
115{

Callers

nothing calls this directly

Calls 10

getChannelModeFunction · 0.85
stringFunction · 0.85
bindFunction · 0.50
disableFunction · 0.50
enableFunction · 0.50
minFunction · 0.50
getNumChannelsFunction · 0.50
to_stringFunction · 0.50
connectMethod · 0.45
getNumOutputChannelsMethod · 0.45

Tested by

no test coverage detected