1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
//! PulseAudio integration for managing audio devices and streams.
//!
//! # Overview
//!
//! Provides reactive access to PulseAudio through [`AudioService`].
//! All state is exposed via [`Property`] fields that automatically update when
//! PulseAudio state changes.
//!
//! # Reactive Properties
//!
//! Every field on [`AudioService`], [`OutputDevice`], [`InputDevice`], and
//! [`AudioStream`] is a [`Property<T>`] with two access patterns:
//!
//! - **Snapshot**: Call `.get()` for the current value
//! - **Stream**: Call `.watch()` for a `Stream<Item = T>` that yields on changes
//!
//! ```rust,no_run
//! use wayle_audio::AudioService;
//! use futures::StreamExt;
//!
//! # async fn example() -> Result<(), wayle_audio::Error> {
//! let audio = AudioService::new().await?;
//!
//! // Snapshot: get current default output device
//! if let Some(device) = audio.default_output.get() {
//! println!("Default output: {}", device.description.get());
//! println!("Volume: {:?}", device.volume.get());
//! println!("Muted: {}", device.muted.get());
//! }
//!
//! // Stream: react to default output changes
//! let mut stream = audio.default_output.watch();
//! while let Some(maybe_device) = stream.next().await {
//! match maybe_device {
//! Some(device) => println!("Default changed to: {}", device.description.get()),
//! None => println!("No default output"),
//! }
//! }
//! # Ok(())
//! # }
//! ```
//!
//! # Live vs Snapshot Instances
//!
//! Devices from [`AudioService`] fields (`output_devices`, `default_output`, etc.)
//! are **live**: their properties update when PulseAudio state changes.
//!
//! The explicit lookup methods differ:
//!
//! | Method | Returns | Properties Update? |
//! |--------|---------|-------------------|
//! | `output_device()` | `OutputDevice` | No (snapshot) |
//! | `output_device_monitored()` | `Arc<OutputDevice>` | Yes (live) |
//!
//! ```rust,no_run
//! # use wayle_audio::{AudioService, types::device::{DeviceKey, DeviceType}};
//! # async fn example() -> Result<(), wayle_audio::Error> {
//! # let audio = AudioService::new().await?;
//! # let key = DeviceKey::new(0, DeviceType::Output);
//! // Snapshot: properties won't update
//! let snapshot = audio.output_device(key).await?;
//! let vol_at_query_time = snapshot.volume.get();
//!
//! // Live: properties update automatically
//! let live = audio.output_device_monitored(key).await?;
//! let mut vol_stream = live.volume.watch();
//! // vol_stream yields whenever volume changes in PulseAudio
//! # Ok(())
//! # }
//! ```
//!
//! # Controlling Devices
//!
//! [`OutputDevice`] and [`InputDevice`] have control methods:
//!
//! ```rust,no_run
//! # use wayle_audio::{AudioService, volume::types::Volume};
//! # async fn example() -> Result<(), wayle_audio::Error> {
//! # let audio = AudioService::new().await?;
//! if let Some(device) = audio.default_output.get() {
//! // Mute/unmute
//! device.set_mute(true).await?;
//!
//! // Set volume (0.0 to 1.0 per channel)
//! device.set_volume(Volume::stereo(0.5, 0.5)).await?;
//!
//! // Make this device the default
//! device.set_as_default().await?;
//! }
//! # Ok(())
//! # }
//! ```
//!
//! # Configuration
//!
//! | Method | Effect |
//! |--------|--------|
//! | `with_daemon()` | Control audio from scripts or other processes |
//!
//! ```rust,no_run
//! use wayle_audio::AudioService;
//!
//! # async fn example() -> Result<(), wayle_audio::Error> {
//! let audio = AudioService::builder()
//! .with_daemon()
//! .build()
//! .await?;
//! # Ok(())
//! # }
//! ```
//!
//! # D-Bus Interface
//!
//! When `with_daemon()` is enabled, the service registers on the session bus.
//!
//! - **Service:** `com.wayle.Audio1`
//! - **Path:** `/com/wayle/Audio`
//! - **Interface:** `com.wayle.Audio1`
//!
//! See [`dbus.md`](https://github.com/wayle-rs/wayle-services/blob/master/wayle-audio/dbus.md) for the full interface specification.
//!
//! # Service Fields
//!
//! [`AudioService`] exposes these reactive properties:
//!
//! | Field | Type | Description |
//! |-------|------|-------------|
//! | [`output_devices`] | `Vec<Arc<OutputDevice>>` | All sinks (speakers, headphones) |
//! | [`input_devices`] | `Vec<Arc<InputDevice>>` | All sources (microphones) |
//! | [`default_output`] | `Option<Arc<OutputDevice>>` | Current default sink |
//! | [`default_input`] | `Option<Arc<InputDevice>>` | Current default source |
//! | [`playback_streams`] | `Vec<Arc<AudioStream>>` | Active playback (apps playing audio) |
//! | [`recording_streams`] | `Vec<Arc<AudioStream>>` | Active recording (apps capturing audio) |
//!
//! [`output_devices`]: AudioService::output_devices
//! [`input_devices`]: AudioService::input_devices
//! [`default_output`]: AudioService::default_output
//! [`default_input`]: AudioService::default_input
//! [`playback_streams`]: AudioService::playback_streams
//! [`recording_streams`]: AudioService::recording_streams
//! [`Property`]: wayle_core::Property
//! [`Property<T>`]: wayle_core::Property
//! [`OutputDevice`]: core::device::output::OutputDevice
//! [`InputDevice`]: core::device::input::InputDevice
//! [`AudioStream`]: core::stream::AudioStream
/// Core domain models
/// D-Bus interface for external control
/// Types for the audio service
/// Volume control domain
pub use AudioServiceBuilder;
pub use Error;
pub use AudioService;
;