From 36782528b3fdfb47a14d60a6a4c71a9882e1d8a9 Mon Sep 17 00:00:00 2001 From: Miriam Zimmerman Date: Tue, 16 Sep 2025 13:27:47 -0400 Subject: [PATCH 1/2] Do not rebuild logging function if gecko-in-tree Avoid a double definition of rust_write_formatted_msg by only building it once when cubeb is being built directly and not when built via cubeb-pulse-rs's invocation Resolves #125 --- cubeb-core/src/log.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cubeb-core/src/log.rs b/cubeb-core/src/log.rs index 486ae48..328e881 100644 --- a/cubeb-core/src/log.rs +++ b/cubeb-core/src/log.rs @@ -3,9 +3,13 @@ // This program is made available under an ISC-style license. See the // accompanying file LICENSE for details. +use ffi; +#[cfg(not(feature = "gecko-in-tree"))] use std::ffi::{c_char, CStr}; +#[cfg(not(feature = "gecko-in-tree"))] use std::sync::RwLock; -use {ffi, Error, Result}; +#[cfg(not(feature = "gecko-in-tree"))] +use {Error, Result}; /// Level (verbosity) of logging for a particular cubeb context. #[derive(PartialEq, Eq, Clone, Debug, Copy, PartialOrd, Ord)] @@ -44,8 +48,10 @@ pub fn log_enabled() -> bool { unsafe { ffi::cubeb_log_get_level() != LogLevel::Disabled as _ } } +#[cfg(not(feature = "gecko-in-tree"))] static LOG_CALLBACK: RwLock> = RwLock::new(None); +#[cfg(not(feature = "gecko-in-tree"))] extern "C" { fn cubeb_write_log(fmt: *const c_char, ...); } @@ -54,6 +60,7 @@ extern "C" { /// /// |s| must be null, or a pointer to a valid, nul-terminated, array of chars. #[no_mangle] +#[cfg(not(feature = "gecko-in-tree"))] pub unsafe extern "C" fn rust_write_formatted_msg(s: *const c_char) { if s.is_null() { // Do nothing if the pointer is null. @@ -68,6 +75,7 @@ pub unsafe extern "C" fn rust_write_formatted_msg(s: *const c_char) { // Silently fail if lock cannot be acquired. } +#[cfg(not(feature = "gecko-in-tree"))] pub fn set_logging(level: LogLevel, f: Option) -> Result<()> { match LOG_CALLBACK.write() { Ok(mut guard) => { From 191059613b203596a16ce453e93bce2af02644f6 Mon Sep 17 00:00:00 2001 From: Miriam Zimmerman Date: Tue, 16 Sep 2025 13:37:01 -0400 Subject: [PATCH 2/2] Fix nightly clippy finding. --- cubeb-backend/src/capi.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubeb-backend/src/capi.rs b/cubeb-backend/src/capi.rs index ba795bb..d9c1787 100644 --- a/cubeb-backend/src/capi.rs +++ b/cubeb-backend/src/capi.rs @@ -198,7 +198,7 @@ pub unsafe extern "C" fn capi_device_collection_destroy( let ctx = &mut *(c as *mut CTX); let collection = &mut *(collection); - let coll = Box::from_raw(std::slice::from_raw_parts_mut( + let coll = Box::from_raw(std::ptr::slice_from_raw_parts_mut( collection.device as *mut DeviceInfo, collection.count, ));