MCPcopy Create free account
hub / github.com/VCVRack/Rack / setDeviceId

Method setDeviceId

src/audio.cpp:157–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157void Port::setDeviceId(int deviceId) {
158 if (!driver)
159 return;
160 if (deviceId == this->deviceId)
161 return;
162 // Destroy device
163 if (this->deviceId >= 0) {
164 try {
165 driver->unsubscribe(this->deviceId, this);
166 onStopStream();
167 }
168 catch (Exception& e) {
169 WARN("Audio port could not unsubscribe from device: %s", e.what());
170 }
171 }
172 device = NULL;
173 this->deviceId = -1;
174
175 // Create device
176 if (deviceId >= 0) {
177 try {
178 device = driver->subscribe(deviceId, this);
179 if (device) {
180 this->deviceId = deviceId;
181 onStartStream();
182 }
183 }
184 catch (Exception& e) {
185 WARN("Audio port could not subscribe to device: %s", e.what());
186 }
187 }
188}
189
190int Port::getDeviceNumInputs(int deviceId) {
191 if (!driver)

Callers

nothing calls this directly

Calls 3

whatMethod · 0.80
unsubscribeMethod · 0.45
subscribeMethod · 0.45

Tested by

no test coverage detected