add 'none' input device
This commit is contained in:
parent
96bc395561
commit
8cfff09c0b
@ -59,7 +59,9 @@ function on_open()
|
|||||||
.."<container id='input_volume_inner' color='#00FF00FF' pos='1' size='2'/>"
|
.."<container id='input_volume_inner' color='#00FF00FF' pos='1' size='2'/>"
|
||||||
.."</container>")
|
.."</container>")
|
||||||
local selectbox = document.input_device_select
|
local selectbox = document.input_device_select
|
||||||
local devices = {}
|
local devices = {
|
||||||
|
{value="none", text=gui.str("None", "settings.microphone")},
|
||||||
|
}
|
||||||
local names = audio.__get_input_devices_names()
|
local names = audio.__get_input_devices_names()
|
||||||
for i, name in ipairs(names) do
|
for i, name in ipairs(names) do
|
||||||
table.insert(devices, {value=name, text=name})
|
table.insert(devices, {value=name, text=name})
|
||||||
|
|||||||
@ -109,6 +109,7 @@ settings.Conflict=Найдены возможные конфликты
|
|||||||
settings.Windowed=Оконный
|
settings.Windowed=Оконный
|
||||||
settings.Borderless=Безрамочный
|
settings.Borderless=Безрамочный
|
||||||
settings.Microphone=Микрофон
|
settings.Microphone=Микрофон
|
||||||
|
settings.microphone.None=Нет
|
||||||
|
|
||||||
# Управление
|
# Управление
|
||||||
chunks.reload=Перезагрузить Чанки
|
chunks.reload=Перезагрузить Чанки
|
||||||
|
|||||||
@ -23,6 +23,7 @@ namespace {
|
|||||||
std::unordered_map<speakerid_t, std::shared_ptr<Stream>> streams;
|
std::unordered_map<speakerid_t, std::shared_ptr<Stream>> streams;
|
||||||
std::vector<std::unique_ptr<Channel>> channels;
|
std::vector<std::unique_ptr<Channel>> channels;
|
||||||
util::ObjectsKeeper objects_keeper {};
|
util::ObjectsKeeper objects_keeper {};
|
||||||
|
std::unique_ptr<InputDevice> input_device = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel::Channel(std::string name) : name(std::move(name)) {
|
Channel::Channel(std::string name) : name(std::move(name)) {
|
||||||
@ -151,8 +152,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::unique_ptr<InputDevice> input_device = nullptr;
|
|
||||||
|
|
||||||
void audio::initialize(bool enabled, AudioSettings& settings) {
|
void audio::initialize(bool enabled, AudioSettings& settings) {
|
||||||
enabled = enabled && settings.enabled.get();
|
enabled = enabled && settings.enabled.get();
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
@ -183,9 +182,9 @@ void audio::initialize(bool enabled, AudioSettings& settings) {
|
|||||||
}, true));
|
}, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
input_device = backend->openInputDevice("", 44100, 1, 16);
|
::input_device = backend->openInputDevice("", 44100, 1, 16);
|
||||||
if (input_device) {
|
if (::input_device) {
|
||||||
input_device->startCapture();
|
::input_device->startCapture();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,18 +269,26 @@ std::vector<std::string> audio::get_output_devices_names() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void audio::set_input_device(const std::string& deviceName) {
|
void audio::set_input_device(const std::string& deviceName) {
|
||||||
|
logger.info() << "setting input device to " << deviceName;
|
||||||
|
if (deviceName == audio::DEVICE_NONE) {
|
||||||
|
if (::input_device) {
|
||||||
|
::input_device->stopCapture();
|
||||||
|
}
|
||||||
|
::input_device = nullptr;
|
||||||
|
return;
|
||||||
|
}
|
||||||
auto newDevice = backend->openInputDevice(deviceName, 44100, 1, 16);
|
auto newDevice = backend->openInputDevice(deviceName, 44100, 1, 16);
|
||||||
if (newDevice == nullptr) {
|
if (newDevice == nullptr) {
|
||||||
logger.error() << "could not open input device: " << deviceName;
|
logger.error() << "could not open input device: " << deviceName;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input_device) {
|
if (::input_device) {
|
||||||
input_device->stopCapture();
|
::input_device->stopCapture();
|
||||||
}
|
}
|
||||||
input_device = std::move(newDevice);
|
::input_device = std::move(newDevice);
|
||||||
if (input_device) {
|
if (::input_device) {
|
||||||
input_device->startCapture();
|
::input_device->startCapture();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,6 +26,8 @@ namespace audio {
|
|||||||
|
|
||||||
constexpr inline size_t MAX_INPUT_SAMPLES = 22050;
|
constexpr inline size_t MAX_INPUT_SAMPLES = 22050;
|
||||||
|
|
||||||
|
inline std::string_view DEVICE_NONE = "none";
|
||||||
|
|
||||||
class Speaker;
|
class Speaker;
|
||||||
|
|
||||||
/// @brief Audio speaker states
|
/// @brief Audio speaker states
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user