libpulse_sys/mainloop/
threaded.rs

1// Copyright 2017 Lyndon Brown
2//
3// This file is part of the PulseAudio Rust language linking library.
4//
5// Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not
6// copy, modify, or distribute this file except in compliance with said license. You can find copies
7// of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at
8// <http://opensource.org/licenses/MIT> and <http://www.apache.org/licenses/LICENSE-2.0>
9// respectively.
10//
11// Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a
12// fair-use basis, as discussed in the overall project readme (available in the git repository).
13
14//! A variation of the standard main loop implementation, using a background thread.
15
16use std::os::raw::c_char;
17#[cfg(any(doc, feature = "pa_v13"))]
18use std::os::raw::c_void;
19use crate::mainloop::api::pa_mainloop_api;
20
21/// An opaque threaded main loop object.
22#[repr(C)] pub struct pa_threaded_mainloop { _private: [u8; 0] }
23
24#[rustfmt::skip]
25#[link(name = "pulse")]
26extern "C" {
27    pub fn pa_threaded_mainloop_new() -> *mut pa_threaded_mainloop;
28    pub fn pa_threaded_mainloop_free(m: *mut pa_threaded_mainloop);
29    pub fn pa_threaded_mainloop_start(m: *mut pa_threaded_mainloop) -> i32;
30    pub fn pa_threaded_mainloop_stop(m: *mut pa_threaded_mainloop);
31    pub fn pa_threaded_mainloop_lock(m: *mut pa_threaded_mainloop);
32    pub fn pa_threaded_mainloop_unlock(m: *mut pa_threaded_mainloop);
33    pub fn pa_threaded_mainloop_wait(m: *mut pa_threaded_mainloop);
34    pub fn pa_threaded_mainloop_signal(m: *mut pa_threaded_mainloop, wait_for_accept: i32);
35    pub fn pa_threaded_mainloop_accept(m: *mut pa_threaded_mainloop);
36    pub fn pa_threaded_mainloop_get_retval(m: *const pa_threaded_mainloop) -> i32;
37    pub fn pa_threaded_mainloop_get_api(m: *const pa_threaded_mainloop) -> *const pa_mainloop_api;
38    pub fn pa_threaded_mainloop_in_thread(m: *mut pa_threaded_mainloop) -> i32;
39    pub fn pa_threaded_mainloop_set_name(m: *mut pa_threaded_mainloop, name: *const c_char);
40    #[cfg(any(doc, feature = "pa_v13"))]
41    #[cfg_attr(docsrs, doc(cfg(feature = "pa_v13")))]
42    pub fn pa_threaded_mainloop_once_unlocked(m: *mut pa_threaded_mainloop, callback: extern "C" fn(m: *mut pa_threaded_mainloop, userdata: *mut c_void), userdata: *mut c_void);
43}