* @brief Set input channel configuration */
| 250 | * @brief Set input channel configuration |
| 251 | */ |
| 252 | API::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 |
nothing calls this directly
no test coverage detected