fmod/studio/system/
plugins.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 fmod_sys::*;
8use lanyard::Utf8CStr;
9
10use crate::studio::System;
11use crate::{FmodResultExt, Result};
12
13impl System {
14    /// Registers a plugin DSP.
15    ///
16    /// Plugin DSPs used by an event must be registered using this function before loading the bank containing the event.
17    ///
18    /// # Safety
19    ///
20    /// This function provides no gaurdrails or safe API for registering a plugin.
21    /// It can call into non-rust external code.
22    /// Dsp descriptions are intended to be retrieved from a plugin's C API, so it's not feasible to provide a safe API for this function.
23    pub unsafe fn register_plugin(
24        &self,
25        dsp_description: *const FMOD_DSP_DESCRIPTION,
26    ) -> Result<()> {
27        unsafe {
28            FMOD_Studio_System_RegisterPlugin(self.inner.as_ptr(), dsp_description).to_result()
29        }
30    }
31
32    /// Unregisters a plugin DSP.
33    ///
34    /// # Safety
35    ///
36    /// This function provides no gaurdrails or safe API for unregistering a plugin.
37    /// It can call into non-rust external code.
38    pub unsafe fn unregister_plugin(&self, name: &Utf8CStr) -> Result<()> {
39        unsafe {
40            FMOD_Studio_System_UnregisterPlugin(self.inner.as_ptr(), name.as_ptr()).to_result()
41        }
42    }
43}