refactor(config,audio): merge config into oakcommon, split oakaudio
- config moves into oakcommon as ConfigStore + oakcommon_config_* C API (INI storage, typed entries, error-handler injection); node and render call sites keep OAK_CONFIG() macro shape via a local shim that forwards to the C API; transition config stubs removed - oakaudio: de-Qt all six classes, C ABI in include/audio with refcounted handles (processor/manager/waveform/levelmeter/sync, 48 functions); PreviewAudioDevice moved in from render; recording goes through oakcodec encoder; waveform extract uses probe + ffmpeg_bridge decode (decode_audio needs M8 task system) - fix re_sum_samples min/max init bug (values clamped to 0 for same-sign ranges) - every C API function has positive + error-path tests; suites: oakcommon 193, oakaudio 36, oaknode 96, oakrender 42, oakcodec 18
This commit is contained in:
@@ -0,0 +1,168 @@
|
||||
/***
|
||||
|
||||
Oak Video Editor - Non-Linear Video Editor
|
||||
Copyright (C) 2026 Oak Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OAK_RENDER_CONFIGACCESSOR_H
|
||||
#define OAK_RENDER_CONFIGACCESSOR_H
|
||||
|
||||
/**
|
||||
* @brief Consumer-side shim over the oakcommon_config_* C ABI
|
||||
*
|
||||
* config 波次: the old engine/config/config.h (Qt) and the in-memory
|
||||
* transition/config/config.h stub are gone. This header keeps the
|
||||
* OAK_CONFIG(...)/Config::current()[...] call shape so call sites did
|
||||
* not change; every accessor is a C call into liboakcommon. Per the
|
||||
* cross-module rule only the oakcommon C API is used here, never the
|
||||
* ConfigStore C++ class.
|
||||
*/
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
#include "common/config.h"
|
||||
|
||||
#ifndef QStringLiteral
|
||||
#define QStringLiteral(x) x
|
||||
#endif
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief Key-bound value proxy with the QVariant-subset accessors the
|
||||
* call sites use
|
||||
*/
|
||||
class ConfigValue {
|
||||
public:
|
||||
ConfigValue() = default;
|
||||
explicit ConfigValue(const std::string &key)
|
||||
: key_(key)
|
||||
{
|
||||
}
|
||||
|
||||
bool to_bool() const
|
||||
{
|
||||
return oakcommon_config_get_bool(nullptr, key_.c_str(), 0) != 0;
|
||||
}
|
||||
bool toBool() const { return to_bool(); }
|
||||
|
||||
int to_int() const
|
||||
{
|
||||
return oakcommon_config_get_int(nullptr, key_.c_str(), 0);
|
||||
}
|
||||
int toInt() const { return to_int(); }
|
||||
|
||||
int64_t to_long_long() const
|
||||
{
|
||||
return oakcommon_config_get_int64(nullptr, key_.c_str(), 0);
|
||||
}
|
||||
uint64_t to_u_long_long() const
|
||||
{
|
||||
return static_cast<uint64_t>(to_long_long());
|
||||
}
|
||||
uint64_t toULongLong() const { return to_u_long_long(); }
|
||||
|
||||
double to_double() const
|
||||
{
|
||||
return oakcommon_config_get_double(nullptr, key_.c_str(), 0.0);
|
||||
}
|
||||
|
||||
std::string to_string() const
|
||||
{
|
||||
const int size =
|
||||
oakcommon_config_get(nullptr, key_.c_str(), nullptr, 0);
|
||||
if (size <= 0) {
|
||||
return std::string();
|
||||
}
|
||||
std::string s(size - 1, '\0');
|
||||
oakcommon_config_get(nullptr, key_.c_str(), s.data(), size);
|
||||
return s;
|
||||
}
|
||||
std::string toString() const { return to_string(); }
|
||||
|
||||
template <typename T> T value() const { return value_impl<T>(); }
|
||||
|
||||
ConfigValue &operator=(const std::string &s)
|
||||
{
|
||||
oakcommon_config_set(nullptr, key_.c_str(), s.c_str());
|
||||
return *this;
|
||||
}
|
||||
ConfigValue &operator=(const char *s)
|
||||
{
|
||||
return *this = std::string(s);
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_integral<T>::value ||
|
||||
std::is_enum<T>::value,
|
||||
T>::type
|
||||
value_impl() const
|
||||
{
|
||||
return static_cast<T>(to_long_long());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_floating_point<T>::value, T>::type
|
||||
value_impl() const
|
||||
{
|
||||
return static_cast<T>(to_double());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Rational and friends: parsed from the stored "num/den"
|
||||
* string via the type's own static from_string.
|
||||
*/
|
||||
template <typename T>
|
||||
typename std::enable_if<!std::is_arithmetic<T>::value &&
|
||||
!std::is_enum<T>::value,
|
||||
T>::type
|
||||
value_impl() const
|
||||
{
|
||||
return T::from_string(to_string());
|
||||
}
|
||||
|
||||
std::string key_;
|
||||
};
|
||||
|
||||
class Config {
|
||||
public:
|
||||
static Config ¤t()
|
||||
{
|
||||
static Config c;
|
||||
return c;
|
||||
}
|
||||
|
||||
ConfigValue operator[](const std::string &key) const
|
||||
{
|
||||
return ConfigValue(key);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace olive
|
||||
|
||||
#ifndef OAK_CONFIG
|
||||
#define OAK_CONFIG(x) Config::current()[x]
|
||||
#endif
|
||||
#ifndef OAK_CONFIG_STR
|
||||
#define OAK_CONFIG_STR(x) Config::current()[x]
|
||||
#endif
|
||||
|
||||
#endif // OAK_RENDER_CONFIGACCESSOR_H
|
||||
@@ -28,7 +28,7 @@
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include "config/config.h"
|
||||
#include "configaccessor.h"
|
||||
#include "coreengine.h"
|
||||
#include "filefunctions.h"
|
||||
|
||||
@@ -287,7 +287,7 @@ DiskCacheFolder::DiskCacheFolder(const std::string &path)
|
||||
// reached the folder through queued QMetaObject invocations.
|
||||
int interval = OAK_CONFIG("DiskCacheSaveInterval").toInt();
|
||||
if (interval <= 0) {
|
||||
// Config default (10000 ms); the transition config stub returns 0
|
||||
// Defensive fallback; the compiled-in config default is 10000 ms
|
||||
interval = 10000;
|
||||
}
|
||||
save_thread_stop_ = false;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <cctype>
|
||||
#include <filesystem>
|
||||
|
||||
#include "config/config.h"
|
||||
#include "configaccessor.h"
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#include "filefunctions.h"
|
||||
#if !defined(OAK_RENDER_BACKEND_PLUGIN)
|
||||
#include "config/config.h"
|
||||
#include "configaccessor.h"
|
||||
#endif
|
||||
#include "render/job/shaderjob.h"
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "color/colormanager/colormanager.h"
|
||||
#include "config/config.h"
|
||||
#include "configaccessor.h"
|
||||
#include "group/group.h"
|
||||
#include "node.h"
|
||||
#include "output/viewer/viewer.h"
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
|
||||
#include "config/config.h"
|
||||
#include "configaccessor.h"
|
||||
#ifdef OAK_ENABLE_DYNAMIC_RENDER_BACKEND
|
||||
#include "backend/dynamicrenderer.h"
|
||||
#endif
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "config/config.h"
|
||||
#include "configaccessor.h"
|
||||
#include "colorprocessorcache.h"
|
||||
#include "output/viewer/viewer.h"
|
||||
#include "project.h"
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
#pragma once
|
||||
// Transitional stub for engine/config/config.h (still Qt-based, config 未拆分).
|
||||
// Union of the src/node/transition stub and the render-facing surface:
|
||||
// keeps the OAK_CONFIG* call shape; values are inert defaults until the
|
||||
// config milestone wires the real store. operator[] returns a stored
|
||||
// reference so writes (lutlibrary) compile; nothing is persisted. 只增不删。
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "variant.h"
|
||||
#ifndef QStringLiteral
|
||||
#define QStringLiteral(x) x
|
||||
#endif
|
||||
namespace olive {
|
||||
class ConfigValue : public olive::Variant {
|
||||
public:
|
||||
ConfigValue() = default;
|
||||
ConfigValue(const std::string &s) : olive::Variant(s) {}
|
||||
ConfigValue &operator=(const std::string &s)
|
||||
{
|
||||
olive::Variant::operator=(olive::Variant(s));
|
||||
return *this;
|
||||
}
|
||||
bool toBool() const { return to_bool(); }
|
||||
int toInt() const { return to_int(); }
|
||||
uint64_t toULongLong() const { return to_u_long_long(); }
|
||||
// rendermanager reads the graphics backend name through this
|
||||
std::string toString() const { return to_string(); }
|
||||
std::vector<std::string> toStringList() const { return to_string_list(); }
|
||||
};
|
||||
class Config {
|
||||
public:
|
||||
static Config ¤t() { static Config c; return c; }
|
||||
ConfigValue &operator[](const std::string &key) { return values_[key]; }
|
||||
private:
|
||||
std::map<std::string, ConfigValue> values_;
|
||||
};
|
||||
}
|
||||
#ifndef OAK_CONFIG
|
||||
#define OAK_CONFIG(x) Config::current()[x]
|
||||
#endif
|
||||
#ifndef OAK_CONFIG_STR
|
||||
#define OAK_CONFIG_STR(x) Config::current()[x]
|
||||
#endif
|
||||
Reference in New Issue
Block a user