fmod/core/dsp/
channel_format.rs1use fmod_sys::*;
8use std::ffi::c_int;
9
10use crate::{ChannelMask, Dsp, SpeakerMode};
11use crate::{FmodResultExt, Result};
12
13impl Dsp {
14 pub fn set_channel_format(
18 &self,
19 channel_mask: ChannelMask,
20 channel_count: c_int,
21 source_speaker_mode: SpeakerMode,
22 ) -> Result<()> {
23 unsafe {
24 FMOD_DSP_SetChannelFormat(
25 self.inner.as_ptr(),
26 channel_mask.into(),
27 channel_count,
28 source_speaker_mode.into(),
29 )
30 .to_result()
31 }
32 }
33
34 pub fn get_channel_format(&self) -> Result<(ChannelMask, c_int, SpeakerMode)> {
36 let mut channel_mask = 0;
37 let mut channel_count = 0;
38 let mut source_speaker_mode = 0;
39 unsafe {
40 FMOD_DSP_GetChannelFormat(
41 self.inner.as_ptr(),
42 &raw mut channel_mask,
43 &raw mut channel_count,
44 &raw mut source_speaker_mode,
45 )
46 .to_result()?;
47 }
48 let source_speaker_mode = source_speaker_mode.try_into()?;
49 Ok((channel_mask.into(), channel_count, source_speaker_mode))
50 }
51
52 pub fn get_output_channel_format(
54 &self,
55 in_mask: ChannelMask,
56 in_channels: c_int,
57 in_speaker_mode: SpeakerMode,
58 ) -> Result<(ChannelMask, c_int, SpeakerMode)> {
59 let mut out_mask = 0;
60 let mut out_channels = 0;
61 let mut out_speaker_mode = 0;
62 unsafe {
63 FMOD_DSP_GetOutputChannelFormat(
64 self.inner.as_ptr(),
65 in_mask.into(),
66 in_channels,
67 in_speaker_mode.into(),
68 &raw mut out_mask,
69 &raw mut out_channels,
70 &raw mut out_speaker_mode,
71 )
72 .to_result()?;
73 }
74 let out_speaker_mode = out_speaker_mode.try_into()?;
75 Ok((out_mask.into(), out_channels, out_speaker_mode))
76 }
77}