Skip to content

Commit

Permalink
Refactor Host and related traits into a new traits module
Browse files Browse the repository at this point in the history
This is a draft implementation of RustAudio#294. I'll leave this open for
feedback and potentially better trait naming suggestions or better
solutions in general!

cc @ishitatsuyuki
  • Loading branch information
mitchmindtree committed Jun 29, 2019
1 parent 36dee48 commit 5e4f384
Show file tree
Hide file tree
Showing 12 changed files with 225 additions and 219 deletions.
2 changes: 1 addition & 1 deletion examples/beep.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate cpal;
extern crate failure;

use cpal::{Device, EventLoop, Host};
use cpal::traits::{DeviceTrait, EventLoopTrait, HostTrait};

fn main() -> Result<(), failure::Error> {
let host = cpal::default_host();
Expand Down
2 changes: 1 addition & 1 deletion examples/enumerate.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate cpal;
extern crate failure;

use cpal::{Device, Host};
use cpal::traits::{DeviceTrait, HostTrait};

fn main() -> Result<(), failure::Error> {
println!("Supported hosts:\n {:?}", cpal::ALL_HOSTS);
Expand Down
2 changes: 1 addition & 1 deletion examples/feedback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
extern crate cpal;
extern crate failure;

use cpal::{Device, EventLoop, Host};
use cpal::traits::{DeviceTrait, EventLoopTrait, HostTrait};

const LATENCY_MS: f32 = 150.0;

Expand Down
2 changes: 1 addition & 1 deletion examples/record_wav.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extern crate cpal;
extern crate failure;
extern crate hound;

use cpal::{Device, EventLoop, Host};
use cpal::traits::{DeviceTrait, EventLoopTrait, HostTrait};

fn main() -> Result<(), failure::Error> {
// Use the default host for working with audio devices.
Expand Down
5 changes: 1 addition & 4 deletions src/host/alsa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ use ChannelCount;
use BackendSpecificError;
use BuildStreamError;
use DefaultFormatError;
use Device as DeviceTrait;
use DeviceNameError;
use DevicesError;
use EventLoop as EventLoopTrait;
use Format;
use Host as HostTrait;
use PauseStreamError;
use PlayStreamError;
use SampleFormat;
Expand All @@ -21,10 +18,10 @@ use SupportedFormatsError;
use StreamData;
use StreamDataResult;
use StreamError;
use StreamId as StreamIdTrait;
use SupportedFormat;
use UnknownTypeInputBuffer;
use UnknownTypeOutputBuffer;
use traits::{DeviceTrait, EventLoopTrait, HostTrait, StreamIdTrait};

use std::{cmp, ffi, mem, ptr};
use std::sync::Mutex;
Expand Down
5 changes: 1 addition & 4 deletions src/host/coreaudio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,20 @@ use ChannelCount;
use BackendSpecificError;
use BuildStreamError;
use DefaultFormatError;
use Device as DeviceTrait;
use DeviceNameError;
use DevicesError;
use EventLoop as EventLoopTrait;
use Format;
use Host as HostTrait;
use PauseStreamError;
use PlayStreamError;
use SupportedFormatsError;
use SampleFormat;
use SampleRate;
use StreamData;
use StreamDataResult;
use StreamId as StreamIdTrait;
use SupportedFormat;
use UnknownTypeInputBuffer;
use UnknownTypeOutputBuffer;
use traits::{DeviceTrait, EventLoopTrait, HostTrait, StreamIdTrait};

use std::ffi::CStr;
use std::fmt;
Expand Down
5 changes: 1 addition & 4 deletions src/host/emscripten/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,17 @@ use stdweb::web::set_timeout;

use BuildStreamError;
use DefaultFormatError;
use Device as DeviceTrait;
use DeviceNameError;
use DevicesError;
use EventLoop as EventLoopTrait;
use Format;
use Host as HostTrait;
use PauseStreamError;
use PlayStreamError;
use SupportedFormatsError;
use StreamData;
use StreamDataResult;
use StreamId as StreamIdTrait;
use SupportedFormat;
use UnknownTypeOutputBuffer;
use traits::{DeviceTrait, EventLoopTrait, HostTrait, StreamIdTrait};

/// The default emscripten host type.
#[derive(Debug)]
Expand Down
5 changes: 1 addition & 4 deletions src/host/null/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@

use BuildStreamError;
use DefaultFormatError;
use Device as DeviceTrait;
use DevicesError;
use DeviceNameError;
use EventLoop as EventLoopTrait;
use Format;
use Host as HostTrait;
use PauseStreamError;
use PlayStreamError;
use StreamDataResult;
use SupportedFormatsError;
use StreamId as StreamIdTrait;
use SupportedFormat;
use traits::{DeviceTrait, EventLoopTrait, HostTrait, StreamIdTrait};

#[derive(Default)]
pub struct Devices;
Expand Down
5 changes: 1 addition & 4 deletions src/host/wasapi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@ extern crate winapi;
use BackendSpecificError;
use BuildStreamError;
use DefaultFormatError;
use Device as DeviceTrait;
use DeviceNameError;
use DevicesError;
use EventLoop as EventLoopTrait;
use Format;
use Host as HostTrait;
use PlayStreamError;
use PauseStreamError;
use StreamDataResult;
use StreamId as StreamIdTrait;
use SupportedFormatsError;
use self::winapi::um::winnt::HRESULT;
use std::io::Error as IoError;
use traits::{DeviceTrait, EventLoopTrait, HostTrait, StreamIdTrait};
pub use self::device::{Device, Devices, SupportedInputFormats, SupportedOutputFormats, default_input_device, default_output_device};
pub use self::stream::{EventLoop, StreamId};

Expand Down
Loading

0 comments on commit 5e4f384

Please sign in to comment.