impl Debug for Device (#253)
The internal alsa, null and emscripten Device implementations already implemented Debug; but the coreaudio and wasapi ones, and therefore also the wrapper, did not. I decided to eschew the `Device(…)` wrapping in the outer layer (hence a custom implementation rather than `#[derive(Debug)]`), because `Device(Device)`, `Device(Device { … })` and so forth all look better without the extra `Device(…)` wrapping. On the wasapi and coreaudio implementations I put both the pointer and name. Name because it’s useful, pointer because on Windows at least I believe duplicated names are possible. (e.g. two monitors that include monitors, of the same type; I haven’t strictly confirmed this, because I killed those off harshly on my machine and don’t want to reinstate them.) I do not have access to a macOS device to confirm that the coreaudio implementation is sane, but I think it is.
This commit is contained in:
parent
c2d606176a
commit
2679ea845f
|
@ -15,6 +15,7 @@ use UnknownTypeInputBuffer;
|
||||||
use UnknownTypeOutputBuffer;
|
use UnknownTypeOutputBuffer;
|
||||||
|
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
|
use std::fmt;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::os::raw::c_char;
|
use std::os::raw::c_char;
|
||||||
use std::ptr::null;
|
use std::ptr::null;
|
||||||
|
@ -302,6 +303,15 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for Device {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
f.debug_struct("Device")
|
||||||
|
.field("audio_device_id", &self.audio_device_id)
|
||||||
|
.field("name", &self.name())
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The ID of a stream is its index within the `streams` array of the events loop.
|
// The ID of a stream is its index within the `streams` array of the events loop.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct StreamId(usize);
|
pub struct StreamId(usize);
|
||||||
|
|
|
@ -395,6 +395,12 @@ impl Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for Device {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
fmt::Debug::fmt(&self.0, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl EventLoop {
|
impl EventLoop {
|
||||||
/// Initializes a new events loop.
|
/// Initializes a new events loop.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use std;
|
use std;
|
||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
|
use std::fmt;
|
||||||
use std::io::Error as IoError;
|
use std::io::Error as IoError;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
|
@ -552,6 +553,15 @@ impl Clone for Device {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for Device {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
f.debug_struct("Device")
|
||||||
|
.field("device", &self.device)
|
||||||
|
.field("name", &self.name())
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Drop for Device {
|
impl Drop for Device {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
|
|
Loading…
Reference in New Issue