Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ its source package at the repository given.
tracing-core v0.1.36 MIT https://github.com/tokio-rs/tracing
unicode-ident v1.0.26 (MIT OR Apache-2.0) AND Unicode-3.0 https://github.com/dtolnay/unicode-ident
uuid v1.26.1 Apache-2.0 OR MIT https://github.com/uuid-rs/uuid
wasapi v0.26.0 MIT https://github.com/HEnquist/wasapi-rs
wasapi v0.27.0 MIT https://github.com/HEnquist/wasapi-rs
windowfunctions v0.1.1 MIT https://github.com/HEnquist/windowfunctions-rs
windows v0.62.2 MIT OR Apache-2.0 https://github.com/microsoft/windows-rs
windows-collections v0.3.2 MIT OR Apache-2.0 https://github.com/microsoft/windows-rs
Expand Down
4 changes: 2 additions & 2 deletions native/akou-capture/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion native/akou-capture/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pulseaudio = "0.3"
zbus = "5"

[target.'cfg(target_os = "windows")'.dependencies]
wasapi = "0.26"
wasapi = "0.27"
# The same `windows` release wasapi is built on, for the few calls it does not wrap. Dictation
# (DC-N1, DC-N6 to DC-N9, DC-L2) adds the low-level key and mouse hooks and `SendInput`
# (UI_WindowsAndMessaging, UI_Input_KeyboardAndMouse, and Graphics_Gdi for a window class), the clipboard's delayed rendering
Expand Down
22 changes: 10 additions & 12 deletions native/akou-capture/src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ fn device_id(d: &Device) -> Option<DeviceId> {
/// The active devices of one direction. `DeviceCollection`'s own iterator panics on an error,
/// and a panic here aborts the helper, so this walks it by index.
fn active(en: &DeviceEnumerator, dir: Direction) -> Vec<Device> {
let Ok(c) = en.get_device_collection(&dir) else {
let Ok(c) = en.get_device_collection(dir) else {
return vec![];
};
let n = c.get_nbr_devices().unwrap_or(0);
Expand All @@ -206,12 +206,12 @@ impl Stream {
/// Starts `client` capturing 32-bit float at `rate` and `channels`, event-driven, with WASAPI
/// converting from the device's own format when it differs (it never changes the device).
fn start(mut client: AudioClient, rate: u32, channels: usize) -> Result<Stream, WasapiError> {
let fmt = WaveFormat::new(32, 32, &SampleType::Float, rate as usize, channels, None);
let fmt = WaveFormat::new(32, 32, SampleType::Float, rate as usize, channels, None);
let mode = StreamMode::EventsShared {
autoconvert: true,
buffer_duration_hns: BUFFER_HNS,
};
client.initialize_client(&fmt, &Direction::Capture, &mode)?;
client.initialize_client(&fmt, Direction::Capture, mode, None)?;
let event = client.set_get_eventhandle()?;
let capture = client.get_audiocaptureclient()?;
client.start_stream()?;
Expand Down Expand Up @@ -410,7 +410,7 @@ fn open_mic(
.iter()
.filter_map(|d| d.get_id().ok())
.collect();
let default = || en.get_default_device_for_role(&Direction::Capture, &Role::Communications);
let default = || en.get_default_device_for_role(Direction::Capture, Role::Communications);
let device = match mic_target(requested, &ids) {
MicTarget::Pinned(id) => en.get_device(&id),
MicTarget::Default => default(),
Expand Down Expand Up @@ -460,10 +460,8 @@ struct CallOpen {
/// The default render devices for the console and communications roles, in that order. They are
/// one device unless the machine sets them apart.
fn default_renders(en: &DeviceEnumerator) -> [Option<Device>; 2] {
[Role::Console, Role::Communications].map(|role| {
en.get_default_device_for_role(&Direction::Render, &role)
.ok()
})
[Role::Console, Role::Communications]
.map(|role| en.get_default_device_for_role(Direction::Render, role).ok())
}

/// What the call side's device watch follows (see `wasapi_rules::render_watch`).
Expand All @@ -478,7 +476,7 @@ fn render_device(en: &DeviceEnumerator) -> Option<DeviceId> {
/// Loopback of the default communications output, the one call apps play to, with its name.
fn open_endpoint() -> Result<(Stream, u32, String), OpenError> {
let device = DeviceEnumerator::new()
.and_then(|en| en.get_default_device_for_role(&Direction::Render, &Role::Communications))
.and_then(|en| en.get_default_device_for_role(Direction::Render, Role::Communications))
.map_err(|e| OpenError::no_device(format!("no output device: {e}")))?;
let name = device
.get_friendlyname()
Expand Down Expand Up @@ -639,8 +637,8 @@ impl Control {
st.default_output = render_device(en);
st.default_input = en
.get_default_device_for_role(
&Direction::Capture,
&Role::Communications,
Direction::Capture,
Role::Communications,
)
.ok()
.and_then(|d| device_id(&d));
Expand Down Expand Up @@ -907,7 +905,7 @@ pub fn list_devices() -> Result<Endpoints, OpenError> {
let en = DeviceEnumerator::new().map_err(|e| err("the device list", e))?;
let side = |dir: Direction, role: Role| {
let default = en
.get_default_device_for_role(&dir, &role)
.get_default_device_for_role(dir, role)
.ok()
.and_then(|d| d.get_id().ok());
active(&en, dir)
Expand Down
Loading