1use fmod_sys::*;
8use std::ops::Deref;
9
10use crate::ChannelControl;
11
12mod information;
13mod playback_control;
14
15#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
16#[repr(transparent)] pub struct Channel {
18 pub(crate) inner: *mut FMOD_CHANNEL,
19}
20
21unsafe impl Send for Channel {}
22unsafe impl Sync for Channel {}
23
24impl From<*mut FMOD_CHANNEL> for Channel {
25 fn from(value: *mut FMOD_CHANNEL) -> Self {
26 Channel { inner: value }
27 }
28}
29
30impl From<Channel> for *mut FMOD_CHANNEL {
31 fn from(value: Channel) -> Self {
32 value.inner
33 }
34}
35
36impl Deref for Channel {
37 type Target = ChannelControl;
38
39 fn deref(&self) -> &Self::Target {
40 #[cfg(debug_assertions)]
41 unsafe {
42 let control = FMOD_Channel_CastToControl(self.inner);
44 assert_eq!(
45 control as usize, self.inner as usize,
46 "ChannelControl cast was not equivalent! THIS IS A MAJOR BUG. PLEASE REPORT THIS!"
47 );
48 }
49 unsafe { &*std::ptr::from_ref(self).cast::<ChannelControl>() }
52 }
53}