Skip to content

Commit af54283

Browse files
committed
Update nix dependency
1 parent 68c9568 commit af54283

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

interactive/examples/midi_live_interactive_serial.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn sig(
1919
.keyboard
2020
.opinionated_key_events(Note::B0)
2121
.merge(Sig(key_events))
22-
.poly_voices(48)
22+
.poly_voices(12)
2323
.into_iter()
2424
.map(
2525
|MonoVoice {

midi-serial/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ anyhow = "1.0"
1414
caw_core = { version = "0.5", path = "../core" }
1515
caw_midi = { version = "0.4", path = "../midi" }
1616
midly = "0.5"
17-
nix = { version = "0.29", features = ["fs", "term"] }
17+
nix = { version = "0.30", features = ["fs", "term"] }

midi-serial/src/lib.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ use caw_core::{Sig, SigT};
22
use caw_midi::MidiMessages;
33
use midly::live::LiveEvent;
44
use nix::sys::termios::BaudRate;
5-
use std::{os::fd::OwnedFd, path::Path};
5+
use std::{
6+
os::fd::{AsFd, OwnedFd},
7+
path::Path,
8+
};
69

710
pub struct MidiLiveSerial {
811
owned_fd: OwnedFd,
@@ -45,16 +48,11 @@ impl MidiLiveSerial {
4548
termios::{self, LocalFlags, SetArg},
4649
},
4750
};
48-
let fd = fcntl::open(
51+
let owned_fd = fcntl::open(
4952
tty_path.as_ref(),
5053
OFlag::O_RDONLY | OFlag::O_NONBLOCK,
5154
Mode::empty(),
5255
)?;
53-
let owned_fd = unsafe {
54-
use std::os::fd::FromRawFd;
55-
// fd is a valid file descriptor and the only cleanup it needs is close
56-
OwnedFd::from_raw_fd(fd)
57-
};
5856
let mut termios = termios::tcgetattr(&owned_fd)?;
5957
termios.local_flags &= !(LocalFlags::ECHO | LocalFlags::ICANON);
6058
let baud_rate = Self::convert_baud_rate(baud_rate)?;
@@ -65,9 +63,8 @@ impl MidiLiveSerial {
6563

6664
fn read_byte(&self) -> anyhow::Result<Option<u8>> {
6765
use nix::{errno::Errno, unistd};
68-
use std::os::fd::AsRawFd;
6966
let mut buf = [0];
70-
let nbytes = match unistd::read(self.owned_fd.as_raw_fd(), &mut buf) {
67+
let nbytes = match unistd::read(self.owned_fd.as_fd(), &mut buf) {
7168
Ok(nbytes) => nbytes,
7269
Err(Errno::EAGAIN) => 0,
7370
Err(e) => return Err(e.into()),

0 commit comments

Comments
 (0)