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
/*!
The devices module's purpose is to make interacting with audio devices easier.<br>
You can use it to check all devices and check if the user has a valid output device.<br><br>
# Usage
A simple program using this module:
```
use rs_audio::misc::devices::*;
use rodio::DeviceTrait; // Note that you have to import the DeviceTrait from rodio for this to work.
if !has_valid_device() {
eprintln!("No valid audio output device detected!");
std::process::exit(1);
}
let all_devices = all_devices().unwrap();
for (key, device) in all_devices.iter().enumerate() {
println!("{}: {:?}", key, device.name())
}
```
*/
use ;
/**
Checks if the host has a valid output device (ie. headphones, speakers, etc...).<br><br>
## Usage
Example:
```
use rs_audio::misc::devices::{has_valid_device};
if has_valid_device() {
println!("You have a valid audio output device!");
}
else {
println!("Couldn't find valid audio output device!");
}
```
*/
/**
Finds the default host's devices and outputs a vector of `Device` structs.<br>
Note that this relies on `cpal`.<br> Also, this is not intended to be shown to the user.<br>
# Panics
This function will panic if it cannot find any output device.<br>
It is recommended to pair this with the `has_valid_device()` function.
```
use rs_audio::misc::devices::{has_valid_device, all_devices};
use rodio::DeviceTrait; // Note that you have to import the DeviceTrait from rodio for this to work.
if has_valid_device() {
let devices = all_devices().unwrap();
// Do something with the devices here...
// Simple example:
for device in devices {
println!("{:?}", device.name());
}
}
```
*/