File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -146,6 +146,11 @@ std::optional<FfiClient::AsyncId> ExtractAsyncId(const proto::FfiEvent& event) {
146146
147147} // namespace
148148
149+ FfiClient& FfiClient::instance () noexcept {
150+ static FfiClient instance;
151+ return instance;
152+ }
153+
149154// clang-tidy flags this as a trivial destructor in release mode
150155// due to the assert being pre-processed out
151156// NOLINTNEXTLINE(modernize-use-equals-default)
Original file line number Diff line number Diff line change @@ -74,10 +74,13 @@ class LIVEKIT_INTERNAL_API FfiClient {
7474 FfiClient (FfiClient&&) = delete ;
7575 FfiClient& operator =(FfiClient&&) = delete ;
7676
77- static FfiClient& instance () noexcept {
78- static FfiClient instance;
79- return instance;
80- }
77+ // Defined out-of-line in ffi_client.cpp so the process has exactly one
78+ // FfiClient. An inline definition would, under the SDK's hidden inline
79+ // visibility, produce a separate function-local static in every TU that
80+ // includes this header (notably: in-tree test executables), giving each
81+ // binary its own "singleton" and silently desynchronizing the dylib-side
82+ // and test-exe-side initialization flags.
83+ static FfiClient& instance () noexcept ;
8184
8285 // Must be called before any other FFI usage
8386 bool initialize (bool capture_logs);
Original file line number Diff line number Diff line change 2222namespace livekit {
2323
2424bool initialize (const LogLevel& level, const LogSink& log_sink) {
25+ // Initializes logger if singleton instance is not already initialized
2526 setLogLevel (level);
2627 auto & ffi_client = FfiClient::instance ();
2728 return ffi_client.initialize (log_sink == LogSink::kCallback );
2829}
2930
3031bool isInitialized () {
31- auto & ffi_client = FfiClient::instance ();
32- return ffi_client.isInitialized ();
32+ return FfiClient::instance ().isInitialized ();
3333}
3434
3535void shutdown () {
36- auto & ffi_client = FfiClient::instance ();
37- ffi_client.shutdown ();
36+ FfiClient::instance ().shutdown ();
3837 detail::shutdownLogger ();
3938}
4039
You can’t perform that action at this time.
0 commit comments