* @brief Set input sample format */
| 219 | * @brief Set input sample format |
| 220 | */ |
| 221 | API::CommandResponse API::Handlers::AudioHandler::setInputSampleFormat(const QString& id, |
| 222 | const QJsonObject& params) |
| 223 | { |
| 224 | if (!params.contains(QStringLiteral("formatIndex"))) { |
| 225 | return CommandResponse::makeError( |
| 226 | id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: formatIndex")); |
| 227 | } |
| 228 | |
| 229 | const int format_index = params.value(QStringLiteral("formatIndex")).toInt(); |
| 230 | |
| 231 | const auto& formats = IO::ConnectionManager::instance().audio()->inputSampleFormats(); |
| 232 | if (format_index < 0 || format_index >= formats.count()) { |
| 233 | return CommandResponse::makeError( |
| 234 | id, |
| 235 | ErrorCode::InvalidParam, |
| 236 | QString(QStringLiteral("Invalid formatIndex: %1. Valid range: 0-%2")) |
| 237 | .arg(format_index) |
| 238 | .arg(formats.count() - 1)); |
| 239 | } |
| 240 | |
| 241 | IO::ConnectionManager::instance().audio()->setSelectedInputSampleFormat(format_index); |
| 242 | |
| 243 | QJsonObject result; |
| 244 | result[QStringLiteral("formatIndex")] = format_index; |
| 245 | result[QStringLiteral("formatName")] = formats.at(format_index); |
| 246 | return CommandResponse::makeSuccess(id, result); |
| 247 | } |
| 248 | |
| 249 | /** |
| 250 | * @brief Set input channel configuration |
nothing calls this directly
no test coverage detected