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

Method setOutputChannelConfig

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

* @brief Set output channel configuration */

Source from the content-addressed store, hash-verified

312 * @brief Set output channel configuration
313 */
314API::CommandResponse API::Handlers::AudioHandler::setOutputChannelConfig(const QString& id,
315 const QJsonObject& params)
316{
317 if (!params.contains(QStringLiteral("channelIndex"))) {
318 return CommandResponse::makeError(
319 id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: channelIndex"));
320 }
321
322 const int channel_index = params.value(QStringLiteral("channelIndex")).toInt();
323
324 const auto& channels = IO::ConnectionManager::instance().audio()->outputChannelConfigurations();
325 if (channel_index < 0 || channel_index >= channels.count()) {
326 return CommandResponse::makeError(
327 id,
328 ErrorCode::InvalidParam,
329 QString(QStringLiteral("Invalid channelIndex: %1. Valid range: 0-%2"))
330 .arg(channel_index)
331 .arg(channels.count() - 1));
332 }
333
334 IO::ConnectionManager::instance().audio()->setSelectedOutputChannelConfiguration(channel_index);
335
336 QJsonObject result;
337 result[QStringLiteral("channelIndex")] = channel_index;
338 result[QStringLiteral("channelName")] = channels.at(channel_index);
339 return CommandResponse::makeSuccess(id, result);
340}
341
342//--------------------------------------------------------------------------------------------------
343// Getters

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