fmod/core/dsp_connection/
mod.rs

1// Copyright (c) 2024 Melody Madeline 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 std::ptr::NonNull;
8
9use fmod_sys::*;
10
11mod general;
12mod mix_properties;
13
14/// An interface that manages Digital Signal Processor (DSP) connections
15#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
16#[repr(transparent)] // so we can transmute between types
17pub struct DspConnection {
18    pub(crate) inner: NonNull<FMOD_DSPCONNECTION>,
19}
20
21#[cfg(not(feature = "thread-unsafe"))]
22unsafe impl Send for DspConnection {}
23#[cfg(not(feature = "thread-unsafe"))]
24unsafe impl Sync for DspConnection {}
25
26impl DspConnection {
27    /// # Safety
28    ///
29    /// `value` must be a valid pointer either aquired from [`Self::as_ptr`] or FMOD.
30    ///
31    /// # Panics
32    ///
33    /// Panics if `value` is null.
34    pub unsafe fn from_ffi(value: *mut FMOD_DSPCONNECTION) -> Self {
35        let inner = NonNull::new(value).unwrap();
36        DspConnection { inner }
37    }
38
39    /// Converts `self` into its raw representation.
40    pub fn as_ptr(self) -> *mut FMOD_DSPCONNECTION {
41        self.inner.as_ptr()
42    }
43}
44
45impl From<DspConnection> for *mut FMOD_DSPCONNECTION {
46    fn from(value: DspConnection) -> Self {
47        value.inner.as_ptr()
48    }
49}