fmod/core/channel_group/
channel_management.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 std::ffi::c_int;
9
10use crate::{Channel, ChannelGroup};
11
12impl ChannelGroup {
13    /// Retrieves the number of Channels that feed into to this group.
14    pub fn get_channel_count(&self) -> Result<c_int> {
15        let mut count = 0;
16        unsafe { FMOD_ChannelGroup_GetNumChannels(self.inner, &mut count).to_result()? }
17        Ok(count)
18    }
19
20    /// Retrieves the Channel at the specified index in the list of Channel inputs.
21    pub fn get_channel(&self, index: c_int) -> Result<Channel> {
22        let mut channel = std::ptr::null_mut();
23        unsafe { FMOD_ChannelGroup_GetChannel(self.inner, index, &mut channel).to_result()? }
24        Ok(channel.into())
25    }
26}