* @brief Set output sample format */
| 281 | * @brief Set output sample format |
| 282 | */ |
| 283 | API::CommandResponse API::Handlers::AudioHandler::setOutputSampleFormat(const QString& id, |
| 284 | const QJsonObject& params) |
| 285 | { |
| 286 | if (!params.contains(QStringLiteral("formatIndex"))) { |
| 287 | return CommandResponse::makeError( |
| 288 | id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: formatIndex")); |
| 289 | } |
| 290 | |
| 291 | const int format_index = params.value(QStringLiteral("formatIndex")).toInt(); |
| 292 | |
| 293 | const auto& formats = IO::ConnectionManager::instance().audio()->outputSampleFormats(); |
| 294 | if (format_index < 0 || format_index >= formats.count()) { |
| 295 | return CommandResponse::makeError( |
| 296 | id, |
| 297 | ErrorCode::InvalidParam, |
| 298 | QString(QStringLiteral("Invalid formatIndex: %1. Valid range: 0-%2")) |
| 299 | .arg(format_index) |
| 300 | .arg(formats.count() - 1)); |
| 301 | } |
| 302 | |
| 303 | IO::ConnectionManager::instance().audio()->setSelectedOutputSampleFormat(format_index); |
| 304 | |
| 305 | QJsonObject result; |
| 306 | result[QStringLiteral("formatIndex")] = format_index; |
| 307 | result[QStringLiteral("formatName")] = formats.at(format_index); |
| 308 | return CommandResponse::makeSuccess(id, result); |
| 309 | } |
| 310 | |
| 311 | /** |
| 312 | * @brief Set output channel configuration |
nothing calls this directly
no test coverage detected