diff --git a/sdrbase/resources/index.html b/sdrbase/resources/index.html
index 5efb84fe0..e9c527b75 100644
--- a/sdrbase/resources/index.html
+++ b/sdrbase/resources/index.html
@@ -696,12 +696,16 @@ margin-bottom: 20px;
// Script section to load models into a JS Var
var defs = {}
defs.AudioDevices = {
- "required" : [ "nbInputDevices", "nbOutputDevices" ],
+ "required" : [ "inputDeviceSelectedIndex", "nbInputDevices", "nbOutputDevices", "outputDeviceSelectedIndex" ],
"properties" : {
"nbInputDevices" : {
"type" : "integer",
"description" : "Number of input audio devices"
},
+ "inputDeviceSelectedIndex" : {
+ "type" : "integer",
+ "description" : "Index of selected input audio devices (-1 if default)"
+ },
"inputDevices" : {
"type" : "array",
"description" : "Names of input devices",
@@ -713,6 +717,10 @@ margin-bottom: 20px;
"type" : "integer",
"description" : "Number of output audio devices"
},
+ "outputDeviceSelectedIndex" : {
+ "type" : "integer",
+ "description" : "Index of selected output audio devices (-1 if default)"
+ },
"outputDevices" : {
"type" : "array",
"description" : "Names of output devices",
@@ -726,12 +734,12 @@ margin-bottom: 20px;
defs.AudioDevicesSelect = {
"properties" : {
"input" : {
- "type" : "string",
- "description" : "Name of the audio input device"
+ "type" : "integer",
+ "description" : "Index of the audio input device (-1 for default)"
},
"output" : {
- "type" : "string",
- "description" : "Name of the audio output device"
+ "type" : "integer",
+ "description" : "Index of the audio output device (-1 for default)"
}
},
"description" : "Audio devices selected"
@@ -7356,7 +7364,7 @@ except ApiException as e:
- Generated 2017-11-24T00:55:01.257+01:00
+ Generated 2017-11-24T08:42:52.359+01:00
diff --git a/sdrbase/webapi/webapiadapterinterface.cpp b/sdrbase/webapi/webapiadapterinterface.cpp
index baffe8de3..c14851dc6 100644
--- a/sdrbase/webapi/webapiadapterinterface.cpp
+++ b/sdrbase/webapi/webapiadapterinterface.cpp
@@ -22,4 +22,4 @@ QString WebAPIAdapterInterface::instanceSummaryURL = "/sdrangel";
QString WebAPIAdapterInterface::instanceDevicesURL = "/sdrangel/devices";
QString WebAPIAdapterInterface::instanceChannelsURL = "/sdrangel/channels";
QString WebAPIAdapterInterface::instanceLoggingURL = "/sdrangel/logging";
-
+QString WebAPIAdapterInterface::instanceAudioURL = "/sdrangel/audio";
diff --git a/sdrbase/webapi/webapiadapterinterface.h b/sdrbase/webapi/webapiadapterinterface.h
index 4a8782dfc..c44ec8e9c 100644
--- a/sdrbase/webapi/webapiadapterinterface.h
+++ b/sdrbase/webapi/webapiadapterinterface.h
@@ -27,6 +27,7 @@ namespace Swagger
class SWGInstanceDevicesResponse;
class SWGInstanceChannelsResponse;
class SWGLoggingInfo;
+ class SWGAudioDevices;
class SWGErrorResponse;
}
@@ -82,10 +83,20 @@ public:
Swagger::SWGErrorResponse& error __attribute__((unused)))
{ return 501; }
+ /**
+ * Handler of /sdrangel/audio (GET) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
+ * returns the Http status code (default 501: not implemented)
+ */
+ virtual int instanceAudioGet(
+ Swagger::SWGAudioDevices& response __attribute__((unused)),
+ Swagger::SWGErrorResponse& error __attribute__((unused)))
+ { return 501; }
+
static QString instanceSummaryURL;
static QString instanceDevicesURL;
static QString instanceChannelsURL;
static QString instanceLoggingURL;
+ static QString instanceAudioURL;
};
diff --git a/sdrbase/webapi/webapirequestmapper.cpp b/sdrbase/webapi/webapirequestmapper.cpp
index 1a35cd8af..9d1f7f73a 100644
--- a/sdrbase/webapi/webapirequestmapper.cpp
+++ b/sdrbase/webapi/webapirequestmapper.cpp
@@ -25,6 +25,8 @@
#include "SWGInstanceSummaryResponse.h"
#include "SWGInstanceDevicesResponse.h"
#include "SWGInstanceChannelsResponse.h"
+#include "SWGAudioDevices.h"
+#include "SWGAudioDevicesSelect.h"
#include "SWGErrorResponse.h"
WebAPIRequestMapper::WebAPIRequestMapper(QObject* parent) :
@@ -185,6 +187,33 @@ void WebAPIRequestMapper::service(qtwebapp::HttpRequest& request, qtwebapp::Http
response.write("Invalid HTTP method");
}
}
+ else if (path == WebAPIAdapterInterface::instanceAudioURL)
+ {
+ Swagger::SWGErrorResponse errorResponse;
+
+ if (request.getMethod() == "GET")
+ {
+ Swagger::SWGAudioDevices normalResponse;
+
+ int status = m_adapter->instanceAudioGet(normalResponse, errorResponse);
+ response.setStatus(status);
+
+ if (status == 200) {
+ response.write(normalResponse.asJson().toUtf8());
+ } else {
+ response.write(errorResponse.asJson().toUtf8());
+ }
+ }
+ else if (request.getMethod() == "PATCH")
+ {
+ Swagger::SWGAudioDevicesSelect normalResponse;
+ }
+ else
+ {
+ response.setStatus(405,"Invalid HTTP method");
+ response.write("Invalid HTTP method");
+ }
+ }
else
{
// QDirIterator it(":", QDirIterator::Subdirectories);
diff --git a/sdrgui/webapi/webapiadaptergui.cpp b/sdrgui/webapi/webapiadaptergui.cpp
index 37663444d..976d2e1fe 100644
--- a/sdrgui/webapi/webapiadaptergui.cpp
+++ b/sdrgui/webapi/webapiadaptergui.cpp
@@ -36,6 +36,7 @@
#include "SWGInstanceDevicesResponse.h"
#include "SWGInstanceChannelsResponse.h"
#include "SWGDeviceListItem.h"
+#include "SWGAudioDevices.h"
#include "SWGErrorResponse.h"
#include "webapiadaptergui.h"
@@ -249,6 +250,38 @@ int WebAPIAdapterGUI::instanceLoggingPut(
return 200;
}
+int WebAPIAdapterGUI::instanceAudioGet(
+ Swagger::SWGAudioDevices& response,
+ Swagger::SWGErrorResponse& error __attribute__((unused)))
+{
+ const QList& audioInputDevices = m_mainWindow.m_audioDeviceInfo.getInputDevices();
+ const QList& audioOutputDevices = m_mainWindow.m_audioDeviceInfo.getOutputDevices();
+ int nbInputDevices = audioInputDevices.size();
+ int nbOutputDevices = audioOutputDevices.size();
+
+ response.init();
+ response.setNbInputDevices(nbInputDevices);
+ response.setInputDeviceSelectedIndex(m_mainWindow.m_audioDeviceInfo.getInputDeviceIndex());
+ response.setNbOutputDevices(nbOutputDevices);
+ response.setOutputDeviceSelectedIndex(m_mainWindow.m_audioDeviceInfo.getOutputDeviceIndex());
+ QList *inputDeviceNames = response.getInputDevices();
+ QList *outputDeviceNames = response.getOutputDevices();
+
+ for (int i = 0; i < nbInputDevices; i++)
+ {
+ inputDeviceNames->append(new QString());
+ *inputDeviceNames->back() = audioInputDevices[i].deviceName();
+ }
+
+ for (int i = 0; i < nbOutputDevices; i++)
+ {
+ outputDeviceNames->append(new QString());
+ *outputDeviceNames->back() = audioOutputDevices[i].deviceName();
+ }
+
+ return 200;
+}
+
QtMsgType WebAPIAdapterGUI::getMsgTypeFromString(const QString& msgTypeString)
{
if (msgTypeString == "debug") {
diff --git a/sdrgui/webapi/webapiadaptergui.h b/sdrgui/webapi/webapiadaptergui.h
index d10ab7455..42d3faf3c 100644
--- a/sdrgui/webapi/webapiadaptergui.h
+++ b/sdrgui/webapi/webapiadaptergui.h
@@ -53,6 +53,10 @@ public:
Swagger::SWGLoggingInfo& response,
Swagger::SWGErrorResponse& error);
+ virtual int instanceAudioGet(
+ Swagger::SWGAudioDevices& response,
+ Swagger::SWGErrorResponse& error);
+
private:
MainWindow& m_mainWindow;
diff --git a/swagger/sdrangel/api/swagger/swagger.yaml b/swagger/sdrangel/api/swagger/swagger.yaml
index fd6592b0b..02a1c5ca3 100644
--- a/swagger/sdrangel/api/swagger/swagger.yaml
+++ b/swagger/sdrangel/api/swagger/swagger.yaml
@@ -634,11 +634,16 @@ definitions:
description: "List of audio devices available in the system"
required:
- nbInputDevices
+ - inputDeviceSelectedIndex
- nbOutputDevices
+ - outputDeviceSelectedIndex
properties:
nbInputDevices:
description: "Number of input audio devices"
type: integer
+ inputDeviceSelectedIndex:
+ description: "Index of selected input audio devices (-1 if default)"
+ type: integer
inputDevices:
description: "Names of input devices"
type: array
@@ -647,6 +652,9 @@ definitions:
nbOutputDevices:
description: "Number of output audio devices"
type: integer
+ outputDeviceSelectedIndex:
+ description: "Index of selected output audio devices (-1 if default)"
+ type: integer
outputDevices:
description: "Names of output devices"
type: array
@@ -656,11 +664,11 @@ definitions:
description: "Audio devices selected"
properties:
input:
- description: "Name of the audio input device"
- type: string
+ description: "Index of the audio input device (-1 for default)"
+ type: integer
output:
- description: "Name of the audio output device"
- type: string
+ description: "Index of the audio output device (-1 for default)"
+ type: integer
LocationInformation:
description: "Instance geolocation information"
required:
diff --git a/swagger/sdrangel/code/html2/index.html b/swagger/sdrangel/code/html2/index.html
index 5efb84fe0..e9c527b75 100644
--- a/swagger/sdrangel/code/html2/index.html
+++ b/swagger/sdrangel/code/html2/index.html
@@ -696,12 +696,16 @@ margin-bottom: 20px;
// Script section to load models into a JS Var
var defs = {}
defs.AudioDevices = {
- "required" : [ "nbInputDevices", "nbOutputDevices" ],
+ "required" : [ "inputDeviceSelectedIndex", "nbInputDevices", "nbOutputDevices", "outputDeviceSelectedIndex" ],
"properties" : {
"nbInputDevices" : {
"type" : "integer",
"description" : "Number of input audio devices"
},
+ "inputDeviceSelectedIndex" : {
+ "type" : "integer",
+ "description" : "Index of selected input audio devices (-1 if default)"
+ },
"inputDevices" : {
"type" : "array",
"description" : "Names of input devices",
@@ -713,6 +717,10 @@ margin-bottom: 20px;
"type" : "integer",
"description" : "Number of output audio devices"
},
+ "outputDeviceSelectedIndex" : {
+ "type" : "integer",
+ "description" : "Index of selected output audio devices (-1 if default)"
+ },
"outputDevices" : {
"type" : "array",
"description" : "Names of output devices",
@@ -726,12 +734,12 @@ margin-bottom: 20px;
defs.AudioDevicesSelect = {
"properties" : {
"input" : {
- "type" : "string",
- "description" : "Name of the audio input device"
+ "type" : "integer",
+ "description" : "Index of the audio input device (-1 for default)"
},
"output" : {
- "type" : "string",
- "description" : "Name of the audio output device"
+ "type" : "integer",
+ "description" : "Index of the audio output device (-1 for default)"
}
},
"description" : "Audio devices selected"
@@ -7356,7 +7364,7 @@ except ApiException as e:
- Generated 2017-11-24T00:55:01.257+01:00
+ Generated 2017-11-24T08:42:52.359+01:00
diff --git a/swagger/sdrangel/code/qt5/client/SWGAudioDevices.cpp b/swagger/sdrangel/code/qt5/client/SWGAudioDevices.cpp
index a9915d73c..5a3a9dc6c 100644
--- a/swagger/sdrangel/code/qt5/client/SWGAudioDevices.cpp
+++ b/swagger/sdrangel/code/qt5/client/SWGAudioDevices.cpp
@@ -38,8 +38,10 @@ SWGAudioDevices::~SWGAudioDevices() {
void
SWGAudioDevices::init() {
nb_input_devices = 0;
+ input_device_selected_index = 0;
input_devices = new QList();
nb_output_devices = 0;
+ output_device_selected_index = 0;
output_devices = new QList();
}
@@ -47,6 +49,7 @@ void
SWGAudioDevices::cleanup() {
+
if(input_devices != nullptr) {
QList* arr = input_devices;
foreach(QString* o, *arr) {
@@ -56,6 +59,7 @@ SWGAudioDevices::cleanup() {
}
+
if(output_devices != nullptr) {
QList* arr = output_devices;
foreach(QString* o, *arr) {
@@ -77,10 +81,12 @@ SWGAudioDevices::fromJson(QString &json) {
void
SWGAudioDevices::fromJsonObject(QJsonObject &pJson) {
::Swagger::setValue(&nb_input_devices, pJson["nbInputDevices"], "qint32", "");
+ ::Swagger::setValue(&input_device_selected_index, pJson["inputDeviceSelectedIndex"], "qint32", "");
::Swagger::setValue(&input_devices, pJson["inputDevices"], "QList", "QString");
::Swagger::setValue(&nb_output_devices, pJson["nbOutputDevices"], "qint32", "");
+ ::Swagger::setValue(&output_device_selected_index, pJson["outputDeviceSelectedIndex"], "qint32", "");
::Swagger::setValue(&output_devices, pJson["outputDevices"], "QList", "QString");
@@ -102,12 +108,16 @@ SWGAudioDevices::asJsonObject() {
obj->insert("nbInputDevices", QJsonValue(nb_input_devices));
+ obj->insert("inputDeviceSelectedIndex", QJsonValue(input_device_selected_index));
+
QJsonArray input_devicesJsonArray;
toJsonArray((QList*)input_devices, &input_devicesJsonArray, "input_devices", "QString");
obj->insert("inputDevices", input_devicesJsonArray);
obj->insert("nbOutputDevices", QJsonValue(nb_output_devices));
+ obj->insert("outputDeviceSelectedIndex", QJsonValue(output_device_selected_index));
+
QJsonArray output_devicesJsonArray;
toJsonArray((QList*)output_devices, &output_devicesJsonArray, "output_devices", "QString");
obj->insert("outputDevices", output_devicesJsonArray);
@@ -124,6 +134,15 @@ SWGAudioDevices::setNbInputDevices(qint32 nb_input_devices) {
this->nb_input_devices = nb_input_devices;
}
+qint32
+SWGAudioDevices::getInputDeviceSelectedIndex() {
+ return input_device_selected_index;
+}
+void
+SWGAudioDevices::setInputDeviceSelectedIndex(qint32 input_device_selected_index) {
+ this->input_device_selected_index = input_device_selected_index;
+}
+
QList*
SWGAudioDevices::getInputDevices() {
return input_devices;
@@ -142,6 +161,15 @@ SWGAudioDevices::setNbOutputDevices(qint32 nb_output_devices) {
this->nb_output_devices = nb_output_devices;
}
+qint32
+SWGAudioDevices::getOutputDeviceSelectedIndex() {
+ return output_device_selected_index;
+}
+void
+SWGAudioDevices::setOutputDeviceSelectedIndex(qint32 output_device_selected_index) {
+ this->output_device_selected_index = output_device_selected_index;
+}
+
QList*
SWGAudioDevices::getOutputDevices() {
return output_devices;
diff --git a/swagger/sdrangel/code/qt5/client/SWGAudioDevices.h b/swagger/sdrangel/code/qt5/client/SWGAudioDevices.h
index c151ac719..563f239c0 100644
--- a/swagger/sdrangel/code/qt5/client/SWGAudioDevices.h
+++ b/swagger/sdrangel/code/qt5/client/SWGAudioDevices.h
@@ -46,20 +46,28 @@ public:
qint32 getNbInputDevices();
void setNbInputDevices(qint32 nb_input_devices);
+ qint32 getInputDeviceSelectedIndex();
+ void setInputDeviceSelectedIndex(qint32 input_device_selected_index);
+
QList* getInputDevices();
void setInputDevices(QList* input_devices);
qint32 getNbOutputDevices();
void setNbOutputDevices(qint32 nb_output_devices);
+ qint32 getOutputDeviceSelectedIndex();
+ void setOutputDeviceSelectedIndex(qint32 output_device_selected_index);
+
QList* getOutputDevices();
void setOutputDevices(QList* output_devices);
private:
qint32 nb_input_devices;
+ qint32 input_device_selected_index;
QList* input_devices;
qint32 nb_output_devices;
+ qint32 output_device_selected_index;
QList* output_devices;
};
diff --git a/swagger/sdrangel/code/qt5/client/SWGAudioDevicesSelect.cpp b/swagger/sdrangel/code/qt5/client/SWGAudioDevicesSelect.cpp
index e16b22cc9..80139ea4e 100644
--- a/swagger/sdrangel/code/qt5/client/SWGAudioDevicesSelect.cpp
+++ b/swagger/sdrangel/code/qt5/client/SWGAudioDevicesSelect.cpp
@@ -37,20 +37,14 @@ SWGAudioDevicesSelect::~SWGAudioDevicesSelect() {
void
SWGAudioDevicesSelect::init() {
- input = new QString("");
- output = new QString("");
+ input = 0;
+ output = 0;
}
void
SWGAudioDevicesSelect::cleanup() {
- if(input != nullptr) {
- delete input;
- }
- if(output != nullptr) {
- delete output;
- }
}
SWGAudioDevicesSelect*
@@ -64,8 +58,8 @@ SWGAudioDevicesSelect::fromJson(QString &json) {
void
SWGAudioDevicesSelect::fromJsonObject(QJsonObject &pJson) {
- ::Swagger::setValue(&input, pJson["input"], "QString", "QString");
- ::Swagger::setValue(&output, pJson["output"], "QString", "QString");
+ ::Swagger::setValue(&input, pJson["input"], "qint32", "");
+ ::Swagger::setValue(&output, pJson["output"], "qint32", "");
}
QString
@@ -82,28 +76,28 @@ QJsonObject*
SWGAudioDevicesSelect::asJsonObject() {
QJsonObject* obj = new QJsonObject();
- toJsonValue(QString("input"), input, obj, QString("QString"));
+ obj->insert("input", QJsonValue(input));
- toJsonValue(QString("output"), output, obj, QString("QString"));
+ obj->insert("output", QJsonValue(output));
return obj;
}
-QString*
+qint32
SWGAudioDevicesSelect::getInput() {
return input;
}
void
-SWGAudioDevicesSelect::setInput(QString* input) {
+SWGAudioDevicesSelect::setInput(qint32 input) {
this->input = input;
}
-QString*
+qint32
SWGAudioDevicesSelect::getOutput() {
return output;
}
void
-SWGAudioDevicesSelect::setOutput(QString* output) {
+SWGAudioDevicesSelect::setOutput(qint32 output) {
this->output = output;
}
diff --git a/swagger/sdrangel/code/qt5/client/SWGAudioDevicesSelect.h b/swagger/sdrangel/code/qt5/client/SWGAudioDevicesSelect.h
index c66bcbbd5..c87c0e317 100644
--- a/swagger/sdrangel/code/qt5/client/SWGAudioDevicesSelect.h
+++ b/swagger/sdrangel/code/qt5/client/SWGAudioDevicesSelect.h
@@ -22,7 +22,6 @@
#include
-#include
#include "SWGObject.h"
@@ -42,16 +41,16 @@ public:
void fromJsonObject(QJsonObject &json);
SWGAudioDevicesSelect* fromJson(QString &jsonString);
- QString* getInput();
- void setInput(QString* input);
+ qint32 getInput();
+ void setInput(qint32 input);
- QString* getOutput();
- void setOutput(QString* output);
+ qint32 getOutput();
+ void setOutput(qint32 output);
private:
- QString* input;
- QString* output;
+ qint32 input;
+ qint32 output;
};
}