MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / setInputChannelConfig

Method setInputChannelConfig

app/src/API/Handlers/AudioHandler.cpp:252–278  ·  view source on GitHub ↗

* @brief Set input channel configuration */

Source from the content-addressed store, hash-verified

250 * @brief Set input channel configuration
251 */
252API::CommandResponse API::Handlers::AudioHandler::setInputChannelConfig(const QString& id,
253 const QJsonObject& params)
254{
255 if (!params.contains(QStringLiteral("channelIndex"))) {
256 return CommandResponse::makeError(
257 id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: channelIndex"));
258 }
259
260 const int channel_index = params.value(QStringLiteral("channelIndex")).toInt();
261
262 const auto& channels = IO::ConnectionManager::instance().audio()->inputChannelConfigurations();
263 if (channel_index < 0 || channel_index >= channels.count()) {
264 return CommandResponse::makeError(
265 id,
266 ErrorCode::InvalidParam,
267 QString(QStringLiteral("Invalid channelIndex: %1. Valid range: 0-%2"))
268 .arg(channel_index)
269 .arg(channels.count() - 1));
270 }
271
272 IO::ConnectionManager::instance().audio()->setSelectedInputChannelConfiguration(channel_index);
273
274 QJsonObject result;
275 result[QStringLiteral("channelIndex")] = channel_index;
276 result[QStringLiteral("channelName")] = channels.at(channel_index);
277 return CommandResponse::makeSuccess(id, result);
278}
279
280/**
281 * @brief Set output sample format

Callers

nothing calls this directly

Calls 6

audioMethod · 0.80
containsMethod · 0.45
valueMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected