fmod/studio/system/command_replay.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::*;
8use lanyard::Utf8CStr;
9
10use crate::studio::{CommandCaptureFlags, CommandReplay, CommandReplayFlags, System};
11
12impl System {
13 /// Recording Studio commands to a file.
14 ///
15 /// The commands generated by the FMOD Studio API can be captured and later replayed for debug and profiling purposes.
16 ///
17 /// Unless the [`CommandCaptureFlags::SKIP_INITIAL_STATE`] flag is specified, the command capture will first record the set of all banks and event instances that currently exist.
18 pub fn start_command_capture(
19 &self,
20 filename: &Utf8CStr,
21 flags: CommandCaptureFlags,
22 ) -> Result<()> {
23 unsafe {
24 FMOD_Studio_System_StartCommandCapture(self.inner, filename.as_ptr(), flags.into())
25 .to_result()
26 }
27 }
28
29 /// Stop recording Studio commands.
30 pub fn stop_command_capture(&self) -> Result<()> {
31 unsafe { FMOD_Studio_System_StopCommandCapture(self.inner).to_result() }
32 }
33
34 /// Load a command replay.
35 pub fn load_command_replay(
36 &self,
37 filename: &Utf8CStr,
38 flags: CommandReplayFlags,
39 ) -> Result<CommandReplay> {
40 let mut replay = std::ptr::null_mut();
41 unsafe {
42 FMOD_Studio_System_LoadCommandReplay(
43 self.inner,
44 filename.as_ptr(),
45 flags.into(),
46 &mut replay,
47 )
48 .to_result()?;
49 Ok(CommandReplay::from(replay))
50 }
51 }
52}