alsaseq 0.8.0

API binding for alsaseq library
Documentation
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::ffi;
use glib::{
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    /// A GObject-derived object to express information of pool owned by client.
    ///
    /// A [`ClientPool`][crate::ClientPool] is a GObject-derived object to express information of pool owned by
    /// client. The pool consists of a batch of cells to store message contents in kernel space. The
    /// call of [`client_pool()`][crate::client_pool()] returns the instance of object. The call of
    /// [`UserClientExt::set_pool()`][crate::prelude::UserClientExt::set_pool()]) and [`UserClientExtManual::pool()`][crate::prelude::UserClientExtManual::pool()] require the instance of object.
    ///
    /// The object wraps `struct snd_seq_client_pool` in UAPI of Linux sound subsystem.
    ///
    /// ## Properties
    ///
    ///
    /// #### `client-id`
    ///  The numeric ID of client. One of [`SpecificClientId`][crate::SpecificClientId] is available as well as any
    /// numeric value.
    ///
    /// Readable
    ///
    ///
    /// #### `input-free`
    ///  The current number of free cells in memory pool for input direction.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `input-pool`
    ///  The total number of cells in memory pool for input direction. The client dequeue any event
    /// from the pool when the event is copied from the output memory pool of source client.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `output-free`
    ///  The current number of free cells in memory pool for output direction.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `output-pool`
    ///  The total number of cells in memory pool for output direction. The client enqueue any event
    /// into the pool at scheduling, then the event is copied to input memory pool of destination
    /// client.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `output-room`
    ///  The number of cells in memory pool for output direction as threshold for writable condition
    /// at the result of poll(2). The property is useless for [`UserClient`][crate::UserClient] since it doesn't
    /// perform poll(2) to check writable or not.
    ///
    /// Readable | Writeable
    ///
    /// # Implements
    ///
    /// [`ClientPoolExt`][trait@crate::prelude::ClientPoolExt]
    #[doc(alias = "ALSASeqClientPool")]
    pub struct ClientPool(Object<ffi::ALSASeqClientPool, ffi::ALSASeqClientPoolClass>);

    match fn {
        type_ => || ffi::alsaseq_client_pool_get_type(),
    }
}

impl ClientPool {
    pub const NONE: Option<&'static ClientPool> = None;

    #[doc(alias = "alsaseq_client_pool_new")]
    pub fn new() -> ClientPool {
        unsafe { from_glib_full(ffi::alsaseq_client_pool_new()) }
    }
}

impl Default for ClientPool {
    fn default() -> Self {
        Self::new()
    }
}

/// Trait containing all [`struct@ClientPool`] methods.
///
/// # Implementors
///
/// [`ClientPool`][struct@crate::ClientPool]
pub trait ClientPoolExt: IsA<ClientPool> + 'static {
    /// The numeric ID of client. One of [`SpecificClientId`][crate::SpecificClientId] is available as well as any
    /// numeric value.
    #[doc(alias = "client-id")]
    fn client_id(&self) -> u8 {
        ObjectExt::property(self.as_ref(), "client-id")
    }

    /// The current number of free cells in memory pool for input direction.
    #[doc(alias = "input-free")]
    fn input_free(&self) -> u32 {
        ObjectExt::property(self.as_ref(), "input-free")
    }

    /// The current number of free cells in memory pool for input direction.
    #[doc(alias = "input-free")]
    fn set_input_free(&self, input_free: u32) {
        ObjectExt::set_property(self.as_ref(), "input-free", input_free)
    }

    /// The total number of cells in memory pool for input direction. The client dequeue any event
    /// from the pool when the event is copied from the output memory pool of source client.
    #[doc(alias = "input-pool")]
    fn input_pool(&self) -> u32 {
        ObjectExt::property(self.as_ref(), "input-pool")
    }

    /// The total number of cells in memory pool for input direction. The client dequeue any event
    /// from the pool when the event is copied from the output memory pool of source client.
    #[doc(alias = "input-pool")]
    fn set_input_pool(&self, input_pool: u32) {
        ObjectExt::set_property(self.as_ref(), "input-pool", input_pool)
    }

    /// The current number of free cells in memory pool for output direction.
    #[doc(alias = "output-free")]
    fn output_free(&self) -> u32 {
        ObjectExt::property(self.as_ref(), "output-free")
    }

    /// The current number of free cells in memory pool for output direction.
    #[doc(alias = "output-free")]
    fn set_output_free(&self, output_free: u32) {
        ObjectExt::set_property(self.as_ref(), "output-free", output_free)
    }

    /// The total number of cells in memory pool for output direction. The client enqueue any event
    /// into the pool at scheduling, then the event is copied to input memory pool of destination
    /// client.
    #[doc(alias = "output-pool")]
    fn output_pool(&self) -> u32 {
        ObjectExt::property(self.as_ref(), "output-pool")
    }

    /// The total number of cells in memory pool for output direction. The client enqueue any event
    /// into the pool at scheduling, then the event is copied to input memory pool of destination
    /// client.
    #[doc(alias = "output-pool")]
    fn set_output_pool(&self, output_pool: u32) {
        ObjectExt::set_property(self.as_ref(), "output-pool", output_pool)
    }

    /// The number of cells in memory pool for output direction as threshold for writable condition
    /// at the result of poll(2). The property is useless for [`UserClient`][crate::UserClient] since it doesn't
    /// perform poll(2) to check writable or not.
    #[doc(alias = "output-room")]
    fn output_room(&self) -> u32 {
        ObjectExt::property(self.as_ref(), "output-room")
    }

    /// The number of cells in memory pool for output direction as threshold for writable condition
    /// at the result of poll(2). The property is useless for [`UserClient`][crate::UserClient] since it doesn't
    /// perform poll(2) to check writable or not.
    #[doc(alias = "output-room")]
    fn set_output_room(&self, output_room: u32) {
        ObjectExt::set_property(self.as_ref(), "output-room", output_room)
    }

    #[doc(alias = "client-id")]
    fn connect_client_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_client_id_trampoline<
            P: IsA<ClientPool>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::ALSASeqClientPool,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(ClientPool::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::client-id".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_client_id_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "input-free")]
    fn connect_input_free_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_input_free_trampoline<
            P: IsA<ClientPool>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::ALSASeqClientPool,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(ClientPool::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::input-free".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_input_free_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "input-pool")]
    fn connect_input_pool_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_input_pool_trampoline<
            P: IsA<ClientPool>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::ALSASeqClientPool,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(ClientPool::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::input-pool".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_input_pool_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "output-free")]
    fn connect_output_free_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_output_free_trampoline<
            P: IsA<ClientPool>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::ALSASeqClientPool,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(ClientPool::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::output-free".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_output_free_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "output-pool")]
    fn connect_output_pool_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_output_pool_trampoline<
            P: IsA<ClientPool>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::ALSASeqClientPool,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(ClientPool::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::output-pool".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_output_pool_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "output-room")]
    fn connect_output_room_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_output_room_trampoline<
            P: IsA<ClientPool>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::ALSASeqClientPool,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(ClientPool::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::output-room".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_output_room_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl<O: IsA<ClientPool>> ClientPoolExt for O {}