Add PlayStreamError and PauseStreamError.
This allows for properly handling potential failure on macOS. We should also consider propagating the mutex/channel poison errors through these new types, especially considering the potential removal of the event loop in favour of switching over to high-priority audio threads on windows and linux.
This commit is contained in:
parent
ba8d354e93
commit
eae0e18714
9 changed files with 86 additions and 18 deletions
|
|
@ -5,7 +5,7 @@ fn main() {
|
|||
let format = device.default_output_format().expect("Failed to get default output format");
|
||||
let event_loop = cpal::EventLoop::new();
|
||||
let stream_id = event_loop.build_output_stream(&device, &format).unwrap();
|
||||
event_loop.play_stream(stream_id.clone());
|
||||
event_loop.play_stream(stream_id.clone()).unwrap();
|
||||
|
||||
let sample_rate = format.sample_rate.0 as f32;
|
||||
let mut sample_clock = 0f32;
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ fn main() {
|
|||
|
||||
// Play the streams.
|
||||
println!("Starting the input and output streams with `{}` milliseconds of latency.", LATENCY_MS);
|
||||
event_loop.play_stream(input_stream_id.clone());
|
||||
event_loop.play_stream(output_stream_id.clone());
|
||||
event_loop.play_stream(input_stream_id.clone()).unwrap();
|
||||
event_loop.play_stream(output_stream_id.clone()).unwrap();
|
||||
|
||||
// Run the event loop on a separate thread.
|
||||
std::thread::spawn(move || {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ fn main() {
|
|||
let event_loop = cpal::EventLoop::new();
|
||||
let stream_id = event_loop.build_input_stream(&device, &format)
|
||||
.expect("Failed to build input stream");
|
||||
event_loop.play_stream(stream_id);
|
||||
event_loop.play_stream(stream_id).unwrap();
|
||||
|
||||
// The WAV file we're recording to.
|
||||
const PATH: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/recorded.wav");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue