1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
// Copyright (c) 2024 Lily Lyons
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
use fmod_sys::*;
mod bank;
mod builder;
mod callback;
mod command_replay;
mod general;
mod lifecycle;
mod listener;
mod misc;
mod parameter;
mod plugins;
mod profiling; // things too small to really make their own module
pub use builder::SystemBuilder;
pub use callback::SystemCallback;
/// The main system object for FMOD Studio.
///
/// Initializing the FMOD Studio System object will also initialize the core System object.
///
/// Created with [`SystemBuilder`], which handles initialization for you.
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)] // TODO: should this logically be copy?
#[repr(transparent)] // so we can transmute between types
pub struct System {
pub(crate) inner: *mut FMOD_STUDIO_SYSTEM,
}
impl From<*mut FMOD_STUDIO_SYSTEM> for System {
fn from(inner: *mut FMOD_STUDIO_SYSTEM) -> Self {
Self { inner }
}
}
/// Convert a System instance to its FFI equivalent.
///
/// This is safe, provided you don't use the pointer.
impl From<System> for *mut FMOD_STUDIO_SYSTEM {
fn from(value: System) -> Self {
value.inner
}
}
/// Most of FMOD is thread safe.
/// There are some select functions that are not thread safe to call, those are marked as unsafe.
unsafe impl Send for System {}
unsafe impl Sync for System {}