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
// 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::*;
use lanyard::Utf8CStr;

use crate::studio::System;

impl System {
    /// Registers a plugin DSP.
    ///
    /// Plugin DSPs used by an event must be registered using this function before loading the bank containing the event.
    ///
    /// # Safety
    ///
    /// This function provides no gaurdrails or safe API for registering a plugin.
    /// It can call into non-rust external code.
    /// 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.
    /// TODO
    pub unsafe fn register_plugin(
        &self,
        dsp_description: *const FMOD_DSP_DESCRIPTION,
    ) -> Result<()> {
        unsafe { FMOD_Studio_System_RegisterPlugin(self.inner, dsp_description).to_result() }
    }

    /// Unregisters a plugin DSP.
    ///
    /// # Safety
    ///
    /// This function provides no gaurdrails or safe API for unregistering a plugin.
    /// It can call into non-rust external code.
    /// TODO
    pub unsafe fn unregister_plugin(&self, name: &Utf8CStr) -> Result<()> {
        unsafe { FMOD_Studio_System_UnregisterPlugin(self.inner, name.as_ptr()).to_result() }
    }
}