libpulse-glib-binding-2.28.1/.cargo_vcs_info.json0000644000000001710000000000100152670ustar { "git": { "sha1": "83adaf1280fe7ac5fdff6cd14f80bf749bddd29c" }, "path_in_vcs": "pulse-binding-mainloop-glib" }libpulse-glib-binding-2.28.1/CHANGELOG.md000064400000000000000000000214101046102023000156670ustar 00000000000000# 2.28.1 (July 18th, 2023) * Fixed cross-crate version requirements. # 2.28.0 (July 18th, 2023) * Fixed docs.rs build failure. * Dropped PA v4 support. # 2.27.1 (January 9th, 2023) * Fixed broken build status badge in readme. # 2.27.0 (January 9th, 2023) * Bumped Rust edition to 2021. * Added `rust-version` (MSRV) attribute to `cargo.toml` file. * Updated required dependencies: - `libpulse-binding` from 2.24 to 2.27. - `libpulse-mainloop-glib-sys` from 1.19 to 1.20. Note: version 2.26 skipped to catch up with main `libpulse-binding` version. # 2.25.1 (January 13th, 2022) * Minor tweaks not worth documenting. # 2.25.0 (August 29th, 2021) * Minor tweaks to work with the changes in verson 2.25.0 of the main binding crate. * Minor formatting tweaks. * Updated required dependencies: - `libpulse-binding` from 2.24 to 2.25. # 2.24.0 (July 28th, 2021) * Updated required dependencies: - `libpulse-binding` from 2.23 to 2.24. - `libpulse-mainloop-glib-sys` from 1.16 to 1.19. # 2.23.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. * Updated required dependencies: - `libpulse-binding` from 2.20 to 2.23. Note: versions 2.21 and 2.22 skipped, used only for `libpulse-binding` crate changes. # 2.20.2 (December 26th, 2020) * Fixed segfault thanks to @DanielChabrowski on github. # 2.20.1 (December 15th, 2020) * Fixed mistake made trying to conditionally enable `#[cfg(doc)]` for docs.rs. # 2.20.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. * 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). * Updated required dependencies: - `libpulse-binding` from 2.18 to 2.20. - `libpulse-mainloop-glib-sys` from 1.15 to 1.16. Note: version 2.19 skipped, used only for `libpulse-binding` crate changes. # 2.18.1 (November 25th, 2020) * Fixed deprecated license attribute syntax. # 2.18.0 (November 25th, 2020) * Updated required dependencies: - `libpulse-binding` from 2.17 to 2.18. - `libpulse-mainloop-glib-sys` from 1.14 to 1.15. # 2.17.0 (November 24th, 2020) * Updated required dependencies: - `libpulse-binding` from 2.16 to 2.17. - `libpulse-mainloop-glib-sys` from 1.13 to 1.14. # 2.16.1 (September 9th, 2020) * Bumped `pa_latest_common` feature to target PA v13. # 2.16.0 (April 18th, 2020) * Removed deprecated Cargo features. * Updated required dependencies: - `libpulse-binding` from 2.15 to 2.16. - `libpulse-mainloop-glib-sys` from 1.12 to 1.13. # 2.15.0 (December 29th, 2019) * Updated required dependencies: - `libpulse-binding` from 2.14 to 2.15. - `libpulse-mainloop-glib-sys` from 1.11 to 1.12. # 2.14.0 (October 28th, 2019) * Updated required dependencies: - `libpulse-binding` from 2.13 to 2.14. # 2.13.0 (September 17th, 2019) * Changed the license model from LGPL to dual MIT and Apache-2.0. See [here][issue26] for details. * Updated required dependencies: - `libpulse-binding` from 2.12 to 2.13. - `libpulse-mainloop-glib-sys` from 1.10 to 1.11. # 2.12.0 (September 15th, 2019) * Added PA v13 compatibility control feature. * Updated required dependencies: - `libpulse-binding` from 2.11 to 2.12. - `libpulse-mainloop-glib-sys` from 1.9 to 1.10. # 2.11.1 (August 19th, 2019) * Fixed broken doc.rs documentation generation. # 2.11.0 (August 19th, 2019) * Extended support to even older versions of PA, specifically up to and including v4. * 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. * Updated required dependencies: - `libpulse-binding` from 2.10 to 2.11. - `libpulse-mainloop-glib-sys` from 1.8 to 1.9. # 2.10.0 (August 15th, 2019) * Updated `use` conventions to that of Rust 1.30/1.31. * Specified edition in toml file. * Updated required dependencies: - `libpulse-binding` from 2.7 to 2.10. - `libpulse-mainloop-glib-sys` from 1.6 to 1.8. # 2.9.0 (August 14th, 2019) * Changed `Mainloop::new()` to take a ref of `glib::MainContext` not `glib_sys::GMainContext`. # 2.8.0 (August 13th, 2019) * Addressed long standing todo item of linking `GMainContext` to an actual glib crate. - Added dependency on `glib-sys`. - Replaced our own `GMainContext` type (re-exported from our `sys` crate) with the one from the `glib-sys` crate. - Deprecated use of `GMainContext` directly from this crate. # 2.7.1 (August 13th, 2019) * Fix missed use of UB empty enum trick. * Fixed missing simplification of pointer handling. # 2.7.0 (August 12th, 2019) * Added a new `latest_pa_common_compatibility` feature flag, used by default now instead of `latest_pa_compatibility`. * Updated required dependencies: - `libpulse-binding` from 2.6 to 2.7. - `libpulse-mainloop-glib-sys` from 1.5 to 1.6. # 2.6.0 (March 10th, 2019) * Updated required dependencies: - `libpulse-binding` from 2.5 to 2.6. # 2.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`. * Updated required dependencies: - `libpulse-binding` from 2.4 to 2.5. - `libpulse-mainloop-glib-sys` from 1.4 to 1.5. # 2.4.0 (November 28th, 2018) * Updated required dependencies: - `libpulse-binding` from 2.3 to 2.4. # 2.3.0 (November 4th, 2018) * Clarified `pa_encoding_from_string` feature purpose. * Updated required dependencies: - `libpulse-binding` from 2.2 to 2.3. - `libpulse-mainloop-glib-sys` from 1.3 to 1.4. # 2.2.5 (October 8th, 2018) * Fixed broken attempt to include license file in bundled package. # 2.2.4 (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` and `README.md` files. # 2.2.3 (September 20th, 2018) * Fixed feature control. # 2.2.2 (September 3rd, 2018) * Added homepage and repo links, thanks to @berkus on github for the patch. * Expanded the `pa_encoding_from_string` feature to properly control it across dependencies. Thanks to @thejpster on github for reporting. Note, version number 2.2.1 skipped, bumping number into line with the main binding crate. # 2.2 (August 21st, 2018) * Updated required dependencies: - `libpulse-binding` from 2.1 to 2.2. # 2.1 (July 17th, 2018) * Mainloop API objects now correctly treated as immutable, per related change in version 2.1 of `libpulse-binding`. * Implemented new signals trait from version 2.1 of the main binding. * Updated required dependencies: - `libpulse-binding` from 2.0 to 2.1. - `libpulse-mainloop-glib-sys` from 1.2 to 1.3. # 2.0.1 (June 26th, 2018) * Doc typo fix. * Updated version in `README` usage example. # 2.0 (June 16th, 2018) * Updated required dependencies: - `libpulse-binding` from 1.2 to 2.0. - `libpulse-mainloop-glib-sys` from 1.1 to 1.2. # 1.2 (June 1st, 2018) * Now returning `get_api()` pointer as ref, as done with standard and threaded mainloops. * Updated required dependencies: - `libpulse-binding` from 1.1 to 1.2. # 1.1 (May 27th, 2018) * Updated required dependencies: - `libpulse-binding` from 1.0 to 1.1. - `libpulse-mainloop-glib-sys` from 1.0 to 1.1. # 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. * Removed obsolete readme doc links. # 1.0 (January 24th, 2018) * Original release. [issue26]: https://github.com/jnqnfe/pulse-binding-rust/issues/26 libpulse-glib-binding-2.28.1/Cargo.toml0000644000000036730000000000100132770ustar # 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-glib-binding" version = "2.28.1" authors = ["Lyndon Brown "] exclude = ["README.md"] description = "A Rust language binding for the PulseAudio libpulse-mainloop-glib library." homepage = "https://github.com/jnqnfe/pulse-binding-rust" readme = "README.md" keywords = [ "binding", "pulseaudio", "glib", "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.glib] version = "0" default-features = false [dependencies.glib-sys] version = "0" default-features = false [dependencies.libpulse-binding] version = "2.28" default-features = false [dependencies.libpulse-mainloop-glib-sys] version = "1.21" default-features = false [features] default = ["pa_v8"] pa_v12 = [ "pa_v8", "libpulse-binding/pa_v12", "libpulse-mainloop-glib-sys/pa_v12", ] pa_v13 = [ "pa_v12", "libpulse-binding/pa_v13", "libpulse-mainloop-glib-sys/pa_v13", ] pa_v14 = [ "pa_v13", "libpulse-binding/pa_v14", "libpulse-mainloop-glib-sys/pa_v14", ] pa_v15 = [ "pa_v14", "libpulse-binding/pa_v15", "libpulse-mainloop-glib-sys/pa_v15", ] pa_v6 = [ "libpulse-binding/pa_v6", "libpulse-mainloop-glib-sys/pa_v6", ] pa_v8 = [ "pa_v6", "libpulse-binding/pa_v8", "libpulse-mainloop-glib-sys/pa_v8", ] libpulse-glib-binding-2.28.1/Cargo.toml.orig000064400000000000000000000030611046102023000167470ustar 00000000000000[package] edition = "2021" name = "libpulse-glib-binding" version = "2.28.1" authors = ["Lyndon Brown "] license = "MIT OR Apache-2.0" readme = "README.md" description = "A Rust language binding for the PulseAudio libpulse-mainloop-glib library." keywords = ["binding", "pulseaudio", "glib", "audio"] homepage = "https://github.com/jnqnfe/pulse-binding-rust" repository = "https://github.com/jnqnfe/pulse-binding-rust" exclude = ["README.md"] rust-version = "1.56" [dependencies] libpulse-binding = { path = "../pulse-binding", version = "2.28", default-features = false } libpulse-mainloop-glib-sys = { path = "../pulse-sys-mainloop-glib", version = "1.21", default-features = false } glib-sys = { version = "0", default-features = false } glib = { version = "0", default-features = false } [features] default = ["pa_v8"] # PA version compatibility selection # See the overall project `COMPATIBILITY.md` file for explanation. pa_v15 = ["pa_v14", "libpulse-binding/pa_v15", "libpulse-mainloop-glib-sys/pa_v15"] pa_v14 = ["pa_v13", "libpulse-binding/pa_v14", "libpulse-mainloop-glib-sys/pa_v14"] pa_v13 = ["pa_v12", "libpulse-binding/pa_v13", "libpulse-mainloop-glib-sys/pa_v13"] pa_v12 = ["pa_v8", "libpulse-binding/pa_v12", "libpulse-mainloop-glib-sys/pa_v12"] pa_v8 = ["pa_v6", "libpulse-binding/pa_v8", "libpulse-mainloop-glib-sys/pa_v8"] pa_v6 = [ "libpulse-binding/pa_v6", "libpulse-mainloop-glib-sys/pa_v6"] [package.metadata.docs.rs] all-features = false no-default-features = true rustdoc-args = ["--cfg", "docsrs"] libpulse-glib-binding-2.28.1/LICENSE-APACHE000064400000000000000000000251371046102023000160140ustar 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-glib-binding-2.28.1/LICENSE-MIT000064400000000000000000000020401046102023000155100ustar 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-glib-binding-2.28.1/README.md000064400000000000000000000050531046102023000153420ustar 00000000000000libpulse-glib-binding ===================== [GitHub Workflow Status](https://github.com/jnqnfe/pulse-binding-rust/actions) [crates.io](https://crates.io/crates/libpulse-glib-binding) [docs.rs](https://docs.rs/libpulse-glib-binding) [min-rust-version](https://rust-lang.github.io/rfcs/2495-min-rust-version.html) A Rust language binding for the PulseAudio libpulse-mainloop-glib library. ## Usage Add the following two crates to the dependencies specified in your `Cargo.toml` (you will likely need to use components from the main binding crate in addition to this crate itself): ```toml [dependencies] libpulse-binding = "2.0" libpulse-glib-binding = "2.0" ``` Though you may wish to rename the crates to shorter names (for example `pulse` and `pulse_glib`) for cleaner references within your code: ```toml [dependencies] pulse = { version = "2.0", package = "libpulse-binding" } pulse_glib = { version = "2.0", package = "libpulse-glib-binding" } ``` An alternative to that which some may prefer is: ```toml [dependencies.pulse] version = "2.0" package = "libpulse-binding" [dependencies.pulse_glib] version = "2.0" package = "libpulse-glib-binding" ``` ### 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-glib-binding-2.28.1/src/lib.rs000064400000000000000000000142661046102023000157740ustar 00000000000000// Copyright 2017 Lyndon Brown // // This file is part of the PulseAudio Rust language binding. // // 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 binding for the PulseAudio ‘GLIB mainloop’ component (`libpulse-mainloop-glib` system //! library). //! //! # About //! //! This binding enables Rust projects to make use of the ‘GLIB mainloop’ component of the //! [PulseAudio] client system library. It builds upon the [separate raw FFI crate][sys] to provide //! a more “Rusty” interface. //! //! This component provides a wrapper around the GLIB main loop. Use this to embed PulseAudio into //! your GLIB/GTK+/GNOME programs. //! //! Note that you will need components of the primary [`libpulse-binding`] crate to make use of //! this. //! //! # Introduction //! //! The GLIB main loop bindings are extremely easy to use. All that is required is to create a //! Mainloop object using [`Mainloop::new()`]. When the main loop abstraction is needed, it is //! provided by [`Mainloop::get_api()`]. //! //! # Usage //! //! Start by adding a dependency on the crate, along with the main binding crate, in your program’s //! `Cargo.toml` file. Note that it is recommended that you rename the crates such that you can //! refer to them by shorter names within your code (such as `pulse` and `pulse_glib`). Such //! renaming can be done [within your `Cargo.toml` file][rename] with cargo version 1.31 or newer, //! or otherwise with `extern crate` statements. //! //! See the documentation in [`libpulse-binding`] for further information regarding actual usage of //! libpulse mainloops. //! //! [sys]: https://docs.rs/libpulse-mainloop-glib-sys //! [`libpulse-binding`]: https://docs.rs/libpulse-binding //! [PulseAudio]: https://en.wikipedia.org/wiki/PulseAudio //! [rename]: https://doc.rust-lang.org/1.31.0/cargo/reference/specifying-dependencies.html#renaming-dependencies-in-cargotoml #![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" )] #![warn(missing_docs)] #![cfg_attr(docsrs, feature(doc_cfg))] extern crate libpulse_binding as pulse; extern crate libpulse_mainloop_glib_sys as capi; use std::rc::Rc; use std::ptr::null_mut; use glib_sys::GMainContext; use glib::{MainContext, translate::ToGlibPtr}; use std::mem; use pulse::mainloop::api::{MainloopInternalType, MainloopInner, MainloopInnerType, MainloopApi}; use pulse::mainloop::signal::MainloopSignals; use pulse::mainloop::api::Mainloop as MainloopTrait; /* Note, we cannot simply use the object defined in the ‘sys’ crate, since either the type or the * trait need to be defined locally in order to link them. Thus, we create the below type (an empty * one, just used as an opaque pointer), and transmute to the ‘sys’ crate one. */ /// An opaque GLIB main loop object. #[repr(C)] pub struct MainloopInternal { _private: [u8; 0] } impl MainloopInternalType for MainloopInternal {} /// This acts as a safe interface to the internal PA Mainloop. /// /// The mainloop object pointers are further enclosed here in a ref counted wrapper, allowing this /// outer wrapper to have clean methods for creating event objects, which can cleanly pass a copy of /// the inner ref counted mainloop object to them. Giving this to events serves two purposes, /// firstly because they need the API pointer, secondly, it ensures that event objects do not /// outlive the mainloop object. pub struct Mainloop { /// The ref-counted inner data. pub _inner: Rc>, } impl MainloopTrait for Mainloop { type MI = MainloopInner; #[inline(always)] fn inner(&self) -> Rc> { Rc::clone(&self._inner) } } impl MainloopSignals for Mainloop {} /// Drop function for MainloopInner. #[inline(always)] fn drop_actual(self_: &mut MainloopInner) { unsafe { capi::pa_glib_mainloop_free(mem::transmute(self_.get_ptr())) }; } impl Mainloop { /// Creates a new GLIB main loop object for the specified GLIB main loop context. /// /// Takes an argument `context` for the [`glib::MainContext`] to use. If context is `None` the /// default context is used. /// /// This returns the object in an Rc wrapper, allowing multiple references to be held, which /// allows event objects to hold one, thus ensuring they do not outlive it. pub fn new(context: Option<&mut MainContext>) -> Option { let p_ctx = context.map_or(null_mut::(), |c| c.to_glib_none().0); let ptr = unsafe { capi::pa_glib_mainloop_new(p_ctx) }; if ptr.is_null() { return None; } let api_ptr = unsafe { mem::transmute(capi::pa_glib_mainloop_get_api(ptr)) }; let ml_inner = unsafe { MainloopInner::::new(mem::transmute(ptr), api_ptr, drop_actual, false) }; Some(Self { _inner: Rc::new(ml_inner) }) } /// Gets the abstract main loop abstraction layer vtable for this main loop. /// /// No need to free the API as it is owned by the loop and is destroyed when the loop is freed. /// /// Talking to PA directly with C requires fetching this pointer explicitly via this function. /// This is actually unnecessary through this binding. The pointer is retrieved automatically /// upon Mainloop creation, stored internally, and automatically obtained from it by functions /// that need it. pub fn get_api<'a>(&self) -> &'a MainloopApi { let ptr = self._inner.get_api_ptr(); assert_eq!(false, ptr.is_null()); unsafe { &*ptr } } }