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
//! # coreaudio
//!
//! A safe, idiomatic Rust wrapper around the macOS CoreAudio Hardware Abstraction Layer (HAL).
//!
//! This crate models the CoreAudio object hierarchy — system, devices, and streams — as
//! generic [`AudioObject<T>`] types, where the type parameter determines which properties
//! and operations are available. Properties carry compile-time metadata encoding their
//! value type, access mode (read-only vs read-write), and whether they support listeners,
//! so invalid operations are caught at compile time rather than at runtime.
//!
//! ## Core concepts
//!
//! - **[`AudioObject<System>`]** is the entry point. Use it to enumerate devices or
//! query system-wide audio state.
//! - **[`AudioObject<Device>`]** represents a single audio device. Read and write
//! properties like sample rate and buffer size, enumerate streams, or register
//! IO procs for audio rendering.
//! - **[`AudioObject<Stream>`]** represents an individual stream on a device. Inspect
//! its virtual/physical format, direction, and latency.
//! - **[`Property`] constants** (e.g. [`DEVICE_NAME`], [`DEVICE_NOMINAL_SAMPLE_RATE`])
//! are passed to `get_property`, `set_property`, and `add_listener`. The type system
//! enforces that you can only write to read-write properties and only listen to
//! listenable ones.
//! - **[`PropertyListener`]** watches a property for changes, offering non-blocking,
//! blocking, and timeout-based polling.
//! - **[`IOProc`]** wraps a CoreAudio I/O procedure, letting you register an audio
//! render callback and control playback.
//!
//! ## Quick start
//!
//! ```rust,no_run
//! use coreaudio::{AudioObject, System, Scope, DEVICE_NAME};
//!
//! let system = AudioObject::<System>::default();
//! let devices = system.devices_with_scope(Scope::Output)?;
//!
//! for device in &devices {
//! let name: String = device.get_property(DEVICE_NAME)?;
//! println!("{}", name);
//! }
//! # Ok::<(), coreaudio::CoreAudioError>(())
//! ```
// ---- Modules ------------
// ---- Re-exports ------------
// Data types
pub use ;
// Errors
pub use ;
// Objects
pub use ;
// Listener
pub use PropertyListener;
// IO Proc
pub use ;
// Property
pub use Property;
// Property constants
pub use ;