libpulse-sys-1.21.0/.cargo_vcs_info.json0000644000000001470000000000100135520ustar { "git": { "sha1": "dfb3b5d2beabc04556a0bb6b31cc998861aa52c8" }, "path_in_vcs": "pulse-sys" }libpulse-sys-1.21.0/CHANGELOG.md000064400000000000000000000234471046102023000141630ustar 00000000000000# 1.21.0 (July 18th, 2023) * Fixed warning from clashing namespace exports. * Fixed docs.rs build failure. * Dropped PA v4 support. # 1.20.1 (January 9th, 2023) * Fixed broken build status badge in readme. # 1.20.0 (January 9th, 2023) * Bumped Rust edition to 2021. * Bumped MSRV from 1.46 to 1.56. * Added `rust-version` (MSRV) attribute to `cargo.toml` file. # 1.19.3 (December 7th, 2021) * Fixed handling of pkg-config failure handling due to change in `pkg-config` crate. Thanks to @fredszaq on github for the initial patch. # 1.19.2 (August 29th, 2021) * Minor formatting tweaks. * Bumped MSRV from 1.41 to 1.46. * Marked `pa_check_version` and `pa_clamp_volume` as `const fn`. # 1.19.1 (July 29th, 2021) * Fixed feature guard mistake in `version` mod causing docs.rs build to fail. # 1.19.0 (July 28th, 2021) * Added PA v15 support (API additions). # 1.18.0 (January 30th, 2021) * Now using intra-doc-linking introduced in Rust 1.48. The MSRV remains unchanged at 1.41; this is too great a simplification to maintaining documentation to not implement immediately; the only negative is that links will be broken in locally generated documentation when built with an older Rust compiler than version 1.48. # 1.17.0 (December 22nd, 2020) * Tweaked version constants. * Deprecated `pa_check_version()`. # 1.16.2 (December 15th, 2020) * Nothing notable. # 1.16.1 (December 15th, 2020) * Fixed mistake made trying to conditionally enable `#[cfg(doc)]` for docs.rs. # 1.16.0 (December 14th, 2020) * Made some changes to cargo features: - Removed the now obsolete `dox` cargo feature. - Removed the `pa_latest` and `pa_latest_common` cargo features. - Changed the default version feature level to `pa_v8`. * MSRV bumped from 1.40 to 1.41. * Changed `PA_CHANNELS_MAX` from `usize` to `u8`. * Made use of `#[cfg(doc)]` to always include stuff behind PA version feature guards in generated documentation. (Required bump of minimum supported Rust version from 1.40 to 1.41). * Added support for feature tagging in documentation (requires nightly Rust version, so only enabled if a certain config flag is used, as for the docs.rs copy). * Marked `version::Compatibility` as `#[non_exhaustive]`. # 1.15.3 (December 11th, 2020) * Fixed incorrect `PA_SOURCE_DYNAMIC_LATENCY` flag value. Was mistakenly `0x42` instead of `0x40` (thus combined with `PA_SOURCE_LATENCY`). # 1.15.2 (December 8th, 2020) * Added missing `Default` implementation for `channelmap::pa_channel_map_def_t`. * Added documentation for `pa_check_version()`. If you use it, please double check that it actually does what you think it does. It does **not** involve talking to the client library. # 1.15.1 (November 25th, 2020) * Fixed deprecated license attribute syntax. # 1.15.0 (November 25th, 2020) * Marked `pa_encoding_t` as `#[non_exhaustive]`. * Added derive of `FromPrimitive` and `ToPrimitive` from the `num-derive` crate on enums. * Updated required dependencies: - `num-traits` 0.2 now required. - `num-derive` 0.3 now required. # 1.14.1 (November 25th, 2020) * Fixed missing rename of `pa_error_code_t::Io` to `pa_error_code_t::IO` to match change in binding. # 1.14.0 (November 24th, 2020) * Added PA v14 support (API additions). # 1.13.3 (November 21st, 2020) * Trivial documentation fixes. # 1.13.2 (September 9th, 2020) * Bumped `pa_latest_common` feature to target PA v13. # 1.13.1 (June 2nd, 2020) * Fixed output of build script warning when pkg-config is missing (thanks to @cole-h on github!). # 1.13.0 (April 18th, 2020) * Removed deprecated Cargo features. # 1.12.1 (December 29th, 2019) * Improved the non-pkg-config fallback for lib linking. # 1.12.0 (December 29th, 2019) * Now using pkg-config in build script for more than just Linux. # 1.11.1 (December 27th, 2019) * Fixed an issue compiling on Windows (needed to reference a different `pollfd` definition). Thanks to @allquixotic on github for reporting. # 1.11.0 (September 17th, 2019) * Changed the license model from LGPL to dual MIT and Apache-2.0. See [here][issue26] for details. # 1.10.0 (September 15th, 2019) * Implemented PA v13 enhancements. * Added PA v13 compatibility control feature. # 1.9.1 (August 19th, 2019) * Fixed broken doc.rs documentation generation. # 1.9.0 (August 19th, 2019) * Extended support to even older versions of PA, specifically up to and including v4. * Improved the build script. * Revised `version::Compatibility` variants to make more sense. * Simplified feature flags, old ones left as temorary aliases, to be removed later. * Added a `dox` feature flag, for use with `cargo doc`. It enables the very latest PA version compatibility, while bypassing the pkg-config check, thus is useful for generating documentation that includes information on features from versions of PA that may be newer than the version you have installed. * Improved version documentation further. # 1.8.1 (August 17th, 2019) * Version: Improved mod documentation. # 1.8.0 (August 15th, 2019) * Updated `use` conventions to that of Rust 1.30/1.31. * Specified edition in toml file. * Made the following functions `const`: - `version::get_compatibility()`. - `channelmap::pa_channel_position_mask()`. - `volume::pa_volume_is_valid()`. - `context::subscribe::pa_subscription_match_flags()`. * Version: purged deprecated items. Note: version 1.7 skipped, used only for `libpulse-mainloop-glib-sys` crate changes. # 1.6.0 (August 12th, 2019) * Replaced use of empty enums for opaque types with a struct based alternative. According to the Rust nomicon ([here][nomicon-ros]) the use of the empty enum trick is apparently undefined behaviour. * Added a new `latest_pa_common_compatibility` feature flag, used by default now instead of `latest_pa_compatibility`. # 1.5.0 (December 22nd, 2018) * Added the new `latest_pa_compatibility` and `pa_v12_compatibility` feature flags, and deprecated `pa_encoding_from_string` in favour of `pa_v12_compatibility`. # 1.4.0 (November 4th, 2018) * Switched to using package-config for linking (though retaining the direct linking as a fallback for those without the necessary *.pc files installed). Thanks to @JohnAZoidberg on github for the original patch. * Improved the `version` mod: - Constants now vary depending upon backwards compatibility flags, correctly indicating the newest supported PA version. - Added the `Compatibility` enum and `get_compatibility()` function. - Renamed `LINK_TARGET_VERSION` to `TARGET_VERSION_STRING`. - Introduced `TARGET_VERSION` and deprecated `PA_MAJOR`, `PA_MINOR` and `PA_MICRO`. - Deprecated `get_headers_version()`. * Clarified PA version compatibility in `version` mod. * Clarified `pa_encoding_from_string` feature purpose. # 1.3.4 (October 8th, 2018) * Fixed broken attempt to include license file in bundled package. # 1.3.3 (October 8th, 2018) * Added dedicated changelog, split off from the old single project overview one. * Included copy of license file in bundled package and excluded the `.gitignore` file. Note, version number 1.3.2 skipped, bumping number into line with the other crates. # 1.3.1 (September 3rd, 2018) * Added homepage and repo links, thanks to @berkus on github for the patch. # 1.3 (July 17th, 2018) * Mainloop API objects now correctly treated as immutable, per related change in version 2.1 of `libpulse-binding`. * Default-enabled inclusion of the `pa_encoding_from_string` function symbol, which was missing from PA’s symbol file and thus not available in the client library before v12. # 1.2.1 (June 26th, 2018) * Updated declared PA version compatibility (11.0 → 12.0). # 1.2 (June 16th, 2018) * Context: Handful of functions changed to take `const` pointers. In version 1.1 many functions throughout the API were changed to take `const` pointers, with respective patches sent in to PA itself (which have since been accepted). Some context related functions were skipped over then however due to a complication with an artefact relating to validation checks. Additional patches solving this have now been created and sent in to the PA project. Discussion with PA devs indicates that this change will be accepted, so pre-emtively pushing the change here in our representation of the API; logically they should be immutable, and we do not need to propagate this unfortunate artefact). * Introspect & subscribe: Purged autoload API (deprecated in PA since 2009). # 1.1 (May 27th, 2018) * Various functions have been changed to take immutable `const` pointers. There are numerous functions in the C API which take mutable pointers to objects where there is no intention to actually mutate those objects. Patches have been sent in to the PA project to correct many of these cases. There was no point in waiting for those to be accepted before fixing our representation of the API here, since the change is so obviously correct. # 1.0.5 (May 27th, 2018) * Minor, non-functional consistency fix only. Note, some version numbers skipped, bumping number into line with the other crates. # 1.0.2 (February 9th, 2018) * Added travis badge. # 1.0.1 (February 2nd, 2018) * Fixed toml file license string `LGPL-2.1` → `LGPL-2.1+`. * Fixed toml file missing author email address. # 1.0 (January 24th, 2018) * Original release. (By the new crate owner with the replacement codebase). # 0.0.0 (January 11th, 2016) This was the original version available on crates.io, built by a different author in a different code repository. Version 1.0 above represents the first published version from the replacement codebase. (To be clear, version 0.0.0 cannot be found in the current repository). [issue26]: https://github.com/jnqnfe/pulse-binding-rust/issues/26 [nomicon-ros]: https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs libpulse-sys-1.21.0/Cargo.toml0000644000000027440000000000100115550ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" rust-version = "1.56" name = "libpulse-sys" version = "1.21.0" authors = ["Lyndon Brown "] build = "build.rs" links = "pulse" exclude = ["README.md"] description = "FFI bindings for the PulseAudio libpulse system library." homepage = "https://github.com/jnqnfe/pulse-binding-rust" readme = "README.md" keywords = [ "ffi", "pulseaudio", "audio", ] license = "MIT OR Apache-2.0" repository = "https://github.com/jnqnfe/pulse-binding-rust" [package.metadata.docs.rs] all-features = false no-default-features = true rustdoc-args = [ "--cfg", "docsrs", ] [dependencies.libc] version = "0.2" [dependencies.num-derive] version = "0.3" [dependencies.num-traits] version = "0.2" [build-dependencies.pkg-config] version = "0.3.23" [features] default = ["pa_v8"] pa_v12 = ["pa_v8"] pa_v13 = ["pa_v12"] pa_v14 = ["pa_v13"] pa_v15 = ["pa_v14"] pa_v6 = [] pa_v8 = ["pa_v6"] [target."cfg(windows)".dependencies.winapi] version = "0.3" features = ["winsock2"] default-features = false libpulse-sys-1.21.0/Cargo.toml.orig000064400000000000000000000020521046102023000152260ustar 00000000000000[package] edition = "2021" name = "libpulse-sys" version = "1.21.0" authors = ["Lyndon Brown "] license = "MIT OR Apache-2.0" readme = "README.md" description = "FFI bindings for the PulseAudio libpulse system library." keywords = ["ffi", "pulseaudio", "audio"] homepage = "https://github.com/jnqnfe/pulse-binding-rust" repository = "https://github.com/jnqnfe/pulse-binding-rust" exclude = ["README.md"] links = "pulse" build = "build.rs" rust-version = "1.56" [dependencies] libc = "0.2" num-traits = "0.2" num-derive = "0.3" [target.'cfg(windows)'.dependencies] winapi = { version = "0.3", features = ["winsock2"], default-features = false } [build-dependencies] pkg-config = "0.3.23" [features] default = ["pa_v8"] # PA version compatibility selection # See the overall project `COMPATIBILITY.md` file for explanation. pa_v15 = ["pa_v14"] pa_v14 = ["pa_v13"] pa_v13 = ["pa_v12"] pa_v12 = ["pa_v8"] pa_v8 = ["pa_v6"] pa_v6 = [] [package.metadata.docs.rs] all-features = false no-default-features = true rustdoc-args = ["--cfg", "docsrs"] libpulse-sys-1.21.0/LICENSE-APACHE000064400000000000000000000251371046102023000142740ustar 00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. libpulse-sys-1.21.0/LICENSE-MIT000064400000000000000000000020401046102023000137700ustar 00000000000000Copyright (c) 2019 Lyndon Brown Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. libpulse-sys-1.21.0/README.md000064400000000000000000000044041046102023000136210ustar 00000000000000libpulse-sys ============ [GitHub Workflow Status](https://github.com/jnqnfe/pulse-binding-rust/actions) [crates.io](https://crates.io/crates/libpulse-sys) [docs.rs](https://docs.rs/libpulse-sys) [min-rust-version](https://rust-lang.github.io/rfcs/2495-min-rust-version.html) FFI bindings for the PulseAudio libpulse system library. See also the higher-level [`libpulse-binding`](https://crates.io/crates/libpulse-binding) crate. ## Usage Add this crate to the dependencies specified in your `Cargo.toml`: ```toml [dependencies] libpulse-sys = "1.0" ``` Though you may wish to rename the crate to a shorter name (for example `pulse`) for cleaner references within your code: ```toml [dependencies] pulse = { version = "1.0", package = "libpulse-sys" } ``` An alternative to that which some may prefer is: ```toml [dependencies.pulse] version = "1.0" package = "libpulse-sys" ``` ### PulseAudio version compatibility The default functionality provided is support for PulseAudio version 8.0 or newer. This should be good enough for most needs, however if you _need_ to use something only available in a newer version then you can select the corresponding version compatibility feature to raise the minimum compatibility level. You can also reduce support down to even older versions if you wish. See the overall project `COMPATIBILITY.md` file for further details. ## License Licensed under either of * [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) * [MIT license](http://opensource.org/licenses/MIT) at your option. ### Contribution Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. libpulse-sys-1.21.0/build.rs000064400000000000000000000060331046102023000140070ustar 00000000000000fn main() { // Skip pkg-config check if just generating documentation. if std::env::var_os("DOCS_RS").is_some() { return; } let lib_name = "libpulse"; let fallback_name = { #[cfg(target_os = "linux")] { "pulse::libpulse.so.0" } #[cfg(target_os = "macos")] { "pulse::libpulse.0.dylib" } #[cfg(windows)] { "pulse::libpulse-0.dll" } #[cfg(not(any(target_os = "linux", target_os = "macos", windows)))] { "pulse" } }; let min_version = { #[cfg(feature = "pa_v15")] { "15.0" } #[cfg(all(feature = "pa_v14", not(feature = "pa_v15")))] { "14.0" } #[cfg(all(feature = "pa_v13", not(feature = "pa_v14")))] { "13.0" } #[cfg(all(feature = "pa_v12", not(feature = "pa_v13")))] { "12.0" } #[cfg(all(feature = "pa_v8", not(feature = "pa_v12")))] { "8.0" } #[cfg(all(feature = "pa_v6", not(feature = "pa_v8")))] { "6.0" } #[cfg(not(feature = "pa_v6"))] { "5.0" } }; let mut config = pkg_config::Config::new(); // Has the user got pkg-config and the PA pkg-config file installed (via dev package)? // This is a little crude, since impossible to reliably distinguish between pkg-config errors // (it only gives strings, and they could be translated). We perform a non-version specific // check here, and disable generation of cargo meta data, thus doing a 'exists' type check. config.cargo_metadata(false); let fallback = match config.probe(lib_name) { // We assume all failure here (being a non-version specific check) indicates no *.pc file Err(pkg_config::Error::ProbeFailure { .. }) | Err(pkg_config::Error::Failure { .. }) => { println!("cargo:warning=Pkg-config seems to not know about PulseAudio (dev package not installed?), \ trying generic fallback..."); true }, // Also allow fallback if pkg-config not installed, or disabled Err(pkg_config::Error::EnvNoPkgConfig(_)) | Err(pkg_config::Error::Command { .. }) => { println!("cargo:warning=No pkg-config or disabled, trying generic fallback..."); true }, // In all other cases we will perform a version-specfic check and honor the result _ => false, }; // If the user does not have pkg-config or the PA *.pc file (they have not installed the dev // package), then let’s try a default fallback (having to install dev packages for Rust // development is unnatural imo, ideally distros should start shipping *.pc files differently). if fallback { println!("cargo:rustc-link-lib={}", fallback_name); return; } config.cargo_metadata(true) .atleast_version(min_version); // Do version specific pkg-config check and honor result match config.probe(lib_name) { Err(e) => { println!("cargo:warning={}", e); std::process::exit(1); }, Ok(_) => {}, } } libpulse-sys-1.21.0/src/channelmap.rs000064400000000000000000000274561046102023000156210ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Constants and routines for handing channel mapping. use std::os::raw::c_char; use num_derive::{FromPrimitive, ToPrimitive}; use crate::sample::pa_sample_spec; pub type pa_channel_position_mask_t = u64; #[inline(always)] pub const fn pa_channel_position_mask(pos: pa_channel_position_t) -> pa_channel_position_mask_t { 1u64 << (pos as pa_channel_position_mask_t) } #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(FromPrimitive, ToPrimitive)] pub enum pa_channel_position_t { Invalid = -1, Mono = 0, FrontLeft, FrontRight, FrontCenter, RearCenter, RearLeft, RearRight, Lfe, FrontLeftOfCenter, FrontRightOfCenter, SideLeft, SideRight, Aux0, Aux1, Aux2, Aux3, Aux4, Aux5, Aux6, Aux7, Aux8, Aux9, Aux10, Aux11, Aux12, Aux13, Aux14, Aux15, Aux16, Aux17, Aux18, Aux19, Aux20, Aux21, Aux22, Aux23, Aux24, Aux25, Aux26, Aux27, Aux28, Aux29, Aux30, Aux31, TopCenter, TopFrontLeft, TopFrontRight, TopFrontCenter, TopRearLeft, TopRearRight, TopRearCenter, } pub const PA_CHANNEL_POSITION_MAX: usize = 51; pub const PA_CHANNEL_POSITION_INVALID: pa_channel_position_t = pa_channel_position_t::Invalid; pub const PA_CHANNEL_POSITION_MONO: pa_channel_position_t = pa_channel_position_t::Mono; pub const PA_CHANNEL_POSITION_LEFT: pa_channel_position_t = pa_channel_position_t::FrontLeft; pub const PA_CHANNEL_POSITION_RIGHT: pa_channel_position_t = pa_channel_position_t::FrontRight; pub const PA_CHANNEL_POSITION_CENTER: pa_channel_position_t = pa_channel_position_t::FrontCenter; pub const PA_CHANNEL_POSITION_FRONT_LEFT: pa_channel_position_t = pa_channel_position_t::FrontLeft; pub const PA_CHANNEL_POSITION_FRONT_RIGHT: pa_channel_position_t = pa_channel_position_t::FrontRight; pub const PA_CHANNEL_POSITION_FRONT_CENTER: pa_channel_position_t = pa_channel_position_t::FrontCenter; pub const PA_CHANNEL_POSITION_REAR_CENTER: pa_channel_position_t = pa_channel_position_t::RearCenter; pub const PA_CHANNEL_POSITION_REAR_LEFT: pa_channel_position_t = pa_channel_position_t::RearLeft; pub const PA_CHANNEL_POSITION_REAR_RIGHT: pa_channel_position_t = pa_channel_position_t::RearRight; pub const PA_CHANNEL_POSITION_LFE: pa_channel_position_t = pa_channel_position_t::Lfe; pub const PA_CHANNEL_POSITION_SUBWOOFER: pa_channel_position_t = pa_channel_position_t::Lfe; pub const PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER: pa_channel_position_t = pa_channel_position_t::FrontLeftOfCenter; pub const PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER: pa_channel_position_t = pa_channel_position_t::FrontRightOfCenter; pub const PA_CHANNEL_POSITION_SIDE_LEFT: pa_channel_position_t = pa_channel_position_t::SideLeft; pub const PA_CHANNEL_POSITION_SIDE_RIGHT: pa_channel_position_t = pa_channel_position_t::SideRight; pub const PA_CHANNEL_POSITION_AUX0: pa_channel_position_t = pa_channel_position_t::Aux0; pub const PA_CHANNEL_POSITION_AUX1: pa_channel_position_t = pa_channel_position_t::Aux1; pub const PA_CHANNEL_POSITION_AUX2: pa_channel_position_t = pa_channel_position_t::Aux2; pub const PA_CHANNEL_POSITION_AUX3: pa_channel_position_t = pa_channel_position_t::Aux3; pub const PA_CHANNEL_POSITION_AUX4: pa_channel_position_t = pa_channel_position_t::Aux4; pub const PA_CHANNEL_POSITION_AUX5: pa_channel_position_t = pa_channel_position_t::Aux5; pub const PA_CHANNEL_POSITION_AUX6: pa_channel_position_t = pa_channel_position_t::Aux6; pub const PA_CHANNEL_POSITION_AUX7: pa_channel_position_t = pa_channel_position_t::Aux7; pub const PA_CHANNEL_POSITION_AUX8: pa_channel_position_t = pa_channel_position_t::Aux8; pub const PA_CHANNEL_POSITION_AUX9: pa_channel_position_t = pa_channel_position_t::Aux9; pub const PA_CHANNEL_POSITION_AUX10: pa_channel_position_t = pa_channel_position_t::Aux10; pub const PA_CHANNEL_POSITION_AUX11: pa_channel_position_t = pa_channel_position_t::Aux11; pub const PA_CHANNEL_POSITION_AUX12: pa_channel_position_t = pa_channel_position_t::Aux12; pub const PA_CHANNEL_POSITION_AUX13: pa_channel_position_t = pa_channel_position_t::Aux13; pub const PA_CHANNEL_POSITION_AUX14: pa_channel_position_t = pa_channel_position_t::Aux14; pub const PA_CHANNEL_POSITION_AUX15: pa_channel_position_t = pa_channel_position_t::Aux15; pub const PA_CHANNEL_POSITION_AUX16: pa_channel_position_t = pa_channel_position_t::Aux16; pub const PA_CHANNEL_POSITION_AUX17: pa_channel_position_t = pa_channel_position_t::Aux17; pub const PA_CHANNEL_POSITION_AUX18: pa_channel_position_t = pa_channel_position_t::Aux18; pub const PA_CHANNEL_POSITION_AUX19: pa_channel_position_t = pa_channel_position_t::Aux19; pub const PA_CHANNEL_POSITION_AUX20: pa_channel_position_t = pa_channel_position_t::Aux20; pub const PA_CHANNEL_POSITION_AUX21: pa_channel_position_t = pa_channel_position_t::Aux21; pub const PA_CHANNEL_POSITION_AUX22: pa_channel_position_t = pa_channel_position_t::Aux22; pub const PA_CHANNEL_POSITION_AUX23: pa_channel_position_t = pa_channel_position_t::Aux23; pub const PA_CHANNEL_POSITION_AUX24: pa_channel_position_t = pa_channel_position_t::Aux24; pub const PA_CHANNEL_POSITION_AUX25: pa_channel_position_t = pa_channel_position_t::Aux25; pub const PA_CHANNEL_POSITION_AUX26: pa_channel_position_t = pa_channel_position_t::Aux26; pub const PA_CHANNEL_POSITION_AUX27: pa_channel_position_t = pa_channel_position_t::Aux27; pub const PA_CHANNEL_POSITION_AUX28: pa_channel_position_t = pa_channel_position_t::Aux28; pub const PA_CHANNEL_POSITION_AUX29: pa_channel_position_t = pa_channel_position_t::Aux29; pub const PA_CHANNEL_POSITION_AUX30: pa_channel_position_t = pa_channel_position_t::Aux30; pub const PA_CHANNEL_POSITION_AUX31: pa_channel_position_t = pa_channel_position_t::Aux31; pub const PA_CHANNEL_POSITION_TOP_CENTER: pa_channel_position_t = pa_channel_position_t::TopCenter; pub const PA_CHANNEL_POSITION_TOP_FRONT_LEFT: pa_channel_position_t = pa_channel_position_t::TopFrontLeft; pub const PA_CHANNEL_POSITION_TOP_FRONT_RIGHT: pa_channel_position_t = pa_channel_position_t::TopFrontRight; pub const PA_CHANNEL_POSITION_TOP_FRONT_CENTER: pa_channel_position_t = pa_channel_position_t::TopFrontCenter; pub const PA_CHANNEL_POSITION_TOP_REAR_LEFT: pa_channel_position_t = pa_channel_position_t::TopRearLeft; pub const PA_CHANNEL_POSITION_TOP_REAR_RIGHT: pa_channel_position_t = pa_channel_position_t::TopRearRight; pub const PA_CHANNEL_POSITION_TOP_REAR_CENTER: pa_channel_position_t = pa_channel_position_t::TopRearCenter; impl Default for pa_channel_position_t { fn default() -> Self { pa_channel_position_t::Invalid } } /// Channel map definition standards. /// /// Used in having a channel map automatically setup per number of channels and a specific standard. #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(FromPrimitive, ToPrimitive)] pub enum pa_channel_map_def_t { /// The mapping from RFC3551, which is based on AIFF-C. AIFF, /// The default mapping used by ALSA. This mapping is probably not too useful since ALSA’s /// default channel mapping depends on the device string used. ALSA, /// Only aux channels. Aux, /// Microsoft’s WAVEFORMATEXTENSIBLE mapping. This mapping works as if all LSBs of dwChannelMask /// are set. WAVEEx, /// The default channel mapping used by OSS as defined in the OSS 4.0 API specs. This mapping is /// probably not too useful since the OSS API has changed in this respect and no longer knows a /// default channel mapping based on the number of channels. OSS, } pub const PA_CHANNEL_MAP_DEF_MAX: usize = 5; pub const PA_CHANNEL_MAP_AIFF: pa_channel_map_def_t = pa_channel_map_def_t::AIFF; pub const PA_CHANNEL_MAP_ALSA: pa_channel_map_def_t = pa_channel_map_def_t::ALSA; pub const PA_CHANNEL_MAP_AUX: pa_channel_map_def_t = pa_channel_map_def_t::Aux; pub const PA_CHANNEL_MAP_WAVEEX: pa_channel_map_def_t = pa_channel_map_def_t::WAVEEx; pub const PA_CHANNEL_MAP_OSS: pa_channel_map_def_t = pa_channel_map_def_t::OSS; pub const PA_CHANNEL_MAP_DEFAULT: pa_channel_map_def_t = pa_channel_map_def_t::AIFF; impl Default for pa_channel_map_def_t { fn default() -> Self { PA_CHANNEL_MAP_DEFAULT } } #[repr(C)] #[derive(Default, Debug, Copy, Clone)] pub struct pa_channel_map { pub channels: u8, pub map: [pa_channel_position_t; crate::sample::PA_CHANNELS_MAX as usize], } pub const PA_CHANNEL_MAP_SNPRINT_MAX: usize = 336; #[rustfmt::skip] #[link(name = "pulse")] extern "C" { pub fn pa_channel_map_init(m: *mut pa_channel_map) -> *mut pa_channel_map; pub fn pa_channel_map_init_mono(m: *mut pa_channel_map) -> *mut pa_channel_map; pub fn pa_channel_map_init_stereo(m: *mut pa_channel_map) -> *mut pa_channel_map; pub fn pa_channel_map_init_auto(m: *mut pa_channel_map, channels: u32, def: pa_channel_map_def_t) -> *mut pa_channel_map; pub fn pa_channel_map_init_extend(m: *mut pa_channel_map, channels: u32, def: pa_channel_map_def_t) -> *mut pa_channel_map; pub fn pa_channel_position_to_string(pos: pa_channel_position_t) -> *const c_char; pub fn pa_channel_position_from_string(s: *const c_char) -> pa_channel_position_t; pub fn pa_channel_position_to_pretty_string(pos: pa_channel_position_t) -> *const c_char; pub fn pa_channel_map_snprint(s: *mut c_char, l: usize, map: *const pa_channel_map) -> *mut c_char; pub fn pa_channel_map_parse(map: *mut pa_channel_map, s: *const c_char) -> *mut pa_channel_map; pub fn pa_channel_map_equal(a: *const pa_channel_map, b: *const pa_channel_map) -> i32; pub fn pa_channel_map_valid(map: *const pa_channel_map) -> i32; pub fn pa_channel_map_compatible(map: *const pa_channel_map, ss: *const pa_sample_spec) -> i32; pub fn pa_channel_map_superset(a: *const pa_channel_map, b: *const pa_channel_map) -> i32; pub fn pa_channel_map_can_balance(map: *const pa_channel_map) -> i32; pub fn pa_channel_map_can_fade(map: *const pa_channel_map) -> i32; #[cfg(any(doc, feature = "pa_v8"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v8")))] pub fn pa_channel_map_can_lfe_balance(map: *const pa_channel_map) -> i32; pub fn pa_channel_map_to_name(map: *const pa_channel_map) -> *const c_char; pub fn pa_channel_map_to_pretty_name(map: *const pa_channel_map) -> *const c_char; pub fn pa_channel_map_has_position(map: *const pa_channel_map, p: pa_channel_position_t) -> i32; pub fn pa_channel_map_mask(map: *const pa_channel_map) -> pa_channel_position_mask_t; } libpulse-sys-1.21.0/src/context/ext_device_manager.rs000064400000000000000000000060121046102023000207710ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Routines for controlling module-device-manager. use std::os::raw::{c_char, c_void}; use super::{pa_context, pa_context_success_cb_t}; use crate::operation::pa_operation; #[repr(C)] pub struct pa_ext_device_manager_role_priority_info { pub role: *const c_char, pub priority: u32, } #[repr(C)] pub struct pa_ext_device_manager_info { pub name: *const c_char, pub description: *const c_char, pub icon: *const c_char, pub index: u32, pub n_role_priorities: u32, pub role_priorities: *mut pa_ext_device_manager_role_priority_info, } #[rustfmt::skip] pub type pa_ext_device_manager_test_cb_t = Option; #[rustfmt::skip] pub type pa_ext_device_manager_read_cb_t = Option; #[rustfmt::skip] pub type pa_ext_device_manager_subscribe_cb_t = Option; #[rustfmt::skip] #[link(name = "pulse")] extern "C" { pub fn pa_ext_device_manager_test(c: *mut pa_context, cb: pa_ext_device_manager_test_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_ext_device_manager_read(c: *mut pa_context, cb: pa_ext_device_manager_read_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_ext_device_manager_set_device_description(c: *mut pa_context, device: *const c_char, description: *const c_char, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_ext_device_manager_delete(c: *mut pa_context, s: *const *const c_char, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_ext_device_manager_enable_role_device_priority_routing(c: *mut pa_context, enable: i32, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_ext_device_manager_reorder_devices_for_role(c: *mut pa_context, role: *const c_char, devices: *const *const c_char, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_ext_device_manager_subscribe(c: *mut pa_context, enable: i32, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_ext_device_manager_set_subscribe_cb(c: *mut pa_context, cb: pa_ext_device_manager_subscribe_cb_t, userdata: *mut c_void); } libpulse-sys-1.21.0/src/context/ext_device_restore.rs000064400000000000000000000051501046102023000210440ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Routines for controlling module-device-restore. use std::os::raw::c_void; use super::{pa_context, pa_context_success_cb_t}; use crate::{operation::pa_operation, def::pa_device_type_t, format::pa_format_info}; #[repr(C)] pub struct pa_ext_device_restore_info { pub dtype: pa_device_type_t, pub index: u32, pub n_formats: u8, pub formats: *mut *mut pa_format_info, } #[rustfmt::skip] pub type pa_ext_device_restore_test_cb_t = Option; #[rustfmt::skip] pub type pa_ext_device_restore_subscribe_cb_t = Option; #[rustfmt::skip] pub type pa_ext_device_restore_read_device_formats_cb_t = Option; #[rustfmt::skip] #[link(name = "pulse")] extern "C" { pub fn pa_ext_device_restore_test(c: *mut pa_context, cb: pa_ext_device_restore_test_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_ext_device_restore_subscribe(c: *mut pa_context, enable: i32, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_ext_device_restore_set_subscribe_cb(c: *mut pa_context, cb: pa_ext_device_restore_subscribe_cb_t, userdata: *mut c_void); pub fn pa_ext_device_restore_read_formats_all(c: *mut pa_context, cb: pa_ext_device_restore_read_device_formats_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_ext_device_restore_read_formats(c: *mut pa_context, type_: pa_device_type_t, idx: u32, cb: pa_ext_device_restore_read_device_formats_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_ext_device_restore_save_formats(c: *mut pa_context, type_: pa_device_type_t, idx: u32, n_formats: u8, formats: *const *mut pa_format_info, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; } libpulse-sys-1.21.0/src/context/ext_stream_restore.rs000064400000000000000000000051121046102023000210760ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Routines for controlling module-stream-restore. use std::os::raw::{c_char, c_void}; use super::{pa_context, pa_context_success_cb_t}; use crate::{operation::pa_operation, proplist::pa_update_mode_t}; use crate::{volume::pa_cvolume, channelmap::pa_channel_map}; #[repr(C)] pub struct pa_ext_stream_restore_info { pub name: *const c_char, pub channel_map: pa_channel_map, pub volume: pa_cvolume, pub device: *const c_char, pub mute: i32, } #[rustfmt::skip] pub type pa_ext_stream_restore_test_cb_t = Option; #[rustfmt::skip] pub type pa_ext_stream_restore_read_cb_t = Option; #[rustfmt::skip] pub type pa_ext_stream_restore_subscribe_cb_t = Option; #[rustfmt::skip] #[link(name = "pulse")] extern "C" { pub fn pa_ext_stream_restore_test(c: *mut pa_context, cb: pa_ext_stream_restore_test_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_ext_stream_restore_read(c: *mut pa_context, cb: pa_ext_stream_restore_read_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_ext_stream_restore_write(c: *mut pa_context, mode: pa_update_mode_t, data: *const *const pa_ext_stream_restore_info, n: u32, apply_immediately: i32, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_ext_stream_restore_delete(c: *mut pa_context, s: *const *const c_char, b: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_ext_stream_restore_subscribe(c: *mut pa_context, enable: i32, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_ext_stream_restore_set_subscribe_cb(c: *mut pa_context, cb: pa_ext_stream_restore_subscribe_cb_t, userdata: *mut c_void); } libpulse-sys-1.21.0/src/context/introspect.rs000064400000000000000000000477351046102023000173730ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Routines for daemon introspection. use std::os::raw::{c_char, c_void}; use super::{pa_context, pa_context_success_cb_t}; use crate::volume::{pa_cvolume, pa_volume_t}; use crate::sample::{pa_sample_spec, pa_usec_t}; use crate::def::{pa_sink_flags_t, pa_sink_state_t, pa_source_flags_t, pa_source_state_t}; use crate::{operation::pa_operation, channelmap::pa_channel_map}; use crate::{proplist::pa_proplist, format::pa_format_info}; #[repr(C)] pub struct pa_sink_port_info { pub name: *const c_char, pub description: *const c_char, pub priority: u32, pub available: i32, #[cfg(any(doc, feature = "pa_v14"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v14")))] pub availability_group: *const c_char, #[cfg(any(doc, feature = "pa_v14"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v14")))] pub r#type: u32, } #[repr(C)] pub struct pa_sink_info { pub name: *const c_char, pub index: u32, pub description: *const c_char, pub sample_spec: pa_sample_spec, pub channel_map: pa_channel_map, pub owner_module: u32, pub volume: pa_cvolume, pub mute: i32, pub monitor_source: u32, pub monitor_source_name: *const c_char, pub latency: pa_usec_t, pub driver: *const c_char, pub flags: pa_sink_flags_t, pub proplist: *mut pa_proplist, pub configured_latency: pa_usec_t, pub base_volume: pa_volume_t, pub state: pa_sink_state_t, pub n_volume_steps: u32, pub card: u32, pub n_ports: u32, pub ports: *mut *mut pa_sink_port_info, pub active_port: *mut pa_sink_port_info, pub n_formats: u8, pub formats: *mut *mut pa_format_info, } #[rustfmt::skip] pub type pa_sink_info_cb_t = Option; #[repr(C)] pub struct pa_source_port_info { pub name: *const c_char, pub description: *const c_char, pub priority: u32, pub available: i32, #[cfg(any(doc, feature = "pa_v14"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v14")))] pub availability_group: *const c_char, #[cfg(any(doc, feature = "pa_v14"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v14")))] pub r#type: u32, } #[repr(C)] pub struct pa_source_info { pub name: *const c_char, pub index: u32, pub description: *const c_char, pub sample_spec: pa_sample_spec, pub channel_map: pa_channel_map, pub owner_module: u32, pub volume: pa_cvolume, pub mute: i32, pub monitor_of_sink: u32, pub monitor_of_sink_name: *const c_char, pub latency: pa_usec_t, pub driver: *const c_char, pub flags: pa_source_flags_t, pub proplist: *mut pa_proplist, pub configured_latency: pa_usec_t, pub base_volume: pa_volume_t, pub state: pa_source_state_t, pub n_volume_steps: u32, pub card: u32, pub n_ports: u32, pub ports: *mut *mut pa_source_port_info, pub active_port: *mut pa_source_port_info, pub n_formats: u8, pub formats: *mut *mut pa_format_info, } #[rustfmt::skip] pub type pa_source_info_cb_t = Option; #[repr(C)] pub struct pa_server_info { pub user_name: *const c_char, pub host_name: *const c_char, pub server_version: *const c_char, pub server_name: *const c_char, pub sample_spec: pa_sample_spec, pub default_sink_name: *const c_char, pub default_source_name: *const c_char, pub cookie: u32, pub channel_map: pa_channel_map, } #[rustfmt::skip] pub type pa_server_info_cb_t = Option; #[repr(C)] pub struct pa_module_info { pub index: u32, pub name: *const c_char, pub argument: *const c_char, pub n_used: u32, #[deprecated] pub auto_unload: i32, pub proplist: *mut pa_proplist, } #[rustfmt::skip] pub type pa_module_info_cb_t = Option; #[rustfmt::skip] pub type pa_context_index_cb_t = Option; /// Stores information about clients. /// /// Please note that this structure can be extended as part of evolutionary API updates at any time /// in any new release. #[repr(C)] pub struct pa_client_info { /// Index of this client. pub index: u32, /// Name of this client. pub name: *const c_char, /// Index of the owning module, or [`PA_INVALID_INDEX`](crate::def::PA_INVALID_INDEX). pub owner_module: u32, /// Driver name. pub driver: *const c_char, /// Property list. pub proplist: *mut pa_proplist, } #[rustfmt::skip] pub type pa_client_info_cb_t = Option; /// Stores information about a specific profile of a card. /// /// Please note that this structure is obsolete, replaced by [`pa_card_profile_info2`] in PA v5. #[repr(C)] pub struct pa_card_profile_info { /// Name of this profile. pub name: *const c_char, /// Description of this profile. pub description: *const c_char, /// Number of sinks this profile would create. pub n_sinks: u32, /// Number of sources this profile would create. pub n_sources: u32, /// The higher this value is, the more useful this profile is as a default. pub priority: u32, } /// Stores information about a specific profile of a card. /// /// Please note that this structure can be extended as part of evolutionary API updates at any time /// in any new release. #[repr(C)] pub struct pa_card_profile_info2 { /// Name of this profile. pub name: *const c_char, /// Description of this profile. pub description: *const c_char, /// Number of sinks this profile would create. pub n_sinks: u32, /// Number of sources this profile would create. pub n_sources: u32, /// The higher this value is, the more useful this profile is as a default. pub priority: u32, /// Is this profile available? If this is zero, meaning “unavailable”, then it makes no sense to /// try to activate this profile. If this is non-zero, it’s still not a guarantee that /// activating the profile will result in anything useful, it just means that the server isn’t /// aware of any reason why the profile would definitely be useless. pub available: i32, } #[repr(C)] pub struct pa_card_port_info { pub name: *const c_char, pub description: *const c_char, pub priority: u32, pub available: i32, pub direction: i32, pub n_profiles: u32, #[deprecated] pub profiles: *mut *mut pa_card_profile_info, pub proplist: *mut pa_proplist, pub latency_offset: i64, pub profiles2: *mut *mut pa_card_profile_info2, #[cfg(any(doc, feature = "pa_v14"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v14")))] pub availability_group: *const c_char, #[cfg(any(doc, feature = "pa_v14"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v14")))] pub r#type: u32, } #[repr(C)] pub struct pa_card_info { pub index: u32, pub name: *const c_char, pub owner_module: u32, pub driver: *const c_char, pub n_profiles: u32, #[deprecated] pub profiles: *mut pa_card_profile_info, #[deprecated] pub active_profile: *mut pa_card_profile_info, pub proplist: *mut pa_proplist, pub n_ports: u32, pub ports: *mut *mut pa_card_port_info, pub profiles2: *mut *mut pa_card_profile_info2, pub active_profile2: *mut pa_card_profile_info2, } #[rustfmt::skip] pub type pa_card_info_cb_t = Option; #[repr(C)] pub struct pa_sink_input_info { pub index: u32, pub name: *const c_char, pub owner_module: u32, pub client: u32, pub sink: u32, pub sample_spec: pa_sample_spec, pub channel_map: pa_channel_map, pub volume: pa_cvolume, pub buffer_usec: pa_usec_t, pub sink_usec: pa_usec_t, pub resample_method: *const c_char, pub driver: *const c_char, pub mute: i32, pub proplist: *mut pa_proplist, pub corked: i32, pub has_volume: i32, pub volume_writable: i32, pub format: *mut pa_format_info, } #[rustfmt::skip] pub type pa_sink_input_info_cb_t = Option; #[repr(C)] pub struct pa_source_output_info { pub index: u32, pub name: *const c_char, pub owner_module: u32, pub client: u32, pub source: u32, pub sample_spec: pa_sample_spec, pub channel_map: pa_channel_map, pub buffer_usec: pa_usec_t, pub source_usec: pa_usec_t, pub resample_method: *const c_char, pub driver: *const c_char, pub proplist: *mut pa_proplist, pub corked: i32, pub volume: pa_cvolume, pub mute: i32, pub has_volume: i32, pub volume_writable: i32, pub format: *mut pa_format_info, } #[rustfmt::skip] pub type pa_source_output_info_cb_t = Option; /// Memory block statistics. /// /// Please note that this structure can be extended as part of evolutionary API updates at any time /// in any new release. #[repr(C)] #[derive(Debug)] pub struct pa_stat_info { /// Currently allocated memory blocks. pub memblock_total: u32, /// Current total size of allocated memory blocks. pub memblock_total_size: u32, /// Allocated memory blocks during the whole lifetime of the daemon. pub memblock_allocated: u32, /// Total size of all memory blocks allocated during the whole lifetime of the daemon. pub memblock_allocated_size: u32, /// Total size of all sample cache entries. pub scache_size: u32, } #[rustfmt::skip] pub type pa_stat_info_cb_t = Option; #[repr(C)] pub struct pa_sample_info { pub index: u32, pub name: *const c_char, pub volume: pa_cvolume, pub sample_spec: pa_sample_spec, pub channel_map: pa_channel_map, pub duration: pa_usec_t, pub bytes: u32, pub lazy: i32, pub filename: *const c_char, pub proplist: *mut pa_proplist, } #[rustfmt::skip] pub type pa_sample_info_cb_t = Option; #[rustfmt::skip] #[cfg(any(doc, feature = "pa_v15"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v15")))] pub type pa_context_string_cb_t = Option; #[rustfmt::skip] #[link(name = "pulse")] extern "C" { pub fn pa_context_get_sink_info_by_name(c: *mut pa_context, name: *const c_char, cb: pa_sink_info_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_get_sink_info_by_index(c: *mut pa_context, idx: u32, cb: pa_sink_info_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_get_sink_info_list(c: *mut pa_context, cb: pa_sink_info_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_set_sink_volume_by_index(c: *mut pa_context, idx: u32, volume: *const pa_cvolume, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_set_sink_volume_by_name(c: *mut pa_context, name: *const c_char, volume: *const pa_cvolume, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_set_sink_mute_by_index(c: *mut pa_context, idx: u32, mute: i32, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_set_sink_mute_by_name(c: *mut pa_context, name: *const c_char, mute: i32, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_suspend_sink_by_name(c: *mut pa_context, sink_name: *const c_char, suspend: i32, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_suspend_sink_by_index(c: *mut pa_context, idx: u32, suspend: i32, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_set_sink_port_by_index(c: *mut pa_context, idx: u32, port: *const c_char, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_set_sink_port_by_name(c: *mut pa_context, name: *const c_char, port: *const c_char, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_get_source_info_by_name(c: *mut pa_context, name: *const c_char, cb: pa_source_info_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_get_source_info_by_index(c: *mut pa_context, idx: u32, cb: pa_source_info_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_get_source_info_list(c: *mut pa_context, cb: pa_source_info_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_set_source_volume_by_index(c: *mut pa_context, idx: u32, volume: *const pa_cvolume, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_set_source_volume_by_name(c: *mut pa_context, name: *const c_char, volume: *const pa_cvolume, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_set_source_mute_by_index(c: *mut pa_context, idx: u32, mute: i32, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_set_source_mute_by_name(c: *mut pa_context, name: *const c_char, mute: i32, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_suspend_source_by_name(c: *mut pa_context, source_name: *const c_char, suspend: i32, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_suspend_source_by_index(c: *mut pa_context, idx: u32, suspend: i32, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_set_source_port_by_index(c: *mut pa_context, idx: u32, port: *const c_char, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_set_source_port_by_name(c: *mut pa_context, name: *const c_char, port: *const c_char, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_get_server_info(c: *mut pa_context, cb: pa_server_info_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_get_module_info(c: *mut pa_context, idx: u32, cb: pa_module_info_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_get_module_info_list(c: *mut pa_context, cb: pa_module_info_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_load_module(c: *mut pa_context, name: *const c_char, argument: *const c_char, cb: pa_context_index_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_unload_module(c: *mut pa_context, idx: u32, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; #[cfg(any(doc, feature = "pa_v15"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v15")))] pub fn pa_context_send_message_to_object(c: *mut pa_context, recipient_name: *const c_char, message: *const c_char, message_parameters: *const c_char, cb: pa_context_string_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_get_client_info(c: *mut pa_context, idx: u32, cb: pa_client_info_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_get_client_info_list(c: *mut pa_context, cb: pa_client_info_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_kill_client(c: *mut pa_context, idx: u32, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_get_card_info_by_index(c: *mut pa_context, idx: u32, cb: pa_card_info_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_get_card_info_by_name(c: *mut pa_context, name: *const c_char, cb: pa_card_info_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_get_card_info_list(c: *mut pa_context, cb: pa_card_info_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_set_card_profile_by_index(c: *mut pa_context, idx: u32, profile: *const c_char, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_set_card_profile_by_name(c: *mut pa_context, name: *const c_char, profile: *const c_char, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_set_port_latency_offset(c: *mut pa_context, card_name: *const c_char, port_name: *const c_char, offset: i64, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_get_sink_input_info(c: *mut pa_context, idx: u32, cb: pa_sink_input_info_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_get_sink_input_info_list(c: *mut pa_context, cb: pa_sink_input_info_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_move_sink_input_by_name(c: *mut pa_context, idx: u32, sink_name: *const c_char, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_move_sink_input_by_index(c: *mut pa_context, idx: u32, sink_idx: u32, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_set_sink_input_volume(c: *mut pa_context, idx: u32, volume: *const pa_cvolume, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_set_sink_input_mute(c: *mut pa_context, idx: u32, mute: i32, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_kill_sink_input(c: *mut pa_context, idx: u32, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_get_source_output_info(c: *mut pa_context, idx: u32, cb: pa_source_output_info_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_get_source_output_info_list(c: *mut pa_context, cb: pa_source_output_info_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_move_source_output_by_name(c: *mut pa_context, idx: u32, source_name: *const c_char, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_move_source_output_by_index(c: *mut pa_context, idx: u32, source_idx: u32, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_set_source_output_volume(c: *mut pa_context, idx: u32, volume: *const pa_cvolume, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_set_source_output_mute(c: *mut pa_context, idx: u32, mute: i32, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_kill_source_output(c: *mut pa_context, idx: u32, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_stat(c: *mut pa_context, cb: pa_stat_info_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_get_sample_info_by_name(c: *mut pa_context, name: *const c_char, cb: pa_sample_info_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_get_sample_info_by_index(c: *mut pa_context, idx: u32, cb: pa_sample_info_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_get_sample_info_list(c: *mut pa_context, cb: pa_sample_info_cb_t, userdata: *mut c_void) -> *mut pa_operation; } libpulse-sys-1.21.0/src/context/mod.rs000064400000000000000000000144611046102023000157460ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Connection contexts for asynchronous communication with a server. //! //! A [`pa_context`] object wraps a connection to a PulseAudio server using its native protocol. pub mod ext_device_manager; pub mod ext_device_restore; pub mod ext_stream_restore; pub mod introspect; pub mod scache; pub mod subscribe; // Re-export pub use self::ext_device_manager::*; pub use self::ext_device_restore::*; pub use self::ext_stream_restore::*; pub use self::introspect::*; pub use self::scache::*; pub use self::subscribe::*; use std::os::raw::{c_char, c_void}; use num_derive::{FromPrimitive, ToPrimitive}; use crate::mainloop::api::{pa_time_event, pa_time_event_cb_t, pa_mainloop_api}; use crate::{operation::pa_operation, def::pa_spawn_api}; use crate::proplist::{pa_proplist, pa_update_mode_t}; use crate::sample::{pa_usec_t, pa_sample_spec}; /// An opaque connection context to a daemon. #[repr(C)] pub struct pa_context { _private: [u8; 0] } #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(FromPrimitive, ToPrimitive)] pub enum pa_context_state_t { Unconnected, Connecting, Authorizing, SettingName, Ready, Failed, Terminated, } pub const PA_CONTEXT_UNCONNECTED: pa_context_state_t = pa_context_state_t::Unconnected; pub const PA_CONTEXT_CONNECTING: pa_context_state_t = pa_context_state_t::Connecting; pub const PA_CONTEXT_AUTHORIZING: pa_context_state_t = pa_context_state_t::Authorizing; pub const PA_CONTEXT_SETTING_NAME: pa_context_state_t = pa_context_state_t::SettingName; pub const PA_CONTEXT_READY: pa_context_state_t = pa_context_state_t::Ready; pub const PA_CONTEXT_FAILED: pa_context_state_t = pa_context_state_t::Failed; pub const PA_CONTEXT_TERMINATED: pa_context_state_t = pa_context_state_t::Terminated; /// Checks if the passed state is one of the connected states (returns `true` if so). #[inline(always)] pub fn pa_context_is_good(state: pa_context_state_t) -> bool { state == pa_context_state_t::Connecting || state == pa_context_state_t::Authorizing || state == pa_context_state_t::SettingName || state == pa_context_state_t::Ready } pub type pa_context_flags_t = u32; pub use self::flags::*; /// Some special flags for contexts. mod flags { use super::pa_context_flags_t; pub const PA_CONTEXT_NOFLAGS: pa_context_flags_t = 0x0; pub const PA_CONTEXT_NOAUTOSPAWN: pa_context_flags_t = 0x1; pub const PA_CONTEXT_NOFAIL: pa_context_flags_t = 0x2; } pub type pa_context_notify_cb_t = Option; #[rustfmt::skip] pub type pa_context_success_cb_t = Option; #[rustfmt::skip] pub type pa_context_event_cb_t = Option; #[rustfmt::skip] #[link(name = "pulse")] extern "C" { pub fn pa_context_new(mainloop: *const pa_mainloop_api, name: *const c_char) -> *mut pa_context; pub fn pa_context_new_with_proplist(mainloop: *const pa_mainloop_api, name: *const c_char, proplist: *const pa_proplist) -> *mut pa_context; pub fn pa_context_unref(c: *mut pa_context); pub fn pa_context_ref(c: *mut pa_context) -> *mut pa_context; pub fn pa_context_set_state_callback(c: *mut pa_context, cb: pa_context_notify_cb_t, userdata: *mut c_void); pub fn pa_context_set_event_callback(p: *mut pa_context, cb: pa_context_event_cb_t, userdata: *mut c_void); pub fn pa_context_errno(c: *const pa_context) -> i32; pub fn pa_context_is_pending(c: *const pa_context) -> i32; pub fn pa_context_get_state(c: *const pa_context) -> pa_context_state_t; pub fn pa_context_connect(c: *mut pa_context, server: *const c_char, flags: pa_context_flags_t, api: *const pa_spawn_api) -> i32; pub fn pa_context_disconnect(c: *mut pa_context); pub fn pa_context_drain(c: *mut pa_context, cb: pa_context_notify_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_exit_daemon(c: *mut pa_context, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_set_default_sink(c: *mut pa_context, name: *const c_char, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_set_default_source(c: *mut pa_context, name: *const c_char, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_is_local(c: *const pa_context) -> i32; pub fn pa_context_set_name(c: *mut pa_context, name: *const c_char, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_get_server(c: *const pa_context) -> *const c_char; pub fn pa_context_get_protocol_version(c: *const pa_context) -> u32; pub fn pa_context_get_server_protocol_version(c: *const pa_context) -> u32; pub fn pa_context_proplist_update(c: *mut pa_context, mode: pa_update_mode_t, p: *const pa_proplist, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_proplist_remove(c: *mut pa_context, keys: *const *const c_char, cb: pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_get_index(s: *const pa_context) -> u32; pub fn pa_context_rttime_new(c: *const pa_context, usec: pa_usec_t, cb: pa_time_event_cb_t, userdata: *mut c_void) -> *mut pa_time_event; pub fn pa_context_rttime_restart(c: *const pa_context, e: *mut pa_time_event, usec: pa_usec_t); pub fn pa_context_get_tile_size(c: *const pa_context, ss: *const pa_sample_spec) -> usize; pub fn pa_context_load_cookie_from_file(c: *mut pa_context, cookie_file_path: *const c_char) -> i32; } libpulse-sys-1.21.0/src/context/scache.rs000064400000000000000000000031751046102023000164150ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Sample cache mechanism. use std::os::raw::{c_char, c_void}; use crate::{operation::pa_operation, proplist::pa_proplist, volume::pa_volume_t}; #[rustfmt::skip] pub type pa_context_play_sample_cb_t = Option; #[rustfmt::skip] #[link(name = "pulse")] extern "C" { pub fn pa_context_remove_sample(c: *mut super::pa_context, name: *const c_char, cb: super::pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_play_sample(c: *mut super::pa_context, name: *const c_char, dev: *const c_char, volume: pa_volume_t, cb: super::pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_play_sample_with_proplist(c: *mut super::pa_context, name: *const c_char, dev: *const c_char, volume: pa_volume_t, proplist: *const pa_proplist, cb: pa_context_play_sample_cb_t, userdata: *mut c_void) -> *mut pa_operation; } libpulse-sys-1.21.0/src/context/subscribe.rs000064400000000000000000000114541046102023000171470ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Daemon introspection event subscription subsystem. use std::os::raw::c_void; use crate::operation::pa_operation; /// The base integer type passed to the callback, from which the facility and operation components /// can be extracted. pub type pa_subscription_event_type_t = u32; /// Used to express what facilities you are interested in when subscribing. pub type pa_subscription_mask_t = u32; /// Mask to extract facility value from the event type passed to the user callback. pub const PA_SUBSCRIPTION_EVENT_FACILITY_MASK: pa_subscription_event_type_t = 0xf; /// Mask to extract operation value from the event type passed to the user callback. pub const PA_SUBSCRIPTION_EVENT_TYPE_MASK: pa_subscription_event_type_t = 0x30; pub use self::subscription_masks::*; /// A set of masks used for expressing which facilities you are interested in when subscribing. pub mod subscription_masks { use super::pa_subscription_mask_t; pub const PA_SUBSCRIPTION_MASK_NULL: pa_subscription_mask_t = 0; pub const PA_SUBSCRIPTION_MASK_SINK: pa_subscription_mask_t = 1 << 0; pub const PA_SUBSCRIPTION_MASK_SOURCE: pa_subscription_mask_t = 1 << 1; pub const PA_SUBSCRIPTION_MASK_SINK_INPUT: pa_subscription_mask_t = 1 << 2; pub const PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT: pa_subscription_mask_t = 1 << 3; pub const PA_SUBSCRIPTION_MASK_MODULE: pa_subscription_mask_t = 1 << 4; pub const PA_SUBSCRIPTION_MASK_CLIENT: pa_subscription_mask_t = 1 << 5; pub const PA_SUBSCRIPTION_MASK_SAMPLE_CACHE: pa_subscription_mask_t = 1 << 6; pub const PA_SUBSCRIPTION_MASK_SERVER: pa_subscription_mask_t = 1 << 7; /* NOTE: value `0x100` previously assigned, obsoleted */ pub const PA_SUBSCRIPTION_MASK_CARD: pa_subscription_mask_t = 1 << 9; pub const PA_SUBSCRIPTION_MASK_ALL: pa_subscription_mask_t = 0x2ff; } pub use self::event_facilities::*; /// Possible facility variants that could be extracted from an event type. pub mod event_facilities { use super::pa_subscription_event_type_t; pub const PA_SUBSCRIPTION_EVENT_SINK: pa_subscription_event_type_t = 0; pub const PA_SUBSCRIPTION_EVENT_SOURCE: pa_subscription_event_type_t = 1; pub const PA_SUBSCRIPTION_EVENT_SINK_INPUT: pa_subscription_event_type_t = 2; pub const PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT: pa_subscription_event_type_t = 3; pub const PA_SUBSCRIPTION_EVENT_MODULE: pa_subscription_event_type_t = 4; pub const PA_SUBSCRIPTION_EVENT_CLIENT: pa_subscription_event_type_t = 5; pub const PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE: pa_subscription_event_type_t = 6; /// Global server change, only occurring with a change operation. pub const PA_SUBSCRIPTION_EVENT_SERVER: pa_subscription_event_type_t = 7; /* NOTE: value `8` previously assigned, obsoleted */ pub const PA_SUBSCRIPTION_EVENT_CARD: pa_subscription_event_type_t = 9; } pub use self::event_operations::*; /// Possible operation variants that could be extracted from an event type. pub mod event_operations { use super::pa_subscription_event_type_t; pub const PA_SUBSCRIPTION_EVENT_NEW: pa_subscription_event_type_t = 0; pub const PA_SUBSCRIPTION_EVENT_CHANGE: pa_subscription_event_type_t = 0x10; pub const PA_SUBSCRIPTION_EVENT_REMOVE: pa_subscription_event_type_t = 0x20; } /// Checks if event type `t` matches an event mask bitfield (returns `true` if so). pub const fn pa_subscription_match_flags(m: pa_subscription_mask_t, t: pa_subscription_event_type_t) -> bool { (m & (1 << (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK))) != 0 } #[rustfmt::skip] pub type pa_context_subscribe_cb_t = Option; #[rustfmt::skip] #[link(name = "pulse")] extern "C" { pub fn pa_context_subscribe(c: *mut super::pa_context, m: pa_subscription_mask_t, cb: super::pa_context_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_context_set_subscribe_callback(c: *mut super::pa_context, cb: pa_context_subscribe_cb_t, userdata: *mut c_void); } libpulse-sys-1.21.0/src/def.rs000064400000000000000000000222171046102023000142370ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Global definitions. use std::os::raw::c_void; use num_derive::{FromPrimitive, ToPrimitive}; use crate::timeval::timeval; use crate::sample::pa_usec_t; /// An invalid index. pub const PA_INVALID_INDEX: u32 = std::u32::MAX; pub type pa_free_cb_t = Option; /// Device type, source or sink. #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(FromPrimitive, ToPrimitive)] pub enum pa_device_type_t { /// A sink. Sink, /// A source. Source, } pub const PA_DEVICE_TYPE_SINK: pa_device_type_t = pa_device_type_t::Sink; pub const PA_DEVICE_TYPE_SOURCE: pa_device_type_t = pa_device_type_t::Source; #[repr(C)] pub struct pa_buffer_attr { pub maxlength: u32, pub tlength: u32, pub prebuf: u32, pub minreq: u32, pub fragsize: u32, } #[repr(C)] pub struct pa_timing_info { pub timestamp: timeval, pub synchronized_clocks: i32, pub sink_usec: pa_usec_t, pub source_usec: pa_usec_t, pub transport_usec: pa_usec_t, pub playing: i32, pub write_index_corrupt: i32, pub write_index: i64, pub read_index_corrupt: i32, pub read_index: i64, pub configured_sink_usec: pa_usec_t, pub configured_source_usec: pa_usec_t, pub since_underrun: i64, } #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct pa_spawn_api { pub prefork: Option, pub postfork: Option, pub atfork: Option, } pub type pa_sink_flags_t = u32; pub use self::sink_flags::*; /// Special sink flags. pub mod sink_flags { use super::pa_sink_flags_t; pub const PA_SINK_NOFLAGS: pa_sink_flags_t = 0; pub const PA_SINK_HW_VOLUME_CTRL: pa_sink_flags_t = 1 << 0; pub const PA_SINK_LATENCY: pa_sink_flags_t = 1 << 1; pub const PA_SINK_HARDWARE: pa_sink_flags_t = 1 << 2; pub const PA_SINK_NETWORK: pa_sink_flags_t = 1 << 3; pub const PA_SINK_HW_MUTE_CTRL: pa_sink_flags_t = 1 << 4; pub const PA_SINK_DECIBEL_VOLUME: pa_sink_flags_t = 1 << 5; pub const PA_SINK_FLAT_VOLUME: pa_sink_flags_t = 1 << 6; pub const PA_SINK_DYNAMIC_LATENCY: pa_sink_flags_t = 1 << 7; pub const PA_SINK_SET_FORMATS: pa_sink_flags_t = 1 << 8; } #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(FromPrimitive, ToPrimitive)] pub enum pa_sink_state_t { Invalid = -1, Running = 0, Idle = 1, Suspended = 2, } pub const PA_SINK_INVALID_STATE: pa_sink_state_t = pa_sink_state_t::Invalid; pub const PA_SINK_RUNNING: pa_sink_state_t = pa_sink_state_t::Running; pub const PA_SINK_IDLE: pa_sink_state_t = pa_sink_state_t::Idle; pub const PA_SINK_SUSPENDED: pa_sink_state_t = pa_sink_state_t::Suspended; /// Checks if state is playing, i.e. running or idle (returns `true` if so). #[inline(always)] pub fn pa_sink_is_opened(state: pa_sink_state_t) -> bool { state == pa_sink_state_t::Running || state == pa_sink_state_t::Idle } /// Checks if state is running (returns `true` if so). #[inline(always)] pub fn pa_sink_is_running(state: pa_sink_state_t) -> bool { state == pa_sink_state_t::Running } pub type pa_source_flags_t = u32; pub use self::source_flags::*; /// Special source flags. pub mod source_flags { use super::pa_source_flags_t; pub const PA_SOURCE_NOFLAGS: pa_source_flags_t = 0; pub const PA_SOURCE_HW_VOLUME_CTRL: pa_source_flags_t = 1 << 0; pub const PA_SOURCE_LATENCY: pa_source_flags_t = 1 << 1; pub const PA_SOURCE_HARDWARE: pa_source_flags_t = 1 << 2; pub const PA_SOURCE_NETWORK: pa_source_flags_t = 1 << 3; pub const PA_SOURCE_HW_MUTE_CTRL: pa_source_flags_t = 1 << 4; pub const PA_SOURCE_DECIBEL_VOLUME: pa_source_flags_t = 1 << 5; pub const PA_SOURCE_DYNAMIC_LATENCY: pa_source_flags_t = 1 << 6; pub const PA_SOURCE_FLAT_VOLUME: pa_source_flags_t = 1 << 7; } #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(FromPrimitive, ToPrimitive)] pub enum pa_source_state_t { Invalid = -1, Running = 0, Idle = 1, Suspended = 2, } pub const PA_SOURCE_INVALID_STATE: pa_source_state_t = pa_source_state_t::Invalid; pub const PA_SOURCE_RUNNING: pa_source_state_t = pa_source_state_t::Running; pub const PA_SOURCE_IDLE: pa_source_state_t = pa_source_state_t::Idle; pub const PA_SOURCE_SUSPENDED: pa_source_state_t = pa_source_state_t::Suspended; #[inline(always)] pub fn pa_source_is_opened(state: pa_source_state_t) -> bool { state == pa_source_state_t::Running || state == pa_source_state_t::Idle } #[inline(always)] pub fn pa_source_is_running(state: pa_source_state_t) -> bool { state == pa_source_state_t::Running } /// Port availability. #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(FromPrimitive, ToPrimitive)] pub enum pa_port_available_t { /// This port does not support jack detection. Unknown = 0, /// This port is not available, likely because the jack is not plugged in. No = 1, /// This port is available, likely because the jack is plugged in. Yes = 2, } pub const PA_PORT_AVAILABLE_UNKNOWN: pa_port_available_t = pa_port_available_t::Unknown; pub const PA_PORT_AVAILABLE_NO: pa_port_available_t = pa_port_available_t::No; pub const PA_PORT_AVAILABLE_YES: pa_port_available_t = pa_port_available_t::Yes; /// Port type. #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(FromPrimitive, ToPrimitive)] #[allow(non_camel_case_types)] pub enum pa_device_port_type_t { /// Unknown. Unknown = 0, /// Auxillary. Aux = 1, /// Speaker. Speaker = 2, /// Headphones. Headphones = 3, /// Line. Line = 4, /// Mic. Mic = 5, /// Headset. Headset = 6, /// Handset. Handset = 7, /// Earpiece. Earpiece = 8, /// SPDIF. SPDIF = 9, /// HDMI. HDMI = 10, /// TV. TV = 11, /// Radio. Radio = 12, /// Video. Video = 13, /// USB. USB = 14, /// Bluetooth. Bluetooth = 15, /// Portable. Portable = 16, /// Handsfree. Handsfree = 17, /// Car. Car = 18, /// HiFi. HiFi = 19, /// Phone. Phone = 20, /// Network. Network = 21, /// Analog. Analog = 22, } pub const PA_DEVICE_PORT_TYPE_UNKNOWN: pa_device_port_type_t = pa_device_port_type_t::Unknown; pub const PA_DEVICE_PORT_TYPE_AUX: pa_device_port_type_t = pa_device_port_type_t::Aux; pub const PA_DEVICE_PORT_TYPE_SPEAKER: pa_device_port_type_t = pa_device_port_type_t::Speaker; pub const PA_DEVICE_PORT_TYPE_HEADPHONES: pa_device_port_type_t = pa_device_port_type_t::Headphones; pub const PA_DEVICE_PORT_TYPE_LINE: pa_device_port_type_t = pa_device_port_type_t::Line; pub const PA_DEVICE_PORT_TYPE_MIC: pa_device_port_type_t = pa_device_port_type_t::Mic; pub const PA_DEVICE_PORT_TYPE_HEADSET: pa_device_port_type_t = pa_device_port_type_t::Headset; pub const PA_DEVICE_PORT_TYPE_HANDSET: pa_device_port_type_t = pa_device_port_type_t::Handset; pub const PA_DEVICE_PORT_TYPE_EARPIECE: pa_device_port_type_t = pa_device_port_type_t::Earpiece; pub const PA_DEVICE_PORT_TYPE_SPDIF: pa_device_port_type_t = pa_device_port_type_t::SPDIF; pub const PA_DEVICE_PORT_TYPE_HDMI: pa_device_port_type_t = pa_device_port_type_t::HDMI; pub const PA_DEVICE_PORT_TYPE_TV: pa_device_port_type_t = pa_device_port_type_t::TV; pub const PA_DEVICE_PORT_TYPE_RADIO: pa_device_port_type_t = pa_device_port_type_t::Radio; pub const PA_DEVICE_PORT_TYPE_VIDEO: pa_device_port_type_t = pa_device_port_type_t::Video; pub const PA_DEVICE_PORT_TYPE_USB: pa_device_port_type_t = pa_device_port_type_t::USB; pub const PA_DEVICE_PORT_TYPE_BLUETOOTH: pa_device_port_type_t = pa_device_port_type_t::Bluetooth; pub const PA_DEVICE_PORT_TYPE_PORTABLE: pa_device_port_type_t = pa_device_port_type_t::Portable; pub const PA_DEVICE_PORT_TYPE_HANDSFREE: pa_device_port_type_t = pa_device_port_type_t::Handsfree; pub const PA_DEVICE_PORT_TYPE_CAR: pa_device_port_type_t = pa_device_port_type_t::Car; pub const PA_DEVICE_PORT_TYPE_HIFI: pa_device_port_type_t = pa_device_port_type_t::HiFi; pub const PA_DEVICE_PORT_TYPE_PHONE: pa_device_port_type_t = pa_device_port_type_t::Phone; pub const PA_DEVICE_PORT_TYPE_NETWORK: pa_device_port_type_t = pa_device_port_type_t::Network; pub const PA_DEVICE_PORT_TYPE_ANALOG: pa_device_port_type_t = pa_device_port_type_t::Analog; libpulse-sys-1.21.0/src/direction.rs000064400000000000000000000027501046102023000154610ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Utility functions for direction. #[cfg(any(doc, feature = "pa_v6"))] use std::os::raw::c_char; /// Direction bitfield. /// /// While we currently do not expose anything bidirectional, one should test against the bit instead /// of the value because we might add bidirectional stuff in the future. pub type pa_direction_t = i32; pub const PA_DIRECTION_OUTPUT: pa_direction_t = 0x1; pub const PA_DIRECTION_INPUT: pa_direction_t = 0x2; #[link(name = "pulse")] extern "C" { #[cfg(any(doc, feature = "pa_v6"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v6")))] pub fn pa_direction_valid(direction: pa_direction_t) -> i32; #[cfg(any(doc, feature = "pa_v6"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v6")))] pub fn pa_direction_to_string(direction: pa_direction_t) -> *const c_char; } libpulse-sys-1.21.0/src/error.rs000064400000000000000000000112551046102023000146320ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Error management. use std::os::raw::c_char; use num_derive::{FromPrimitive, ToPrimitive}; /// Error code. /// /// These represent the i32 error codes returned by many of the underlying PulseAudio C functions. /// Beware, these enum values are positive values, whilst PA functions return them in negative form, /// i.e. the `Invalid` variant here has a value of `3`, while functions returning this error code /// return `-3`. (This is identical to the enum provided in the PA C API). #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(FromPrimitive, ToPrimitive)] #[allow(non_camel_case_types)] pub enum pa_error_code_t { /// No error. Ok = 0, /// Access failure. Access, /// Unknown command. Command, /// Invalid argument. Invalid, /// Entity exists. Exist, /// No such entity. NoEntity, /// Connection refused. ConnectionRefused, /// Protocol error. Protocol, Timeout, /// No authentication key. AuthKey, Internal, ConnectionTerminated, /// Entity killed. Killed, InvalidServer, ModInitFailed, BadState, NoData, /// Incompatible protocol version. Version, /// Data too large. TooLarge, /// Operation not supported. NotSupported, /// The error code was unknown to the client. Unknown, /// Extension does not exist. NoExtension, /// Obsolete functionality. Obsolete, /// Missing implementation. NotImplemented, /// The caller forked without calling execve() and tried to reuse the context. Forked, /// An IO error happened. IO, /// Device or resource busy. Busy, } pub const PA_ERR_MAX: usize = 27; pub const PA_OK: pa_error_code_t = pa_error_code_t::Ok; pub const PA_ERR_ACCESS: pa_error_code_t = pa_error_code_t::Access; pub const PA_ERR_COMMAND: pa_error_code_t = pa_error_code_t::Command; pub const PA_ERR_INVALID: pa_error_code_t = pa_error_code_t::Invalid; pub const PA_ERR_EXIST: pa_error_code_t = pa_error_code_t::Exist; pub const PA_ERR_NOENTITY: pa_error_code_t = pa_error_code_t::NoEntity; pub const PA_ERR_CONNECTIONREFUSED: pa_error_code_t = pa_error_code_t::ConnectionRefused; pub const PA_ERR_PROTOCOL: pa_error_code_t = pa_error_code_t::Protocol; pub const PA_ERR_TIMEOUT: pa_error_code_t = pa_error_code_t::Timeout; pub const PA_ERR_AUTHKEY: pa_error_code_t = pa_error_code_t::AuthKey; pub const PA_ERR_INTERNAL: pa_error_code_t = pa_error_code_t::Internal; pub const PA_ERR_CONNECTIONTERMINATED: pa_error_code_t = pa_error_code_t::ConnectionTerminated; pub const PA_ERR_KILLED: pa_error_code_t = pa_error_code_t::Killed; pub const PA_ERR_INVALIDSERVER: pa_error_code_t = pa_error_code_t::InvalidServer; pub const PA_ERR_MODINITFAILED: pa_error_code_t = pa_error_code_t::ModInitFailed; pub const PA_ERR_BADSTATE: pa_error_code_t = pa_error_code_t::BadState; pub const PA_ERR_NODATA: pa_error_code_t = pa_error_code_t::NoData; pub const PA_ERR_VERSION: pa_error_code_t = pa_error_code_t::Version; pub const PA_ERR_TOOLARGE: pa_error_code_t = pa_error_code_t::TooLarge; pub const PA_ERR_NOTSUPPORTED: pa_error_code_t = pa_error_code_t::NotSupported; pub const PA_ERR_UNKNOWN: pa_error_code_t = pa_error_code_t::Unknown; pub const PA_ERR_NOEXTENSION: pa_error_code_t = pa_error_code_t::NoExtension; pub const PA_ERR_OBSOLETE: pa_error_code_t = pa_error_code_t::Obsolete; pub const PA_ERR_NOTIMPLEMENTED: pa_error_code_t = pa_error_code_t::NotImplemented; pub const PA_ERR_FORKED: pa_error_code_t = pa_error_code_t::Forked; pub const PA_ERR_IO: pa_error_code_t = pa_error_code_t::IO; pub const PA_ERR_BUSY: pa_error_code_t = pa_error_code_t::Busy; #[link(name = "pulse")] extern "C" { pub fn pa_strerror(error: i32) -> *const c_char; } libpulse-sys-1.21.0/src/format.rs000064400000000000000000000172421046102023000147730ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Utility functions for handling a stream or sink format. use std::os::raw::c_char; use num_derive::{FromPrimitive, ToPrimitive}; use crate::sample::{pa_sample_spec, pa_sample_format_t}; use crate::{proplist::pa_proplist, channelmap::pa_channel_map}; #[repr(C)] #[non_exhaustive] #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(FromPrimitive, ToPrimitive)] #[allow(non_camel_case_types)] pub enum pa_encoding_t { Any, PCM, AC3_IEC61937, EAC3_IEC61937, MPEG_IEC61937, DTS_IEC61937, MPEG2_AAC_IEC61937, #[cfg(any(doc, feature = "pa_v13"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v13")))] TRUEHD_IEC61937, #[cfg(any(doc, feature = "pa_v13"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v13")))] DTSHD_IEC61937, Invalid = -1, } pub const PA_ENCODING_MAX: usize = 7; pub const PA_ENCODING_ANY: pa_encoding_t = pa_encoding_t::Any; pub const PA_ENCODING_PCM: pa_encoding_t = pa_encoding_t::PCM; pub const PA_ENCODING_AC3_IEC61937: pa_encoding_t = pa_encoding_t::AC3_IEC61937; pub const PA_ENCODING_EAC3_IEC61937: pa_encoding_t = pa_encoding_t::EAC3_IEC61937; pub const PA_ENCODING_MPEG_IEC61937: pa_encoding_t = pa_encoding_t::MPEG_IEC61937; pub const PA_ENCODING_DTS_IEC61937: pa_encoding_t = pa_encoding_t::DTS_IEC61937; pub const PA_ENCODING_MPEG2_AAC_IEC61937: pa_encoding_t = pa_encoding_t::MPEG2_AAC_IEC61937; #[cfg(any(doc, feature = "pa_v13"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v13")))] pub const PA_ENCODING_TRUEHD_IEC61937: pa_encoding_t = pa_encoding_t::TRUEHD_IEC61937; #[cfg(any(doc, feature = "pa_v13"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v13")))] pub const PA_ENCODING_DTSHD_IEC61937: pa_encoding_t = pa_encoding_t::DTSHD_IEC61937; pub const PA_ENCODING_INVALID: pa_encoding_t = pa_encoding_t::Invalid; impl Default for pa_encoding_t { fn default() -> Self { pa_encoding_t::Invalid } } /// Represents the format of data provided in a stream or processed by a sink. #[repr(C)] pub struct pa_format_info { pub encoding: pa_encoding_t, pub plist: *mut pa_proplist, } /// The maximum length of strings returned by [`pa_format_info_snprint()`]. /// /// Please note that this value can change with any release without warning and without being /// considered API or ABI breakage. You should not use this definition anywhere where it might /// become part of an ABI. pub const PA_FORMAT_INFO_SNPRINT_MAX: usize = 256; /// Represents the type of value of a property. #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(FromPrimitive, ToPrimitive)] pub enum pa_prop_type_t { /// Integer. Int, /// Integer range. IntRange, /// Integer array. IntArray, /// String. String, /// String array. StringArray, /// Invalid. Invalid = -1, } pub const PA_PROP_TYPE_INT: pa_prop_type_t = pa_prop_type_t::Int; pub const PA_PROP_TYPE_INT_RANGE: pa_prop_type_t = pa_prop_type_t::IntRange; pub const PA_PROP_TYPE_INT_ARRAY: pa_prop_type_t = pa_prop_type_t::IntArray; pub const PA_PROP_TYPE_STRING: pa_prop_type_t = pa_prop_type_t::String; pub const PA_PROP_TYPE_STRING_ARRAY: pa_prop_type_t = pa_prop_type_t::StringArray; pub const PA_PROP_TYPE_INVALID: pa_prop_type_t = pa_prop_type_t::Invalid; impl Default for pa_prop_type_t { fn default() -> Self { pa_prop_type_t::Invalid } } #[rustfmt::skip] #[link(name = "pulse")] extern "C" { pub fn pa_encoding_to_string(e: pa_encoding_t) -> *const c_char; #[cfg(any(doc, feature = "pa_v12"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v12")))] pub fn pa_encoding_from_string(encoding: *const c_char) -> pa_encoding_t; pub fn pa_format_info_new() -> *mut pa_format_info; pub fn pa_format_info_copy(src: *const pa_format_info) -> *mut pa_format_info; pub fn pa_format_info_free(f: *mut pa_format_info); pub fn pa_format_info_valid(f: *const pa_format_info) -> i32; pub fn pa_format_info_is_pcm(f: *const pa_format_info) -> i32; pub fn pa_format_info_is_compatible(first: *const pa_format_info, second: *const pa_format_info) -> i32; pub fn pa_format_info_snprint(s: *mut c_char, l: usize, f: *const pa_format_info) -> *mut c_char; pub fn pa_format_info_from_string(s: *const c_char) -> *mut pa_format_info; pub fn pa_format_info_from_sample_spec(ss: *const pa_sample_spec, map: *const pa_channel_map) -> *mut pa_format_info; pub fn pa_format_info_to_sample_spec(f: *const pa_format_info, ss: *mut pa_sample_spec, map: *mut pa_channel_map) -> i32; pub fn pa_format_info_get_prop_type(f: *const pa_format_info, key: *const c_char) -> pa_prop_type_t; pub fn pa_format_info_get_prop_int(f: *const pa_format_info, key: *const c_char, v: *mut i32) -> i32; pub fn pa_format_info_get_prop_int_range(f: *const pa_format_info, key: *const c_char, min: *mut i32, max: *mut i32) -> i32; pub fn pa_format_info_get_prop_int_array(f: *const pa_format_info, key: *const c_char, values: *mut *mut i32, n_values: *mut i32) -> i32; pub fn pa_format_info_get_prop_string(f: *const pa_format_info, key: *const c_char, v: *mut *mut c_char) -> i32; pub fn pa_format_info_get_prop_string_array(f: *const pa_format_info, key: *const c_char, values: *mut *mut *mut c_char, n_values: *mut i32) -> i32; pub fn pa_format_info_free_string_array(values: *mut *mut c_char, n_values: i32); #[cfg(any(doc, feature = "pa_v13"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v13")))] pub fn pa_format_info_get_sample_format(f: *const pa_format_info, sf: *mut pa_sample_format_t) -> i32; #[cfg(any(doc, feature = "pa_v13"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v13")))] pub fn pa_format_info_get_rate(f: *const pa_format_info, rate: *mut u32) -> i32; #[cfg(any(doc, feature = "pa_v13"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v13")))] pub fn pa_format_info_get_channels(f: *const pa_format_info, channels: *mut u8) -> i32; #[cfg(any(doc, feature = "pa_v13"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v13")))] pub fn pa_format_info_get_channel_map(f: *const pa_format_info, map: *const pa_channel_map) -> i32; pub fn pa_format_info_set_prop_int(f: *mut pa_format_info, key: *const c_char, value: i32); pub fn pa_format_info_set_prop_int_array(f: *mut pa_format_info, key: *const c_char, values: *const i32, n_values: i32); pub fn pa_format_info_set_prop_int_range(f: *mut pa_format_info, key: *const c_char, min: i32, max: i32); pub fn pa_format_info_set_prop_string(f: *mut pa_format_info, key: *const c_char, value: *const c_char); pub fn pa_format_info_set_prop_string_array(f: *mut pa_format_info, key: *const c_char, values: *const *const c_char, n_values: i32); pub fn pa_format_info_set_sample_format(f: *mut pa_format_info, sf: pa_sample_format_t); pub fn pa_format_info_set_rate(f: *mut pa_format_info, rate: i32); pub fn pa_format_info_set_channels(f: *mut pa_format_info, channels: i32); pub fn pa_format_info_set_channel_map(f: *mut pa_format_info, map: *const pa_channel_map); } libpulse-sys-1.21.0/src/lib.rs000064400000000000000000000051021046102023000142410ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! PulseAudio FFI bindings for the main `libpulse` system library. //! //! This crate does nothing more than offer a simple FFI binding to the C API of the [PulseAudio] //! client system library. Please note that there is a “higher-level” binding available (the //! [`libpulse-binding`] crate), built on top of this, which offers a more Rust-oriented interface. //! //! Unlike the “higher-level” binding just mentioned, virtually no documentation is provided here. //! Things that *are* documented here are typically only those directly re-exported by the //! “higher-level” binding. Please see either the equivalent documentation in that, or the //! documentation of the actual PulseAudio C header files, if you need documentation. //! //! [`libpulse-binding`]: https://docs.rs/libpulse-binding //! [PulseAudio]: https://en.wikipedia.org/wiki/PulseAudio #![doc( html_logo_url = "https://github.com/jnqnfe/pulse-binding-rust/raw/master/logo.svg", html_favicon_url = "https://github.com/jnqnfe/pulse-binding-rust/raw/master/favicon.ico" )] #![allow(non_camel_case_types, non_snake_case)] #![cfg_attr(docsrs, feature(doc_cfg))] pub mod channelmap; pub mod context; pub mod def; pub mod direction; pub mod error; pub mod format; pub mod mainloop; pub mod operation; pub mod proplist; pub mod rtclock; pub mod sample; pub mod stream; pub mod timeval; pub mod utf8; pub mod util; pub mod version; pub mod volume; pub mod xmalloc; // Re-export pub use self::channelmap::*; pub use self::context::*; pub use self::def::*; pub use self::direction::*; pub use self::error::*; pub use self::format::*; pub use self::mainloop::*; pub use self::operation::*; pub use self::proplist::*; pub use self::rtclock::*; pub use self::sample::*; pub use self::stream::*; pub use self::timeval::*; pub use self::utf8::*; pub use self::util::*; pub use self::version::*; pub use self::volume::*; pub use self::xmalloc::*; libpulse-sys-1.21.0/src/mainloop/api.rs000064400000000000000000000102131046102023000160610ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Main loop abstraction layer API. use std::os::raw::c_void; use crate::timeval::timeval; pub type pa_io_event_flags_t = u32; pub use self::io_event_flags::*; pub mod io_event_flags { use super::pa_io_event_flags_t; pub const PA_IO_EVENT_NULL: pa_io_event_flags_t = 0; pub const PA_IO_EVENT_INPUT: pa_io_event_flags_t = 1; pub const PA_IO_EVENT_OUTPUT: pa_io_event_flags_t = 2; pub const PA_IO_EVENT_HANGUP: pa_io_event_flags_t = 4; pub const PA_IO_EVENT_ERROR: pa_io_event_flags_t = 8; } /// An opaque IO event source object. #[repr(C)] pub struct pa_io_event { _private: [u8; 0] } #[rustfmt::skip] pub type pa_io_event_cb_t = Option; #[rustfmt::skip] pub type pa_io_event_destroy_cb_t = Option; /// An opaque timer event source object. #[repr(C)] pub struct pa_time_event { _private: [u8; 0] } #[rustfmt::skip] pub type pa_time_event_cb_t = Option; #[rustfmt::skip] pub type pa_time_event_destroy_cb_t = Option; /// An opaque deferred event source object. /// /// Events of this type are triggered once in every main loop iteration. #[repr(C)] pub struct pa_defer_event { _private: [u8; 0] } #[rustfmt::skip] pub type pa_defer_event_cb_t = Option; #[rustfmt::skip] pub type pa_defer_event_destroy_cb_t = Option; #[rustfmt::skip] #[repr(C)] pub struct pa_mainloop_api { pub userdata: *mut c_void, pub io_new: Option *mut pa_io_event>, pub io_enable: Option, pub io_free: Option, pub io_set_destroy: Option, pub time_new: Option *mut pa_time_event>, pub time_restart: Option, pub time_free: Option, pub time_set_destroy: Option, pub defer_new: Option *mut pa_defer_event>, pub defer_enable: Option, pub defer_free: Option, pub defer_set_destroy: Option, pub quit: Option, } #[rustfmt::skip] pub type pa_mainloop_api_once_cb = Option; #[rustfmt::skip] #[link(name = "pulse")] extern "C" { pub fn pa_mainloop_api_once(m: *const pa_mainloop_api, callback: pa_mainloop_api_once_cb, userdata: *mut c_void); } libpulse-sys-1.21.0/src/mainloop/mod.rs000064400000000000000000000016231046102023000160740ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Main loop abstraction layer. pub mod api; pub mod signal; pub mod standard; pub mod threaded; // Re-export pub use self::api::*; pub use self::signal::*; pub use self::standard::*; pub use self::threaded::*; libpulse-sys-1.21.0/src/mainloop/signal.rs000064400000000000000000000031341046102023000165710ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! UNIX signal support for main loops. use std::os::raw::c_void; use crate::mainloop::api::pa_mainloop_api; /// An opaque UNIX signal event source object. #[repr(C)] pub struct pa_signal_event { _private: [u8; 0] } #[rustfmt::skip] pub type pa_signal_cb_t = Option; #[rustfmt::skip] pub type pa_signal_destroy_cb_t = Option; #[rustfmt::skip] #[link(name = "pulse")] extern "C" { pub fn pa_signal_init(api: *const pa_mainloop_api) -> i32; pub fn pa_signal_done(); pub fn pa_signal_new(sig: i32, callback: pa_signal_cb_t, userdata: *mut c_void) -> *mut pa_signal_event; pub fn pa_signal_free(e: *mut pa_signal_event); pub fn pa_signal_set_destroy(e: *mut pa_signal_event, callback: pa_signal_destroy_cb_t); } libpulse-sys-1.21.0/src/mainloop/standard.rs000064400000000000000000000040151046102023000171130ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Standard/minimal main loop implementation based on poll(). use std::os::raw::{c_ulong, c_void}; #[cfg(not(windows))] use libc::pollfd; #[cfg(windows)] use winapi::um::winsock2::WSAPOLLFD as pollfd; use crate::mainloop::api::pa_mainloop_api; /// An opaque main loop object. #[repr(C)] pub struct pa_mainloop { _private: [u8; 0] } #[rustfmt::skip] pub type pa_poll_func = Option i32>; #[rustfmt::skip] #[link(name = "pulse")] extern "C" { pub fn pa_mainloop_new() -> *mut pa_mainloop; pub fn pa_mainloop_free(m: *mut pa_mainloop); pub fn pa_mainloop_prepare(m: *mut pa_mainloop, timeout: i32) -> i32; pub fn pa_mainloop_poll(m: *mut pa_mainloop) -> i32; pub fn pa_mainloop_dispatch(m: *mut pa_mainloop) -> i32; pub fn pa_mainloop_get_retval(m: *const pa_mainloop) -> i32; pub fn pa_mainloop_iterate(m: *mut pa_mainloop, block: i32, retval: *mut i32) -> i32; pub fn pa_mainloop_run(m: *mut pa_mainloop, retval: *mut i32) -> i32; pub fn pa_mainloop_get_api(m: *const pa_mainloop) -> *const pa_mainloop_api; pub fn pa_mainloop_quit(m: *mut pa_mainloop, retval: i32); pub fn pa_mainloop_wakeup(m: *mut pa_mainloop); pub fn pa_mainloop_set_poll_func(m: *mut pa_mainloop, poll_func: pa_poll_func, userdata: *mut c_void); } libpulse-sys-1.21.0/src/mainloop/threaded.rs000064400000000000000000000044671046102023000171060ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! A variation of the standard main loop implementation, using a background thread. use std::os::raw::c_char; #[cfg(any(doc, feature = "pa_v13"))] use std::os::raw::c_void; use crate::mainloop::api::pa_mainloop_api; /// An opaque threaded main loop object. #[repr(C)] pub struct pa_threaded_mainloop { _private: [u8; 0] } #[rustfmt::skip] #[link(name = "pulse")] extern "C" { pub fn pa_threaded_mainloop_new() -> *mut pa_threaded_mainloop; pub fn pa_threaded_mainloop_free(m: *mut pa_threaded_mainloop); pub fn pa_threaded_mainloop_start(m: *mut pa_threaded_mainloop) -> i32; pub fn pa_threaded_mainloop_stop(m: *mut pa_threaded_mainloop); pub fn pa_threaded_mainloop_lock(m: *mut pa_threaded_mainloop); pub fn pa_threaded_mainloop_unlock(m: *mut pa_threaded_mainloop); pub fn pa_threaded_mainloop_wait(m: *mut pa_threaded_mainloop); pub fn pa_threaded_mainloop_signal(m: *mut pa_threaded_mainloop, wait_for_accept: i32); pub fn pa_threaded_mainloop_accept(m: *mut pa_threaded_mainloop); pub fn pa_threaded_mainloop_get_retval(m: *const pa_threaded_mainloop) -> i32; pub fn pa_threaded_mainloop_get_api(m: *const pa_threaded_mainloop) -> *const pa_mainloop_api; pub fn pa_threaded_mainloop_in_thread(m: *mut pa_threaded_mainloop) -> i32; pub fn pa_threaded_mainloop_set_name(m: *mut pa_threaded_mainloop, name: *const c_char); #[cfg(any(doc, feature = "pa_v13"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v13")))] 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); } libpulse-sys-1.21.0/src/operation.rs000064400000000000000000000044001046102023000154730ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Asynchronous operations. use std::os::raw::c_void; use num_derive::{FromPrimitive, ToPrimitive}; /// An asynchronous operation object. #[repr(C)] pub struct pa_operation { _private: [u8; 0] } /// Operation state. #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(FromPrimitive, ToPrimitive)] pub enum pa_operation_state_t { /// The operation is still running. Running, /// The operation has completed. Done, /// The operation has been cancelled. Operations may get cancelled by the application, or as a /// result of the context getting disconnected while the operation is pending. Cancelled, } pub const PA_OPERATION_RUNNING: pa_operation_state_t = pa_operation_state_t::Running; pub const PA_OPERATION_DONE: pa_operation_state_t = pa_operation_state_t::Done; pub const PA_OPERATION_CANCELED: pa_operation_state_t = pa_operation_state_t::Cancelled; pub const PA_OPERATION_CANCELLED: pa_operation_state_t = pa_operation_state_t::Cancelled; /// A callback for operation state changes. #[rustfmt::skip] pub type pa_operation_notify_cb_t = Option; #[rustfmt::skip] #[link(name = "pulse")] extern "C" { pub fn pa_operation_ref(o: *mut pa_operation) -> *mut pa_operation; pub fn pa_operation_unref(o: *mut pa_operation); pub fn pa_operation_cancel(o: *mut pa_operation); pub fn pa_operation_get_state(o: *const pa_operation) -> pa_operation_state_t; pub fn pa_operation_set_state_callback(o: *mut pa_operation, cb: pa_operation_notify_cb_t, userdata: *mut c_void); } libpulse-sys-1.21.0/src/proplist.rs000064400000000000000000000444771046102023000153710ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Property list constants and functions. use std::os::raw::{c_char, c_void}; use num_derive::{FromPrimitive, ToPrimitive}; /// For streams: localized media name, formatted as UTF-8. E.g. "Guns'N'Roses: Civil War". pub const PA_PROP_MEDIA_NAME: &str = "media.name"; /// For streams: localized media title if applicable, formatted as UTF-8. E.g. "Civil War". pub const PA_PROP_MEDIA_TITLE: &str = "media.title"; /// For streams: localized media artist if applicable, formatted as UTF-8. E.g. "Guns'N'Roses". pub const PA_PROP_MEDIA_ARTIST: &str = "media.artist"; /// For streams: localized media copyright string if applicable, formatted as UTF-8. /// E.g. "Evil Record Corp.". pub const PA_PROP_MEDIA_COPYRIGHT: &str = "media.copyright"; /// For streams: localized media generator software string if applicable, formatted as UTF-8. /// E.g. "Foocrop AudioFrobnicator". pub const PA_PROP_MEDIA_SOFTWARE: &str = "media.software"; /// For streams: media language if applicable, in standard POSIX format. E.g. "de_DE". pub const PA_PROP_MEDIA_LANGUAGE: &str = "media.language"; /// For streams: source filename if applicable, in URI format or local path. /// E.g. "/home/lennart/music/foobar.ogg". pub const PA_PROP_MEDIA_FILENAME: &str = "media.filename"; /// For streams: icon for the media. A binary blob containing PNG image data. pub const PA_PROP_MEDIA_ICON: &str = "media.icon"; /// For streams: an XDG icon name for the media. E.g. "audio-x-mp3". pub const PA_PROP_MEDIA_ICON_NAME: &str = "media.icon_name"; /// For streams: logic role of this media. /// One of the strings "video", "music", "game", "event", "phone", "animation", "production", /// "a11y", "test". pub const PA_PROP_MEDIA_ROLE: &str = "media.role"; /// For streams: the name of a filter that is desired, e.g. "echo-cancel" or "equalizer-sink". /// PulseAudio may choose to not apply the filter if it does not make sense (for example, applying /// echo-cancellation on a Bluetooth headset probably does not make sense. pub const PA_PROP_FILTER_WANT: &str = "filter.want"; /// For streams: the name of a filter that is desired, e.g. "echo-cancel" or "equalizer-sink". /// Differs from PA_PROP_FILTER_WANT in that it forces PulseAudio to apply the filter, regardless of /// whether PulseAudio thinks it makes sense to do so or not. If this is set, PA_PROP_FILTER_WANT /// is ignored. In other words, you almost certainly do not want to use this. pub const PA_PROP_FILTER_APPLY: &str = "filter.apply"; /// For streams: the name of a filter that should specifically be suppressed (i.e. overrides /// PA_PROP_FILTER_WANT). Useful for the times that PA_PROP_FILTER_WANT is automatically added (e.g. /// echo-cancellation for phone streams when $VOIP_APP does its own, internal AEC). pub const PA_PROP_FILTER_SUPPRESS: &str = "filter.suppress"; /// For event sound streams: XDG event sound name. e.g. "message-new-email" (Event sound streams are /// those with media.role set to "event"). pub const PA_PROP_EVENT_ID: &str = "event.id"; /// For event sound streams: localized human readable one-line description of the event, formatted /// as UTF-8. E.g. "Email from lennart\@example.com received." pub const PA_PROP_EVENT_DESCRIPTION: &str = "event.description"; /// For event sound streams: absolute horizontal mouse position on the screen if the event sound was /// triggered by a mouse click, integer formatted as text string. E.g. "865". pub const PA_PROP_EVENT_MOUSE_X: &str = "event.mouse.x"; /// For event sound streams: absolute vertical mouse position on the screen if the event sound was /// triggered by a mouse click, integer formatted as text string. E.g. "432". pub const PA_PROP_EVENT_MOUSE_Y: &str = "event.mouse.y"; /// For event sound streams: relative horizontal mouse position on the screen if the event sound was /// triggered by a mouse click, float formatted as text string, ranging from 0.0 (left side of the /// screen) to 1.0 (right side of the screen). E.g. "0.65". pub const PA_PROP_EVENT_MOUSE_HPOS: &str = "event.mouse.hpos"; /// For event sound streams: relative vertical mouse position on the screen if the event sound was /// triggered by a mouse click, float formatted as text string, ranging from 0.0 (top of the screen) /// to 1.0 (bottom of the screen). E.g. "0.43". pub const PA_PROP_EVENT_MOUSE_VPOS: &str = "event.mouse.vpos"; /// For event sound streams: mouse button that triggered the event if applicable, integer formatted /// as string with 0=left, 1=middle, 2=right. E.g. "0". pub const PA_PROP_EVENT_MOUSE_BUTTON: &str = "event.mouse.button"; /// For streams that belong to a window on the screen: localized window title. /// E.g. "Totem Music Player". pub const PA_PROP_WINDOW_NAME: &str = "window.name"; /// For streams that belong to a window on the screen: a textual id for identifying a window /// logically. E.g. "org.gnome.Totem.MainWindow". pub const PA_PROP_WINDOW_ID: &str = "window.id"; /// For streams that belong to a window on the screen: window icon. A binary blob containing PNG /// image data. pub const PA_PROP_WINDOW_ICON: &str = "window.icon"; /// For streams that belong to a window on the screen: an XDG icon name for the window. E.g. /// "totem". pub const PA_PROP_WINDOW_ICON_NAME: &str = "window.icon_name"; /// For streams that belong to a window on the screen: absolute horizontal window position on the /// screen, integer formatted as text string. E.g. "865". pub const PA_PROP_WINDOW_X: &str = "window.x"; /// For streams that belong to a window on the screen: absolute vertical window position on the /// screen, integer formatted as text string. E.g. "343". pub const PA_PROP_WINDOW_Y: &str = "window.y"; /// For streams that belong to a window on the screen: window width on the screen, integer /// formatted as text string. e.g. "365". pub const PA_PROP_WINDOW_WIDTH: &str = "window.width"; /// For streams that belong to a window on the screen: window height on the screen, integer /// formatted as text string. E.g. "643". pub const PA_PROP_WINDOW_HEIGHT: &str = "window.height"; /// For streams that belong to a window on the screen: relative position of the window center on the /// screen, float formatted as text string, ranging from 0.0 (left side of the screen) to 1.0 (right /// side of the screen). E.g. "0.65". pub const PA_PROP_WINDOW_HPOS: &str = "window.hpos"; /// For streams that belong to a window on the screen: relative position of the window center on the /// screen, float formatted as text string, ranging from 0.0 (top of the screen) to 1.0 (bottom of /// the screen). E.g. "0.43". pub const PA_PROP_WINDOW_VPOS: &str = "window.vpos"; /// For streams that belong to a window on the screen: if the windowing system supports multiple /// desktops, a comma separated list of indexes of the desktops this window is visible on. If this /// property is an empty string, it is visible on all desktops (i.e. ‘sticky’). The first desktop is /// zero. E.g. "0,2,3". pub const PA_PROP_WINDOW_DESKTOP: &str = "window.desktop"; /// For streams that belong to an X11 window on the screen: the X11 display string. E.g. ":0.0". pub const PA_PROP_WINDOW_X11_DISPLAY: &str = "window.x11.display"; /// For streams that belong to an X11 window on the screen: the X11 screen the window is on, an /// integer formatted as string. E.g. "0". pub const PA_PROP_WINDOW_X11_SCREEN: &str = "window.x11.screen"; /// For streams that belong to an X11 window on the screen: the X11 monitor the window is on, an /// integer formatted as string. E.g. "0". pub const PA_PROP_WINDOW_X11_MONITOR: &str = "window.x11.monitor"; /// For streams that belong to an X11 window on the screen: the window XID, an integer formatted as /// string. E.g. "25632". pub const PA_PROP_WINDOW_X11_XID: &str = "window.x11.xid"; /// For clients/streams: localized human readable application name. E.g. "Totem Music Player". pub const PA_PROP_APPLICATION_NAME: &str = "application.name"; /// For clients/streams: a textual id for identifying an application logically. /// E.g. "org.gnome.Totem". pub const PA_PROP_APPLICATION_ID: &str = "application.id"; /// For clients/streams: a version string, e.g. "0.6.88". pub const PA_PROP_APPLICATION_VERSION: &str = "application.version"; /// For clients/streams: application icon. A binary blob containing PNG image data. pub const PA_PROP_APPLICATION_ICON: &str = "application.icon"; /// For clients/streams: an XDG icon name for the application. E.g. "totem". pub const PA_PROP_APPLICATION_ICON_NAME: &str = "application.icon_name"; /// For clients/streams: application language if applicable, in standard POSIX format. E.g. "de_DE". pub const PA_PROP_APPLICATION_LANGUAGE: &str = "application.language"; /// For clients/streams on UNIX: application process PID, an integer formatted as string. E.g. /// "4711". pub const PA_PROP_APPLICATION_PROCESS_ID: &str = "application.process.id"; /// For clients/streams: application process name. E.g. "totem". pub const PA_PROP_APPLICATION_PROCESS_BINARY: &str = "application.process.binary"; /// For clients/streams: application user name. E.g. "lennart". pub const PA_PROP_APPLICATION_PROCESS_USER: &str = "application.process.user"; /// For clients/streams: host name the application runs on. E.g. "omega". pub const PA_PROP_APPLICATION_PROCESS_HOST: &str = "application.process.host"; /// For clients/streams: the D-Bus host id the application runs on. /// E.g. "543679e7b01393ed3e3e650047d78f6e". pub const PA_PROP_APPLICATION_PROCESS_MACHINE_ID: &str = "application.process.machine_id"; /// For clients/streams: an id for the login session the application runs in. On Unix the value of /// $XDG_SESSION_ID. E.g. "5". pub const PA_PROP_APPLICATION_PROCESS_SESSION_ID: &str = "application.process.session_id"; /// For devices: device string in the underlying audio layer’s format. E.g. "surround51:0". pub const PA_PROP_DEVICE_STRING: &str = "device.string"; /// For devices: API this device is accessed with. E.g. "alsa". pub const PA_PROP_DEVICE_API: &str = "device.api"; /// For devices: localized human readable device one-line description. /// E.g. "Foobar Industries USB Headset 2000+ Ultra". pub const PA_PROP_DEVICE_DESCRIPTION: &str = "device.description"; /// For devices: bus path to the device in the OS’ format. /// E.g. "/sys/bus/pci/devices/0000:00:1f.2". pub const PA_PROP_DEVICE_BUS_PATH: &str = "device.bus_path"; /// For devices: serial number if applicable. E.g. "4711-0815-1234". pub const PA_PROP_DEVICE_SERIAL: &str = "device.serial"; /// For devices: vendor ID if applicable. E.g. 1274. pub const PA_PROP_DEVICE_VENDOR_ID: &str = "device.vendor.id"; /// For devices: vendor name if applicable. E.g. "Foocorp Heavy Industries". pub const PA_PROP_DEVICE_VENDOR_NAME: &str = "device.vendor.name"; /// For devices: product ID if applicable. E.g. 4565. pub const PA_PROP_DEVICE_PRODUCT_ID: &str = "device.product.id"; /// For devices: product name if applicable. E.g. "SuperSpeakers 2000 Pro". pub const PA_PROP_DEVICE_PRODUCT_NAME: &str = "device.product.name"; /// For devices: device class. One of "sound", "modem", "monitor", "filter". pub const PA_PROP_DEVICE_CLASS: &str = "device.class"; /// For devices: form factor if applicable. One of "internal", "speaker", "handset", "tv", "webcam", /// "microphone", "headset", "headphone", "hands-free", "car", "hifi", "computer", "portable". pub const PA_PROP_DEVICE_FORM_FACTOR: &str = "device.form_factor"; /// For devices: bus of the device if applicable. One of "isa", "pci", "usb", "firewire", /// "bluetooth". pub const PA_PROP_DEVICE_BUS: &str = "device.bus"; /// For devices: icon for the device. A binary blob containing PNG image data. pub const PA_PROP_DEVICE_ICON: &str = "device.icon"; /// For devices: an XDG icon name for the device. E.g. "sound-card-speakers-usb". pub const PA_PROP_DEVICE_ICON_NAME: &str = "device.icon_name"; /// For devices: access mode of the device if applicable. One of "mmap", "mmap_rewrite", "serial". pub const PA_PROP_DEVICE_ACCESS_MODE: &str = "device.access_mode"; /// For filter devices: master device id if applicable. pub const PA_PROP_DEVICE_MASTER_DEVICE: &str = "device.master_device"; /// For devices: buffer size in bytes, integer formatted as string. pub const PA_PROP_DEVICE_BUFFERING_BUFFER_SIZE: &str = "device.buffering.buffer_size"; /// For devices: fragment size in bytes, integer formatted as string. pub const PA_PROP_DEVICE_BUFFERING_FRAGMENT_SIZE: &str = "device.buffering.fragment_size"; /// For devices: profile identifier for the profile this devices is in. /// E.g. "analog-stereo", "analog-surround-40", "iec958-stereo", ... pub const PA_PROP_DEVICE_PROFILE_NAME: &str = "device.profile.name"; /// For devices: intended use. A space separated list of roles (see PA_PROP_MEDIA_ROLE) this device /// is particularly well suited for, due to latency, quality or form factor. pub const PA_PROP_DEVICE_INTENDED_ROLES: &str = "device.intended_roles"; /// For devices: human readable one-line description of the profile this device is in. E.g. /// "Analog Stereo", ... pub const PA_PROP_DEVICE_PROFILE_DESCRIPTION: &str = "device.profile.description"; /// For modules: the author’s name, formatted as UTF-8 string. E.g. "Lennart Poettering". pub const PA_PROP_MODULE_AUTHOR: &str = "module.author"; /// For modules: a human readable one-line description of the module’s purpose formatted as UTF-8. /// E.g. "Frobnicate sounds with a flux compensator". pub const PA_PROP_MODULE_DESCRIPTION: &str = "module.description"; /// For modules: a human readable usage description of the module’s arguments formatted as UTF-8. pub const PA_PROP_MODULE_USAGE: &str = "module.usage"; /// For modules: a version string for the module. E.g. "0.9.15". pub const PA_PROP_MODULE_VERSION: &str = "module.version"; /// For PCM formats: the sample format used as returned by `pa_sample_format_to_string`. pub const PA_PROP_FORMAT_SAMPLE_FORMAT: &str = "format.sample_format"; /// For all formats: the sample rate (unsigned integer). pub const PA_PROP_FORMAT_RATE: &str = "format.rate"; /// For all formats: the number of channels (unsigned integer). pub const PA_PROP_FORMAT_CHANNELS: &str = "format.channels"; /// For PCM formats: the channel map of the stream as returned by `pa_channel_map_snprint`. pub const PA_PROP_FORMAT_CHANNEL_MAP: &str = "format.channel_map"; /// For context: whether to forcefully disable data transfer via POSIX or memfd shared memory. /// This property overrides any other client configuration which would otherwise enable SHM /// communication channels. //TODO: enable this feature gate once the passing of `--cfg doc` to dependencies is fixed (https://github.com/rust-lang/cargo/issues/8811) //#[cfg(any(doc, feature = "pa_v15"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v15")))] pub const PA_PROP_CONTEXT_FORCE_DISABLE_SHM: &str = "context.force.disable.shm"; /// For a bluez device: the currently selected codec name. //TODO: enable this feature gate once the passing of `--cfg doc` to dependencies is fixed (https://github.com/rust-lang/cargo/issues/8811) //#[cfg(any(doc, feature = "pa_v15"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v15")))] pub const PA_PROP_BLUETOOTH_CODEC: &str = "bluetooth.codec"; /// A property list object. Basically a dictionary with ASCII strings as keys and arbitrary data as /// values. #[repr(C)] pub struct pa_proplist { _private: [u8; 0] } /// Update mode. #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(FromPrimitive, ToPrimitive)] pub enum pa_update_mode_t { /// Replace the entire property list with the new one. Don’t keep any of the old data around. Set, /// Merge new property list into the existing one, not replacing any old entries if they share a /// common key with the new property list. Merge, /// Merge new property list into the existing one, replacing all old entries that share a common /// key with the new property list. Replace, } pub const PA_UPDATE_SET: pa_update_mode_t = pa_update_mode_t::Set; pub const PA_UPDATE_MERGE: pa_update_mode_t = pa_update_mode_t::Merge; pub const PA_UPDATE_REPLACE: pa_update_mode_t = pa_update_mode_t::Replace; #[rustfmt::skip] #[link(name = "pulse")] extern "C" { pub fn pa_proplist_new() -> *mut pa_proplist; pub fn pa_proplist_free(p: *mut pa_proplist); pub fn pa_proplist_key_valid(key: *const c_char) -> i32; pub fn pa_proplist_sets(p: *mut pa_proplist, key: *const c_char, value: *const c_char) -> i32; pub fn pa_proplist_setp(p: *mut pa_proplist, pair: *const c_char) -> i32; pub fn pa_proplist_setf(p: *mut pa_proplist, key: *const c_char, format: *const c_char, ...) -> i32; pub fn pa_proplist_set(p: *mut pa_proplist, key: *const c_char, data: *const c_void, nbytes: usize) -> i32; pub fn pa_proplist_gets(p: *const pa_proplist, key: *const c_char) -> *const c_char; pub fn pa_proplist_get(p: *const pa_proplist, key: *const c_char, data: *mut *const c_void, nbytes: *mut usize) -> i32; pub fn pa_proplist_update(p: *mut pa_proplist, mode: pa_update_mode_t, other: *const pa_proplist); pub fn pa_proplist_unset(p: *mut pa_proplist, key: *const c_char) -> i32; pub fn pa_proplist_unset_many(p: *mut pa_proplist, keys: *const *const c_char) -> i32; pub fn pa_proplist_iterate(p: *const pa_proplist, state: *mut *mut c_void) -> *const c_char; pub fn pa_proplist_to_string(p: *const pa_proplist) -> *mut c_char; pub fn pa_proplist_to_string_sep(p: *const pa_proplist, sep: *const c_char) -> *mut c_char; pub fn pa_proplist_from_string(s: *const c_char) -> *mut pa_proplist; pub fn pa_proplist_contains(p: *const pa_proplist, key: *const c_char) -> i32; pub fn pa_proplist_clear(p: *mut pa_proplist); pub fn pa_proplist_copy(p: *const pa_proplist) -> *mut pa_proplist; pub fn pa_proplist_size(p: *const pa_proplist) -> u32; pub fn pa_proplist_isempty(p: *const pa_proplist) -> i32; pub fn pa_proplist_equal(a: *const pa_proplist, b: *const pa_proplist) -> i32; } libpulse-sys-1.21.0/src/rtclock.rs000064400000000000000000000014751046102023000151450ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Monotonic clock utilities. #[link(name = "pulse")] extern "C" { pub fn pa_rtclock_now() -> crate::sample::pa_usec_t; } libpulse-sys-1.21.0/src/sample.rs000064400000000000000000000157301046102023000147640ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Constants and routines for sample type handling. use std::os::raw::c_char; use num_derive::{FromPrimitive, ToPrimitive}; /// Maximum number of allowed channels. pub const PA_CHANNELS_MAX: u8 = 32; /// Maximum allowed sample rate. pub const PA_RATE_MAX: u32 = 48000 * 8; /// Sample format. #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(FromPrimitive, ToPrimitive)] #[allow(non_camel_case_types)] pub enum pa_sample_format_t { U8, ALaw, ULaw, S16le, S16be, F32le, F32be, S32le, S32be, S24le, S24be, S24_32le, S24_32be, Invalid = -1, } pub const PA_SAMPLE_MAX: usize = 13; pub const PA_SAMPLE_U8: pa_sample_format_t = pa_sample_format_t::U8; pub const PA_SAMPLE_ALAW: pa_sample_format_t = pa_sample_format_t::ALaw; pub const PA_SAMPLE_ULAW: pa_sample_format_t = pa_sample_format_t::ULaw; pub const PA_SAMPLE_S16LE: pa_sample_format_t = pa_sample_format_t::S16le; pub const PA_SAMPLE_S16BE: pa_sample_format_t = pa_sample_format_t::S16be; pub const PA_SAMPLE_FLOAT32LE: pa_sample_format_t = pa_sample_format_t::F32le; pub const PA_SAMPLE_FLOAT32BE: pa_sample_format_t = pa_sample_format_t::F32be; pub const PA_SAMPLE_S32LE: pa_sample_format_t = pa_sample_format_t::S32le; pub const PA_SAMPLE_S32BE: pa_sample_format_t = pa_sample_format_t::S32be; pub const PA_SAMPLE_S24LE: pa_sample_format_t = pa_sample_format_t::S24le; pub const PA_SAMPLE_S24BE: pa_sample_format_t = pa_sample_format_t::S24be; pub const PA_SAMPLE_S24_32LE: pa_sample_format_t = pa_sample_format_t::S24_32le; pub const PA_SAMPLE_S24_32BE: pa_sample_format_t = pa_sample_format_t::S24_32be; pub const PA_SAMPLE_INVALID: pa_sample_format_t = pa_sample_format_t::Invalid; impl Default for pa_sample_format_t { fn default() -> Self { pa_sample_format_t::Invalid } } pub use self::ei_formats::*; /// Endian-independent format identifiers. #[cfg(target_endian = "big")] mod ei_formats { use super::pa_sample_format_t; pub const PA_SAMPLE_S16NE: pa_sample_format_t = pa_sample_format_t::S16be; pub const PA_SAMPLE_FLOAT32NE: pa_sample_format_t = pa_sample_format_t::F32be; pub const PA_SAMPLE_S32NE: pa_sample_format_t = pa_sample_format_t::S32be; pub const PA_SAMPLE_S24NE: pa_sample_format_t = pa_sample_format_t::S24be; pub const PA_SAMPLE_S24_32NE: pa_sample_format_t = pa_sample_format_t::S24_32be; pub const PA_SAMPLE_S16RE: pa_sample_format_t = pa_sample_format_t::S16le; pub const PA_SAMPLE_FLOAT32RE: pa_sample_format_t = pa_sample_format_t::F32le; pub const PA_SAMPLE_S32RE: pa_sample_format_t = pa_sample_format_t::S32le; pub const PA_SAMPLE_S24RE: pa_sample_format_t = pa_sample_format_t::S24le; pub const PA_SAMPLE_S24_32RE: pa_sample_format_t = pa_sample_format_t::S24_32le; } /// Endian-independent format identifiers. #[cfg(target_endian = "little")] mod ei_formats { use super::pa_sample_format_t; pub const PA_SAMPLE_S16NE: pa_sample_format_t = pa_sample_format_t::S16le; pub const PA_SAMPLE_FLOAT32NE: pa_sample_format_t = pa_sample_format_t::F32le; pub const PA_SAMPLE_S32NE: pa_sample_format_t = pa_sample_format_t::S32le; pub const PA_SAMPLE_S24NE: pa_sample_format_t = pa_sample_format_t::S24le; pub const PA_SAMPLE_S24_32NE: pa_sample_format_t = pa_sample_format_t::S24_32le; pub const PA_SAMPLE_S16RE: pa_sample_format_t = pa_sample_format_t::S16be; pub const PA_SAMPLE_FLOAT32RE: pa_sample_format_t = pa_sample_format_t::F32be; pub const PA_SAMPLE_S32RE: pa_sample_format_t = pa_sample_format_t::S32be; pub const PA_SAMPLE_S24RE: pa_sample_format_t = pa_sample_format_t::S24be; pub const PA_SAMPLE_S24_32RE: pa_sample_format_t = pa_sample_format_t::S24_32be; } /// A shortcut for [`PA_SAMPLE_FLOAT32NE`]. pub const PA_SAMPLE_FLOAT32: pa_sample_format_t = PA_SAMPLE_FLOAT32NE; /// A sample format and attribute specification. #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct pa_sample_spec { /// The sample format. pub format: pa_sample_format_t, /// The sample rate. (e.g. 44100). pub rate: u32, /// Audio channels. (1 for mono, 2 for stereo, ...). pub channels: u8, } /// Type for usec specifications (unsigned). Always 64 bit. pub type pa_usec_t = u64; /// The maximum length of strings returned by [`pa_sample_spec_snprint()`]. /// /// Please note that this value can change with any release without warning and without being /// considered API or ABI breakage. You should not use this definition anywhere where it might /// become part of an ABI. pub const PA_SAMPLE_SPEC_SNPRINT_MAX: usize = 32; /// The maximum length of strings returned by [`pa_bytes_snprint()`]. /// /// Please note that this value can change with any release without warning and without being /// considered API or ABI breakage. You should not use this definition anywhere where it might /// become part of an ABI. pub const PA_BYTES_SNPRINT_MAX: usize = 11; #[rustfmt::skip] #[link(name = "pulse")] extern "C" { pub fn pa_bytes_per_second(spec: *const pa_sample_spec) -> usize; pub fn pa_frame_size(spec: *const pa_sample_spec) -> usize; pub fn pa_sample_size(spec: *const pa_sample_spec) -> usize; pub fn pa_sample_size_of_format(f: pa_sample_format_t) -> usize; pub fn pa_bytes_to_usec(length: u64, spec: *const pa_sample_spec) -> pa_usec_t; pub fn pa_usec_to_bytes(t: pa_usec_t, spec: *const pa_sample_spec) -> usize; pub fn pa_sample_spec_init(spec: *mut pa_sample_spec) -> *mut pa_sample_spec; pub fn pa_sample_format_valid(format: u32) -> i32; pub fn pa_sample_rate_valid(rate: u32) -> i32; pub fn pa_channels_valid(channels: u8) -> i32; pub fn pa_sample_spec_valid(spec: *const pa_sample_spec) -> i32; pub fn pa_sample_spec_equal(a: *const pa_sample_spec, b: *const pa_sample_spec) -> i32; pub fn pa_sample_format_to_string(f: pa_sample_format_t) -> *const c_char; pub fn pa_parse_sample_format(format: *const c_char) -> pa_sample_format_t; pub fn pa_sample_spec_snprint(s: *mut c_char, l: usize, spec: *const pa_sample_spec) -> *mut c_char; pub fn pa_bytes_snprint(s: *mut c_char, l: usize, v: u32) -> *mut c_char; pub fn pa_sample_format_is_le(f: pa_sample_format_t) -> i32; pub fn pa_sample_format_is_be(f: pa_sample_format_t) -> i32; } libpulse-sys-1.21.0/src/stream.rs000064400000000000000000000275621046102023000150040ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Audio streams for input, output and sample upload. use std::os::raw::{c_char, c_void}; use num_derive::{FromPrimitive, ToPrimitive}; use crate::sample::{pa_sample_spec, pa_usec_t}; use crate::def::{pa_buffer_attr, pa_timing_info, pa_free_cb_t}; use crate::proplist::{pa_proplist, pa_update_mode_t}; use crate::{context::pa_context, channelmap::pa_channel_map, format::pa_format_info}; use crate::{volume::pa_cvolume, operation::pa_operation}; /// An opaque stream for playback or recording. #[repr(C)] pub struct pa_stream { _private: [u8; 0] } #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(FromPrimitive, ToPrimitive)] pub enum pa_stream_state_t { Unconnected, Creating, Ready, Failed, Terminated, } pub const PA_STREAM_UNCONNECTED: pa_stream_state_t = pa_stream_state_t::Unconnected; pub const PA_STREAM_CREATING: pa_stream_state_t = pa_stream_state_t::Creating; pub const PA_STREAM_READY: pa_stream_state_t = pa_stream_state_t::Ready; pub const PA_STREAM_FAILED: pa_stream_state_t = pa_stream_state_t::Failed; pub const PA_STREAM_TERMINATED: pa_stream_state_t = pa_stream_state_t::Terminated; /// Checks if the passed state is one of the connected states (returns `true` if so). #[inline(always)] pub fn pa_stream_is_good(state: pa_stream_state_t) -> bool { state == pa_stream_state_t::Creating || state == pa_stream_state_t::Ready } /// Stream direction. #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(FromPrimitive, ToPrimitive)] pub enum pa_stream_direction_t { /// Invalid. Invalid, /// Playback. Playback, /// Record. Record, /// Upload. Upload, } pub const PA_STREAM_NODIRECTION: pa_stream_direction_t = pa_stream_direction_t::Invalid; pub const PA_STREAM_PLAYBACK: pa_stream_direction_t = pa_stream_direction_t::Playback; pub const PA_STREAM_RECORD: pa_stream_direction_t = pa_stream_direction_t::Record; pub const PA_STREAM_UPLOAD: pa_stream_direction_t = pa_stream_direction_t::Upload; pub type pa_stream_flags_t = u32; pub use self::flags::*; /// Some special flags for stream connections. mod flags { use super::pa_stream_flags_t; pub const PA_STREAM_NOFLAGS: pa_stream_flags_t = 0; pub const PA_STREAM_START_CORKED: pa_stream_flags_t = 1 << 0; pub const PA_STREAM_INTERPOLATE_TIMING: pa_stream_flags_t = 1 << 1; pub const PA_STREAM_NOT_MONOTONIC: pa_stream_flags_t = 1 << 2; pub const PA_STREAM_AUTO_TIMING_UPDATE: pa_stream_flags_t = 1 << 3; pub const PA_STREAM_NO_REMAP_CHANNELS: pa_stream_flags_t = 1 << 4; pub const PA_STREAM_NO_REMIX_CHANNELS: pa_stream_flags_t = 1 << 5; pub const PA_STREAM_FIX_FORMAT: pa_stream_flags_t = 1 << 6; pub const PA_STREAM_FIX_RATE: pa_stream_flags_t = 1 << 7; pub const PA_STREAM_FIX_CHANNELS: pa_stream_flags_t = 1 << 8; pub const PA_STREAM_DONT_MOVE: pa_stream_flags_t = 1 << 9; pub const PA_STREAM_VARIABLE_RATE: pa_stream_flags_t = 1 << 10; pub const PA_STREAM_PEAK_DETECT: pa_stream_flags_t = 1 << 11; pub const PA_STREAM_START_MUTED: pa_stream_flags_t = 1 << 12; pub const PA_STREAM_ADJUST_LATENCY: pa_stream_flags_t = 1 << 13; pub const PA_STREAM_EARLY_REQUESTS: pa_stream_flags_t = 1 << 14; pub const PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND: pa_stream_flags_t = 1 << 15; pub const PA_STREAM_START_UNMUTED: pa_stream_flags_t = 1 << 16; pub const PA_STREAM_FAIL_ON_SUSPEND: pa_stream_flags_t = 1 << 17; pub const PA_STREAM_RELATIVE_VOLUME: pa_stream_flags_t = 1 << 18; pub const PA_STREAM_PASSTHROUGH: pa_stream_flags_t = 1 << 19; } /// Seek mode. #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(FromPrimitive, ToPrimitive)] pub enum pa_seek_mode_t { /// Seek relatively to the write index. Relative = 0, /// Seek relatively to the start of the buffer queue. Absolute = 1, /// Seek relatively to the read index. RelativeOnRead = 2, /// Seek relatively to the current end of the buffer queue. RelativeEnd = 3, } pub const PA_SEEK_RELATIVE: pa_seek_mode_t = pa_seek_mode_t::Relative; pub const PA_SEEK_ABSOLUTE: pa_seek_mode_t = pa_seek_mode_t::Absolute; pub const PA_SEEK_RELATIVE_ON_READ: pa_seek_mode_t = pa_seek_mode_t::RelativeOnRead; pub const PA_SEEK_RELATIVE_END: pa_seek_mode_t = pa_seek_mode_t::RelativeEnd; pub const PA_STREAM_EVENT_REQUEST_CORK: &str = "request-cork"; pub const PA_STREAM_EVENT_REQUEST_UNCORK: &str = "request-uncork"; pub const PA_STREAM_EVENT_FORMAT_LOST: &str = "format-lost"; #[rustfmt::skip] pub type pa_stream_success_cb_t = Option; #[rustfmt::skip] pub type pa_stream_request_cb_t = Option; #[rustfmt::skip] pub type pa_stream_notify_cb_t = Option; #[rustfmt::skip] pub type pa_stream_event_cb_t = Option; #[rustfmt::skip] #[link(name = "pulse")] extern "C" { pub fn pa_stream_connect_upload(s: *mut pa_stream, length: usize) -> i32; pub fn pa_stream_finish_upload(s: *mut pa_stream) -> i32; pub fn pa_stream_new(c: *mut pa_context, name: *const c_char, ss: *const pa_sample_spec, map: *const pa_channel_map) -> *mut pa_stream; pub fn pa_stream_new_with_proplist(c: *mut pa_context, name: *const c_char, ss: *const pa_sample_spec, map: *const pa_channel_map, p: *mut pa_proplist) -> *mut pa_stream; pub fn pa_stream_new_extended(c: *mut pa_context, name: *const c_char, formats: *const *const pa_format_info, n_formats: u32, p: *mut pa_proplist) -> *mut pa_stream; pub fn pa_stream_unref(s: *mut pa_stream); pub fn pa_stream_ref(s: *mut pa_stream) -> *mut pa_stream; pub fn pa_stream_get_state(s: *const pa_stream) -> pa_stream_state_t; pub fn pa_stream_get_context(s: *const pa_stream) -> *mut pa_context; pub fn pa_stream_get_index(s: *const pa_stream) -> u32; pub fn pa_stream_get_device_index(s: *const pa_stream) -> u32; pub fn pa_stream_get_device_name(s: *const pa_stream) -> *const c_char; pub fn pa_stream_is_suspended(s: *const pa_stream) -> i32; pub fn pa_stream_is_corked(s: *const pa_stream) -> i32; pub fn pa_stream_connect_playback(s: *mut pa_stream, dev: *const c_char, attr: *const pa_buffer_attr, flags: pa_stream_flags_t, volume: *const pa_cvolume, sync_stream: *mut pa_stream) -> i32; pub fn pa_stream_connect_record(s: *mut pa_stream, dev: *const c_char, attr: *const pa_buffer_attr, flags: pa_stream_flags_t) -> i32; pub fn pa_stream_disconnect(s: *mut pa_stream) -> i32; pub fn pa_stream_begin_write(s: *mut pa_stream, data: *mut *mut c_void, nbytes: *mut usize) -> i32; pub fn pa_stream_cancel_write(s: *mut pa_stream) -> i32; pub fn pa_stream_write(s: *mut pa_stream, data: *const c_void, nbytes: usize, free_cb: pa_free_cb_t, offset: i64, seek: pa_seek_mode_t) -> i32; #[cfg(any(doc, feature = "pa_v6"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v6")))] pub fn pa_stream_write_ext_free(s: *mut pa_stream, data: *const c_void, nbytes: usize, free_cb: pa_free_cb_t, free_cb_data: *mut c_void, offset: i64, seek: pa_seek_mode_t) -> i32; pub fn pa_stream_peek(s: *mut pa_stream, data: *mut *const c_void, nbytes: *mut usize) -> i32; pub fn pa_stream_drop(s: *mut pa_stream) -> i32; pub fn pa_stream_writable_size(s: *const pa_stream) -> usize; pub fn pa_stream_readable_size(s: *const pa_stream) -> usize; pub fn pa_stream_drain(s: *mut pa_stream, cb: pa_stream_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_stream_update_timing_info(s: *mut pa_stream, cb: pa_stream_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_stream_set_state_callback(s: *mut pa_stream, cb: pa_stream_notify_cb_t, userdata: *mut c_void); pub fn pa_stream_set_write_callback(s: *mut pa_stream, cb: pa_stream_request_cb_t, userdata: *mut c_void); pub fn pa_stream_set_read_callback(s: *mut pa_stream, cb: pa_stream_request_cb_t, userdata: *mut c_void); pub fn pa_stream_set_overflow_callback(s: *mut pa_stream, cb: pa_stream_notify_cb_t, userdata: *mut c_void); pub fn pa_stream_get_underflow_index(s: *const pa_stream) -> i64; pub fn pa_stream_set_underflow_callback(s: *mut pa_stream, cb: pa_stream_notify_cb_t, userdata: *mut c_void); pub fn pa_stream_set_started_callback(s: *mut pa_stream, cb: pa_stream_notify_cb_t, userdata: *mut c_void); pub fn pa_stream_set_latency_update_callback(s: *mut pa_stream, cb: pa_stream_notify_cb_t, userdata: *mut c_void); pub fn pa_stream_set_moved_callback(s: *mut pa_stream, cb: pa_stream_notify_cb_t, userdata: *mut c_void); pub fn pa_stream_set_suspended_callback(s: *mut pa_stream, cb: pa_stream_notify_cb_t, userdata: *mut c_void); pub fn pa_stream_set_event_callback(s: *mut pa_stream, cb: pa_stream_event_cb_t, userdata: *mut c_void); pub fn pa_stream_set_buffer_attr_callback(s: *mut pa_stream, cb: pa_stream_notify_cb_t, userdata: *mut c_void); pub fn pa_stream_cork(s: *mut pa_stream, b: i32, cb: pa_stream_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_stream_flush(s: *mut pa_stream, cb: pa_stream_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_stream_prebuf(s: *mut pa_stream, cb: pa_stream_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_stream_trigger(s: *mut pa_stream, cb: pa_stream_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_stream_set_name(s: *mut pa_stream, name: *const c_char, cb: pa_stream_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_stream_get_time(s: *mut pa_stream, r_usec: *mut pa_usec_t) -> i32; pub fn pa_stream_get_latency(s: *mut pa_stream, r_usec: *mut pa_usec_t, negative: *mut i32) -> i32; pub fn pa_stream_get_timing_info(s: *mut pa_stream) -> *const pa_timing_info; pub fn pa_stream_get_sample_spec(s: *mut pa_stream) -> *const pa_sample_spec; pub fn pa_stream_get_channel_map(s: *mut pa_stream) -> *const pa_channel_map; pub fn pa_stream_get_format_info(s: *const pa_stream) -> *mut pa_format_info; pub fn pa_stream_get_buffer_attr(s: *mut pa_stream) -> *const pa_buffer_attr; pub fn pa_stream_set_buffer_attr(s: *mut pa_stream, attr: *const pa_buffer_attr, cb: pa_stream_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_stream_update_sample_rate(s: *mut pa_stream, rate: u32, cb: pa_stream_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_stream_proplist_update(s: *mut pa_stream, mode: pa_update_mode_t, p: *mut pa_proplist, cb: pa_stream_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_stream_proplist_remove(s: *mut pa_stream, keys: *const *const c_char, cb: pa_stream_success_cb_t, userdata: *mut c_void) -> *mut pa_operation; pub fn pa_stream_set_monitor_stream(s: *mut pa_stream, sink_input_idx: u32) -> i32; pub fn pa_stream_get_monitor_stream(s: *const pa_stream) -> u32; } libpulse-sys-1.21.0/src/timeval.rs000064400000000000000000000034151046102023000151410ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Utility functions for handling timeval calculations. pub(crate) use libc::timeval; use crate::sample::pa_usec_t; pub const PA_MSEC_PER_SEC: pa_usec_t = 1000; pub const PA_USEC_PER_SEC: pa_usec_t = 1_000_000; pub const PA_NSEC_PER_SEC: u64 = 1_000_000_000; pub const PA_USEC_PER_MSEC: pa_usec_t = 1000; pub const PA_NSEC_PER_MSEC: u64 = 1_000_000; pub const PA_NSEC_PER_USEC: u64 = 1000; pub const PA_USEC_INVALID: pa_usec_t = std::u64::MAX; pub const PA_USEC_MAX: pa_usec_t = std::u64::MAX - 1; #[link(name = "pulse")] extern "C" { pub fn pa_gettimeofday(tv: *mut timeval) -> *mut timeval; pub fn pa_timeval_diff(a: *const timeval, b: *const timeval) -> pa_usec_t; pub fn pa_timeval_cmp(a: *const timeval, b: *const timeval) -> i32; pub fn pa_timeval_age(tv: *const timeval) -> pa_usec_t; pub fn pa_timeval_add(tv: *mut timeval, v: pa_usec_t) -> *mut timeval; pub fn pa_timeval_sub(tv: *mut timeval, v: pa_usec_t) -> *mut timeval; pub fn pa_timeval_store(tv: *mut timeval, v: pa_usec_t) -> *mut timeval; pub fn pa_timeval_load(tv: *const timeval) -> pa_usec_t; } libpulse-sys-1.21.0/src/utf8.rs000064400000000000000000000022161046102023000143640ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! UTF-8 validation functions. use std::os::raw::c_char; #[link(name = "pulse")] extern "C" { pub fn pa_utf8_valid(s: *const c_char) -> *mut c_char; pub fn pa_ascii_valid(s: *const c_char) -> *mut c_char; pub fn pa_utf8_filter(s: *const c_char) -> *mut c_char; pub fn pa_ascii_filter(s: *const c_char) -> *mut c_char; pub fn pa_utf8_to_locale(s: *const c_char) -> *mut c_char; pub fn pa_locale_to_utf8(s: *const c_char) -> *mut c_char; } libpulse-sys-1.21.0/src/util.rs000064400000000000000000000026071046102023000144570ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Assorted utility functions. use std::os::raw::{c_char, c_ulong}; #[link(name = "pulse")] extern "C" { pub fn pa_get_user_name(s: *mut c_char, l: usize) -> *mut c_char; pub fn pa_get_host_name(s: *mut c_char, l: usize) -> *mut c_char; pub fn pa_get_fqdn(s: *mut c_char, l: usize) -> *mut c_char; pub fn pa_get_home_dir(s: *mut c_char, l: usize) -> *mut c_char; pub fn pa_get_binary_name(s: *mut c_char, l: usize) -> *mut c_char; pub fn pa_path_get_filename(p: *const c_char) -> *mut c_char; pub fn pa_msleep(t: c_ulong) -> i32; #[cfg(any(doc, feature = "pa_v13"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v13")))] pub fn pa_thread_make_realtime(rtprio: i32) -> i32; } libpulse-sys-1.21.0/src/version.rs000064400000000000000000000156031046102023000151670ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Version constants and functions. //! //! This module contains functions and constants relating to PulseAudio (PA) client API version //! compatibility. //! //! # Dynamic compatibility //! //! As discussed in the project `COMPATIBILITY.md` file, support is offered for multiple versions of //! the PA client library, with changes made in newer versions being guarded with Cargo feature //! flags. //! //! Note that the minimum supported version of PA is v5.0. //! //! # Dynamic constants //! //! The version constants defined here mostly relate to those provided in the PA C headers. They are //! typically only updated following a new **major** release of PA. They are also dynamic, depending //! upon the level of compatibility support selected at compile time via the available Cargo feature //! flags. //! //! Note that there is **not** a one-to-one mapping of major PA version to compatibility feature. A //! new such feature is only introduced where actual changes in the PA client API require one //! because they introduce changes such as the addition of new functions. //! //! It is not obvious how the constants relate to version compatibility levels without reading the //! code, so this needs explaining. Simply put, version numbers are updated typically only on //! release of a new major version of PA, and update the existing version number associated with the //! current latest compatibility level selector when there are no changes requiring a new //! compatibility feature. //! //! Thus, for instance, PA versions 8 and 12 introduced additions to the API and have corresponding //! compatibility features to control the inclusion of those additions on top of the minimum level //! of support offered. If you have v8 compatibility enabled but not v12, then the version number //! indicated will be v11. use std::os::raw::c_char; /// PulseAudio version compatibility. /// /// Used for indicating what level of PA version compatibility was selected at compile time via /// Cargo feature flags. /// /// Note that PA v4 is the oldest supported. #[non_exhaustive] pub enum Compatibility { /// Support for PA version 5+ selected. V5Plus, /// Support for PA version 6+ selected. V6Plus, /// Support for PA version 8+ selected. V8Plus, /// Support for PA version 12+ selected. V12Plus, /// Support for PA version 13+ selected. V13Plus, /// Support for PA version 14+ selected. V14Plus, /// Support for PA version 15+ selected. V15Plus, } // Latest #[cfg(any(feature = "pa_v15", all(doc, not(feature = "pa_v6"))))] mod actual { pub const COMPATIBILITY: super::Compatibility = super::Compatibility::V15Plus; pub const TARGET_VERSION_STRING: &str = "15.0.0"; pub const TARGET_VERSION: (u8, u8) = (15, 0); pub const PA_PROTOCOL_VERSION: u16 = 35; } // Pre-v15 #[cfg(all(feature = "pa_v14", not(feature = "pa_v15")))] mod actual { pub const COMPATIBILITY: super::Compatibility = super::Compatibility::V14Plus; pub const TARGET_VERSION_STRING: &str = "14.0.0"; pub const TARGET_VERSION: (u8, u8) = (14, 0); pub const PA_PROTOCOL_VERSION: u16 = 34; } // Pre-v14 #[cfg(all(feature = "pa_v13", not(feature = "pa_v14")))] mod actual { pub const COMPATIBILITY: super::Compatibility = super::Compatibility::V13Plus; pub const TARGET_VERSION_STRING: &str = "13.0.0"; pub const TARGET_VERSION: (u8, u8) = (13, 0); pub const PA_PROTOCOL_VERSION: u16 = 33; } // Pre-v13 #[cfg(all(feature = "pa_v12", not(feature = "pa_v13")))] mod actual { pub const COMPATIBILITY: super::Compatibility = super::Compatibility::V12Plus; pub const TARGET_VERSION_STRING: &str = "12.0.0"; pub const TARGET_VERSION: (u8, u8) = (12, 0); pub const PA_PROTOCOL_VERSION: u16 = 32; } // Pre-v12 #[cfg(all(feature = "pa_v8", not(feature = "pa_v12")))] mod actual { pub const COMPATIBILITY: super::Compatibility = super::Compatibility::V8Plus; pub const TARGET_VERSION_STRING: &str = "8.0.0"; pub const TARGET_VERSION: (u8, u8) = (8, 0); pub const PA_PROTOCOL_VERSION: u16 = 30; } // Pre-v8 #[cfg(all(feature = "pa_v6", not(feature = "pa_v8")))] mod actual { pub const COMPATIBILITY: super::Compatibility = super::Compatibility::V6Plus; pub const TARGET_VERSION_STRING: &str = "6.0.0"; pub const TARGET_VERSION: (u8, u8) = (6, 0); pub const PA_PROTOCOL_VERSION: u16 = 30; } // Pre-v6 #[cfg(all(not(doc), not(feature = "pa_v6")))] mod actual { pub const COMPATIBILITY: super::Compatibility = super::Compatibility::V5Plus; pub const TARGET_VERSION_STRING: &str = "5.0.0"; pub const TARGET_VERSION: (u8, u8) = (5, 0); pub const PA_PROTOCOL_VERSION: u16 = 29; } /// Version string of targetted version. /// /// See the module level documentation for an explanation. pub const TARGET_VERSION_STRING: &str = actual::TARGET_VERSION_STRING; /// Version number of targetted version. /// /// See the module level documentation for an explanation. pub const TARGET_VERSION: (u8, u8) = actual::TARGET_VERSION; /// Protocol version of targetted version. /// /// See the module level documentation for an explanation. pub const PA_PROTOCOL_VERSION: u16 = actual::PA_PROTOCOL_VERSION; /// The current API version. /// /// Note, this has not been updated since PA v0.9.11. It is presumed that it would only ever be /// updated for backwards-breaking API changes. pub const PA_API_VERSION: u8 = 12; /// Get selected compatibility level. /// /// Returns indication of the level of PulseAudio version compatibility selected at compile time via /// Cargo feature flags. #[inline(always)] pub const fn get_compatibility() -> Compatibility { actual::COMPATIBILITY } /// Just compares given version with that defined in `TARGET_VERSION` and returns `true` if the /// `TARGET_VERSION` version is greater. This does **not** involve talking to the PulseAudio client /// library at runtime. This is not very useful! #[deprecated(since = "1.17.0")] #[inline(always)] pub const fn pa_check_version(major: u8, minor: u8, _micro: u8) -> bool { // Note, defined micro version is always zero as of PA v1.0, thus ignored here (TARGET_VERSION.0 > major) || ((TARGET_VERSION.0 == major) && (TARGET_VERSION.1 > minor)) } #[link(name = "pulse")] extern "C" { pub fn pa_get_library_version() -> *const c_char; } libpulse-sys-1.21.0/src/volume.rs000064400000000000000000000217071046102023000150130ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Constants and routines for volume handling. use std::os::raw::c_char; use crate::channelmap::{pa_channel_map, pa_channel_position_mask_t, pa_channel_position_t}; use crate::sample::pa_sample_spec; /// The basic volume type. pub type pa_volume_t = u32; /// Normal volume (100%, 0 dB). pub const PA_VOLUME_NORM: pa_volume_t = 0x10000; /// Muted (minimal valid) volume (0%, -inf dB). pub const PA_VOLUME_MUTED: pa_volume_t = 0; /// Maximum valid volume we can store. pub const PA_VOLUME_MAX: pa_volume_t = std::u32::MAX / 2; #[inline(always)] pub fn pa_volume_ui_max() -> pa_volume_t { unsafe { pa_sw_volume_from_dB(11.0) } } /// Special ‘invalid’ volume. pub const PA_VOLUME_INVALID: pa_volume_t = std::u32::MAX; /// This floor value is used as minus infinity when using [`pa_sw_volume_to_dB()`] or /// [`pa_sw_volume_from_dB()`]. pub const PA_DECIBEL_MININFTY: f64 = -std::f64::INFINITY; #[repr(C)] #[derive(Copy, Clone, Default)] pub struct pa_cvolume { pub channels: u8, pub values: [pa_volume_t; crate::sample::PA_CHANNELS_MAX as usize], } /// The maximum length of strings returned by [`pa_cvolume_snprint()`]. /// /// Please note that this value can change with any release without warning and without being /// considered API or ABI breakage. You should not use this definition anywhere where it might /// become part of an ABI. pub const PA_CVOLUME_SNPRINT_MAX: usize = 320; /// The maximum length of strings returned by [`pa_sw_cvolume_snprint_dB()`]. /// /// Please note that this value can change with any release without warning and without being /// considered API or ABI breakage. You should not use this definition anywhere where it might /// become part of an ABI. pub const PA_SW_CVOLUME_SNPRINT_DB_MAX: usize = 448; /// The maximum length of strings returned by [`pa_cvolume_snprint_verbose()`]. /// /// Please note that this value can change with any release without warning and without being /// considered API or ABI breakage. You should not use this definition anywhere where it might /// become part of an ABI. pub const PA_CVOLUME_SNPRINT_VERBOSE_MAX: usize = 1984; /// The maximum length of strings returned by [`pa_volume_snprint()`]. /// /// Please note that this value can change with any release without warning and without being /// considered API or ABI breakage. You should not use this definition anywhere where it might /// become part of an ABI. pub const PA_VOLUME_SNPRINT_MAX: usize = 10; /// The maximum length of strings returned by [`pa_sw_volume_snprint_dB()`]. /// /// Please note that this value can change with any release without warning and without being /// considered API or ABI breakage. You should not use this definition anywhere where it might /// become part of an ABI. pub const PA_SW_VOLUME_SNPRINT_DB_MAX: usize = 11; /// The maximum length of strings returned by [`pa_volume_snprint_verbose()`]. /// /// Please note that this value can change with any release without warning and without being /// considered API or ABI breakage. You should not use this definition anywhere where it might /// become part of an ABI. pub const PA_VOLUME_SNPRINT_VERBOSE_MAX: usize = 35; #[inline(always)] pub const fn pa_volume_is_valid(v: pa_volume_t) -> bool { v <= PA_VOLUME_MAX } pub const fn pa_clamp_volume(v: pa_volume_t) -> pa_volume_t { if v < PA_VOLUME_MUTED { return PA_VOLUME_MUTED; } if v > PA_VOLUME_MAX { return PA_VOLUME_MAX; } v } /// Sets the volume of the first n channels to [`PA_VOLUME_NORM`]. #[inline(always)] pub unsafe fn pa_cvolume_reset(a: *mut pa_cvolume, n: u32) -> *mut pa_cvolume { pa_cvolume_set(a, n, PA_VOLUME_NORM) } /// Sets the volume of the first n channels to [`PA_VOLUME_MUTED`]. #[inline(always)] pub unsafe fn pa_cvolume_mute(a: *mut pa_cvolume, n: u32) -> *mut pa_cvolume { pa_cvolume_set(a, n, PA_VOLUME_MUTED) } #[rustfmt::skip] #[link(name = "pulse")] extern "C" { pub fn pa_cvolume_equal(a: *const pa_cvolume, b: *const pa_cvolume) -> i32; pub fn pa_cvolume_init(a: *mut pa_cvolume) -> *mut pa_cvolume; pub fn pa_cvolume_set(a: *mut pa_cvolume, channels: u32, v: pa_volume_t) -> *mut pa_cvolume; pub fn pa_cvolume_snprint(s: *mut c_char, l: usize, c: *const pa_cvolume) -> *mut c_char; pub fn pa_sw_cvolume_snprint_dB(s: *mut c_char, l: usize, c: *const pa_cvolume) -> *mut c_char; pub fn pa_cvolume_snprint_verbose(s: *mut c_char, l: usize, c: *const pa_cvolume, map: *const pa_channel_map, print_dB: i32) -> *mut c_char; pub fn pa_volume_snprint(s: *mut c_char, l: usize, v: pa_volume_t) -> *mut c_char; pub fn pa_sw_volume_snprint_dB(s: *mut c_char, l: usize, v: pa_volume_t) -> *mut c_char; pub fn pa_volume_snprint_verbose(s: *mut c_char, l: usize, v: pa_volume_t, print_dB: i32) -> *mut c_char; pub fn pa_cvolume_avg(a: *const pa_cvolume) -> pa_volume_t; pub fn pa_cvolume_avg_mask(a: *const pa_cvolume, cm: *const pa_channel_map, mask: pa_channel_position_mask_t) -> pa_volume_t; pub fn pa_cvolume_max(a: *const pa_cvolume) -> pa_volume_t; pub fn pa_cvolume_max_mask(a: *const pa_cvolume, cm: *const pa_channel_map, mask: pa_channel_position_mask_t) -> pa_volume_t; pub fn pa_cvolume_min(a: *const pa_cvolume) -> pa_volume_t; pub fn pa_cvolume_min_mask(a: *const pa_cvolume, cm: *const pa_channel_map, mask: pa_channel_position_mask_t) -> pa_volume_t; pub fn pa_cvolume_valid(v: *const pa_cvolume) -> i32; pub fn pa_cvolume_channels_equal_to(a: *const pa_cvolume, v: pa_volume_t) -> i32; pub fn pa_sw_volume_multiply(a: pa_volume_t, b: pa_volume_t) -> pa_volume_t; pub fn pa_sw_cvolume_multiply(dest: *mut pa_cvolume, a: *const pa_cvolume, b: *const pa_cvolume) -> *mut pa_cvolume; pub fn pa_sw_cvolume_multiply_scalar(dest: *mut pa_cvolume, a: *const pa_cvolume, b: pa_volume_t) -> *mut pa_cvolume; pub fn pa_sw_volume_divide(a: pa_volume_t, b: pa_volume_t) -> pa_volume_t; pub fn pa_sw_cvolume_divide(dest: *mut pa_cvolume, a: *const pa_cvolume, b: *const pa_cvolume) -> *mut pa_cvolume; pub fn pa_sw_cvolume_divide_scalar(dest: *mut pa_cvolume, a: *const pa_cvolume, b: pa_volume_t) -> *mut pa_cvolume; pub fn pa_sw_volume_from_dB(f: f64) -> pa_volume_t; pub fn pa_sw_volume_to_dB(v: pa_volume_t) -> f64; pub fn pa_sw_volume_from_linear(v: f64) -> pa_volume_t; pub fn pa_sw_volume_to_linear(v: pa_volume_t) -> f64; pub fn pa_cvolume_remap(v: *mut pa_cvolume, from: *const pa_channel_map, to: *const pa_channel_map) -> *mut pa_cvolume; pub fn pa_cvolume_compatible(v: *const pa_cvolume, ss: *const pa_sample_spec) -> i32; pub fn pa_cvolume_compatible_with_channel_map(v: *const pa_cvolume, cm: *const pa_channel_map) -> i32; pub fn pa_cvolume_get_balance(v: *const pa_cvolume, map: *const pa_channel_map) -> f32; pub fn pa_cvolume_set_balance(v: *mut pa_cvolume, map: *const pa_channel_map, new_balance: f32) -> *mut pa_cvolume; pub fn pa_cvolume_get_fade(v: *const pa_cvolume, map: *const pa_channel_map) -> f32; pub fn pa_cvolume_set_fade(v: *mut pa_cvolume, map: *const pa_channel_map, new_fade: f32) -> *mut pa_cvolume; #[cfg(any(doc, feature = "pa_v8"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v8")))] pub fn pa_cvolume_get_lfe_balance(v: *const pa_cvolume, map: *const pa_channel_map) -> f32; #[cfg(any(doc, feature = "pa_v8"))] #[cfg_attr(docsrs, doc(cfg(feature = "pa_v8")))] pub fn pa_cvolume_set_lfe_balance(v: *mut pa_cvolume, map: *const pa_channel_map, new_balance: f32) -> *mut pa_cvolume; pub fn pa_cvolume_scale(v: *mut pa_cvolume, max: pa_volume_t) -> *mut pa_cvolume; pub fn pa_cvolume_scale_mask(v: *mut pa_cvolume, max: pa_volume_t, cm: *const pa_channel_map, mask: pa_channel_position_mask_t) -> *mut pa_cvolume; pub fn pa_cvolume_set_position(cv: *mut pa_cvolume, map: *const pa_channel_map, t: pa_channel_position_t, v: pa_volume_t) -> *mut pa_cvolume; pub fn pa_cvolume_get_position(cv: *const pa_cvolume, map: *const pa_channel_map, t: pa_channel_position_t) -> pa_volume_t; pub fn pa_cvolume_merge(dest: *mut pa_cvolume, a: *const pa_cvolume, b: *const pa_cvolume) -> *mut pa_cvolume; pub fn pa_cvolume_inc_clamp(v: *mut pa_cvolume, inc: pa_volume_t, limit: pa_volume_t) -> *mut pa_cvolume; pub fn pa_cvolume_inc(v: *mut pa_cvolume, inc: pa_volume_t) -> *mut pa_cvolume; pub fn pa_cvolume_dec(v: *mut pa_cvolume, dec: pa_volume_t) -> *mut pa_cvolume; } libpulse-sys-1.21.0/src/xmalloc.rs000064400000000000000000000050211046102023000151320ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language linking library. // // Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not // copy, modify, or distribute this file except in compliance with said license. You can find copies // of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at // and // respectively. // // Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a // fair-use basis, as discussed in the overall project readme (available in the git repository). //! Memory allocation functions. use std::os::raw::{c_char, c_void}; /// Allocates `n` new structures of the specified type. #[inline(always)] pub unsafe fn pa_xnew(n: usize, k: usize) -> *mut c_void { assert!(n < (std::i32::MAX as usize / k)); pa_xmalloc(n * k) } /// Same as [`pa_xnew()`] but sets the memory to zero. #[inline(always)] pub unsafe fn pa_xnew0(n: usize, k: usize) -> *mut c_void { assert!(n < (std::i32::MAX as usize / k)); pa_xmalloc0(n * k) } /// Same as [`pa_xnew()`] but duplicates the specified data. #[inline(always)] pub unsafe fn pa_xnewdup(p: *const c_void, n: usize, k: usize) -> *mut c_void { assert!(n < (std::i32::MAX as usize / k)); pa_xmemdup(p, n * k) } /// Reallocates `n` new structures of the specified type. #[inline(always)] pub unsafe fn pa_xrenew(p: *mut c_void, n: usize, k: usize) -> *mut c_void { assert!(n < (std::i32::MAX as usize / k)); pa_xrealloc(p, n * k) } #[link(name = "pulse")] extern "C" { /// Allocates the specified number of bytes, just like `malloc()` does. /// However, in case of OOM, terminate. pub fn pa_xmalloc(l: usize) -> *mut c_void; /// Same as [`pa_xmalloc()`] , but initializes allocated memory to 0. pub fn pa_xmalloc0(l: usize) -> *mut c_void; /// The combination of [`pa_xmalloc()`] and `realloc()`. pub fn pa_xrealloc(ptr: *mut c_void, size: usize) -> *mut c_void; /// Frees allocated memory. pub fn pa_xfree(p: *mut c_void); /// Duplicates the specified string, allocating memory with [`pa_xmalloc()`]. pub fn pa_xstrdup(s: *const c_char) -> *mut c_char; /// Duplicates the specified string, but truncate after `l` characters. pub fn pa_xstrndup(s: *const c_char, l: usize) -> *mut c_char; /// Duplicates the specified memory block. pub fn pa_xmemdup(p: *const c_void, l: usize) -> *mut c_void; }