fix(macos): compile the VideoToolbox import and clean platform warnings

The macOS job finally reached the build (after the vcpkg manifest fix) and
hit a macOS-only compile error in the VideoToolbox import: `*ptr as
*const T` parses as `(*ptr) as *const T`, so `sw_format` was read off a
pointer instead of the AVHWFramesContext. Bind the frames pointer first.

Also fix the warnings the cross-check surfaced: the redundant
MTLPixelFormat import, and doc comments on an extern block and a
thread_local! (rustdoc does not document those).

Verified locally with a host-cc wrapper:
`cargo check -p oak-core -p oak-codec -p oak-node -p oak-render
-p oak-task -p oak-plugin --target aarch64-apple-darwin` is clean.
(oak-app itself needs a real Apple toolchain for ring.)
This commit is contained in:
2026-09-24 13:37:23 +08:00
parent 274ae84c01
commit 13ddd8c0e7
3 changed files with 13 additions and 13 deletions
+3 -2
View File
@@ -516,7 +516,7 @@ fn d3d11_import(req: &HwImportRequest<'_>, ctx: &Arc<GpuContext>) -> ImportOutco
// macOS: VideoToolbox CVPixelBuffer -> IOSurface -> Metal textures
// ---------------------------------------------------------------------------
/// `CVPixelBufferGetIOSurface` (CoreVideo).
// `CVPixelBufferGetIOSurface` (CoreVideo).
#[cfg(target_os = "macos")]
#[link(name = "CoreVideo", kind = "framework")]
extern "C" {
@@ -543,7 +543,8 @@ fn videotoolbox_import(req: &HwImportRequest<'_>, ctx: &Arc<GpuContext>) -> Impo
return ImportOutcome::Unsupported;
}
// SAFETY: `hw_frames_ctx` is an AVHWFramesContext for this frame.
let sw_format = unsafe { (*(*frames).data as *const sys::AVHWFramesContext).sw_format };
let hw_frames = unsafe { (*frames).data as *const sys::AVHWFramesContext };
let sw_format = unsafe { (*hw_frames).sw_format };
let format = match sw_format {
sys::AVPixelFormat::AV_PIX_FMT_NV12 => PlanarFormat::Nv12,
sys::AVPixelFormat::AV_PIX_FMT_P010LE | sys::AVPixelFormat::AV_PIX_FMT_P010BE => {
+1 -2
View File
@@ -459,8 +459,7 @@ impl GpuContext {
use objc2::runtime::ProtocolObject;
use objc2_io_surface::IOSurfaceRef;
use objc2_metal::{
MTLDevice as _, MTLPixelFormat, MTLStorageMode, MTLTextureDescriptor,
MTLTextureType, MTLTextureUsage,
MTLDevice as _, MTLStorageMode, MTLTextureDescriptor, MTLTextureType, MTLTextureUsage,
};
use wgpu::hal;
+9 -9
View File
@@ -252,13 +252,13 @@ mod imp {
const K_CGL_PFA_COLOR_SIZE: i32 = 8;
const K_CGL_PFA_ALPHA_SIZE: i32 = 11;
/// macOS:CGL + OpenGL 的 FFI 声明(直接链接 OpenGL.framework)。
///
/// # Safety
///
/// 全部是系统 framework 导出函数;指针参数语义见各函数注释。
/// CGL* 类型用 `*mut c_void` 表示不透明对象指针(CGLContextObj /
/// CGLPixelFormatObj)。
// macOS:CGL + OpenGL 的 FFI 声明(直接链接 OpenGL.framework)。
//
// # Safety
//
// 全部是系统 framework 导出函数;指针参数语义见各函数注释。
// CGL* 类型用 `*mut c_void` 表示不透明对象指针(CGLContextObj /
// CGLPixelFormatObj)。
#[link(name = "OpenGL", kind = "framework")]
unsafe extern "C" {
/// 按属性列表选像素格式(成功返回 kCGLNoError=0;`npix` 是
@@ -406,8 +406,8 @@ mod imp {
_ctx: Arc<GlContext>,
}
/// 当前线程的 acquire 嵌套深度。>0 = 本线程已持外层 guard(上下文
/// 已 current);嵌套 acquire 只递增深度,不重取锁。
// 当前线程的 acquire 嵌套深度。>0 = 本线程已持外层 guard(上下文
// 已 current);嵌套 acquire 只递增深度,不重取锁。
thread_local! {
static ACQUIRE_DEPTH: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
}