2023-10-03 13:15:17 +00:00
|
|
|
import { defineStore } from "pinia";
|
|
|
|
import { ref, computed } from "vue";
|
2023-09-05 09:22:00 +00:00
|
|
|
|
2023-10-21 09:45:45 +00:00
|
|
|
import { setActivePinia } from "pinia";
|
|
|
|
import pinia from "../store/index";
|
|
|
|
setActivePinia(pinia);
|
|
|
|
|
|
|
|
import { useSettingsStore } from "../store/settingsStore.js";
|
|
|
|
const settings = useSettingsStore(pinia);
|
|
|
|
|
2023-10-03 13:15:17 +00:00
|
|
|
export const useAudioStore = defineStore("audioStore", () => {
|
|
|
|
var inputDevices = ref([{ id: 0, name: "no input devices" }]);
|
|
|
|
var outputDevices = ref([{ id: 0, name: "no output devices" }]);
|
2023-09-05 09:22:00 +00:00
|
|
|
|
2023-10-21 09:45:45 +00:00
|
|
|
var startupInputDevice = ref(0)
|
|
|
|
var startupOutputDevice = ref(0)
|
|
|
|
|
|
|
|
|
2023-10-03 13:15:17 +00:00
|
|
|
function getInputDevices() {
|
|
|
|
var html = "";
|
|
|
|
for (var key in inputDevices.value) {
|
2023-10-21 09:45:45 +00:00
|
|
|
|
|
|
|
let selected = ''
|
|
|
|
if (inputDevices.value[key]["name"] == settings.rx_audio){
|
|
|
|
selected = "selected"
|
|
|
|
} else {
|
|
|
|
selected = ''
|
|
|
|
}
|
|
|
|
|
|
|
|
html += `<option value=${inputDevices.value[key]["id"]} ${selected}>${inputDevices.value[key]["name"]}</option>`;
|
2023-09-05 09:22:00 +00:00
|
|
|
}
|
2023-10-03 13:15:17 +00:00
|
|
|
return html;
|
|
|
|
}
|
2023-09-05 09:22:00 +00:00
|
|
|
|
2023-10-03 13:15:17 +00:00
|
|
|
function getOutputDevices() {
|
|
|
|
var html = "";
|
|
|
|
for (var key in outputDevices.value) {
|
2023-10-21 09:45:45 +00:00
|
|
|
|
|
|
|
let selected = ''
|
|
|
|
if (outputDevices.value[key]["name"] == settings.tx_audio){
|
|
|
|
selected = "selected"
|
|
|
|
} else {
|
|
|
|
selected = ''
|
|
|
|
}
|
|
|
|
html += `<option value=${outputDevices.value[key]["id"]} ${selected}>${outputDevices.value[key]["name"]}</option>`;
|
2023-09-05 09:22:00 +00:00
|
|
|
}
|
2023-10-03 13:15:17 +00:00
|
|
|
return html;
|
|
|
|
}
|
2023-09-05 09:22:00 +00:00
|
|
|
|
2023-10-21 09:45:45 +00:00
|
|
|
return { inputDevices, outputDevices, getInputDevices, getOutputDevices, startupInputDevice, startupOutputDevice };
|
2023-09-05 09:22:00 +00:00
|
|
|
});
|