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

Method setInputSampleFormat

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

* @brief Set input sample format */

Source from the content-addressed store, hash-verified

219 * @brief Set input sample format
220 */
221API::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

Callers

nothing calls this directly

Calls 6

inputSampleFormatsMethod · 0.80
audioMethod · 0.80
containsMethod · 0.45
valueMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected