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