* @brief Set output channel configuration */
| 312 | * @brief Set output channel configuration |
| 313 | */ |
| 314 | API::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 |
nothing calls this directly
no test coverage detected