mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-11 14:01:49 +00:00
add 'record-audio' permission
This commit is contained in:
parent
97d2623a06
commit
b3ae6eb59a
6 changed files with 25 additions and 6 deletions
|
|
@ -67,5 +67,8 @@ function on_open()
|
||||||
table.insert(devices, {value=name, text=name})
|
table.insert(devices, {value=name, text=name})
|
||||||
end
|
end
|
||||||
selectbox.options = devices
|
selectbox.options = devices
|
||||||
selectbox.value = audio.__get_input_info().device_specifier
|
local info = audio.__get_input_info()
|
||||||
|
if info then
|
||||||
|
selectbox.value = info.device_specifier
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,6 @@
|
||||||
name = "default"
|
name = "default"
|
||||||
base_packs = ["base"]
|
base_packs = ["base"]
|
||||||
permissions = [
|
permissions = [
|
||||||
"network"
|
"network",
|
||||||
|
"record-audio"
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ namespace {
|
||||||
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;
|
std::unique_ptr<InputDevice> input_device = nullptr;
|
||||||
|
static bool input_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel::Channel(std::string name) : name(std::move(name)) {
|
Channel::Channel(std::string name) : name(std::move(name)) {
|
||||||
|
|
@ -152,7 +153,9 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void audio::initialize(bool enabled, AudioSettings& settings) {
|
void audio::initialize(
|
||||||
|
bool enabled, bool inputEnabled, AudioSettings& settings
|
||||||
|
) {
|
||||||
enabled = enabled && settings.enabled.get();
|
enabled = enabled && settings.enabled.get();
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
logger.info() << "initializing ALAudio backend";
|
logger.info() << "initializing ALAudio backend";
|
||||||
|
|
@ -182,7 +185,10 @@ void audio::initialize(bool enabled, AudioSettings& settings) {
|
||||||
}, true));
|
}, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
::input_device = backend->openInputDevice("", 44100, 1, 16);
|
if (inputEnabled) {
|
||||||
|
::input_device = backend->openInputDevice("", 44100, 1, 16);
|
||||||
|
::input_enabled = true;
|
||||||
|
}
|
||||||
if (::input_device) {
|
if (::input_device) {
|
||||||
::input_device->startCapture();
|
::input_device->startCapture();
|
||||||
}
|
}
|
||||||
|
|
@ -270,6 +276,10 @@ 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;
|
logger.info() << "setting input device to " << deviceName;
|
||||||
|
if (!::input_enabled) {
|
||||||
|
logger.warning() << "unable to set input device due to project permissions";
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (deviceName == audio::DEVICE_NONE) {
|
if (deviceName == audio::DEVICE_NONE) {
|
||||||
if (::input_device) {
|
if (::input_device) {
|
||||||
::input_device->stopCapture();
|
::input_device->stopCapture();
|
||||||
|
|
|
||||||
|
|
@ -402,7 +402,7 @@ namespace audio {
|
||||||
|
|
||||||
/// @brief Initialize audio system or use no audio mode
|
/// @brief Initialize audio system or use no audio mode
|
||||||
/// @param enabled try to initialize actual audio
|
/// @param enabled try to initialize actual audio
|
||||||
void initialize(bool enabled, AudioSettings& settings);
|
void initialize(bool enabled, bool inputEnabled, AudioSettings& settings);
|
||||||
|
|
||||||
/// @brief Load audio file info and PCM data
|
/// @brief Load audio file info and PCM data
|
||||||
/// @param file audio file
|
/// @param file audio file
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ namespace scripting {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Permissions {
|
struct Permissions {
|
||||||
|
static inline std::string RECORD_AUDIO = "record-audio";
|
||||||
static inline std::string WRITE_TO_USER = "write-to-user";
|
static inline std::string WRITE_TO_USER = "write-to-user";
|
||||||
static inline std::string NETWORK = "network";
|
static inline std::string NETWORK = "network";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,11 @@ void Engine::initialize(CoreParameters coreParameters) {
|
||||||
if (!params.headless) {
|
if (!params.headless) {
|
||||||
initializeClient();
|
initializeClient();
|
||||||
}
|
}
|
||||||
audio::initialize(!params.headless, settings.audio);
|
audio::initialize(
|
||||||
|
!params.headless,
|
||||||
|
project->permissions.has(Permissions::RECORD_AUDIO),
|
||||||
|
settings.audio
|
||||||
|
);
|
||||||
|
|
||||||
if (settings.ui.language.get() == "auto") {
|
if (settings.ui.language.get() == "auto") {
|
||||||
settings.ui.language.set(
|
settings.ui.language.set(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue