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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ jobs:
with:
cache-all-crates: true

- name: Check format
run: cargo fmt --all -- --check

- name: Setup Linux dependencies
if: runner.os == 'Linux' && matrix.setup != 'linux-aarch64' && matrix.setup != 'wasm' && matrix.setup != 'android'
run: |
Expand Down
27 changes: 17 additions & 10 deletions src/backend/alsa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{errors, Ignore, MidiMessage};
use alsa::seq::{Addr, EventType, PortCap, PortInfo, PortSubscribe, PortType, QueueTempo};
use alsa::{Direction, Seq};

use log::{error, debug, log_enabled, Level};
use log::{debug, error, log_enabled, Level};

use errors::*;

Expand Down Expand Up @@ -178,7 +178,9 @@ impl PipeFd {

impl Drop for PipeFd {
fn drop(&mut self) {
unsafe { libc::close(self.0); }
unsafe {
libc::close(self.0);
}
}
}

Expand Down Expand Up @@ -230,9 +232,7 @@ impl MidiInput {
let mut queue_id = 0;
// Create the input queue
if !cfg!(feature = "avoid_timestamping") {
queue_id = seq
.alloc_named_queue(c"midir queue")
.unwrap();
queue_id = seq.alloc_named_queue(c"midir queue").unwrap();
// Set arbitrary tempo (mm=100) and resolution (240)
let qtempo = QueueTempo::empty().unwrap();
qtempo.set_tempo(600_000);
Expand Down Expand Up @@ -481,7 +481,10 @@ impl<T> MidiInputConnection<T> {
// Request the thread to stop.
let _res = unsafe {
libc::write(
self.trigger_send_fd.as_ref().expect("send_fd already taken").get(),
self.trigger_send_fd
.as_ref()
.expect("send_fd already taken")
.get(),
&false as *const bool as *const _,
mem::size_of::<bool>() as libc::size_t,
)
Expand Down Expand Up @@ -704,9 +707,10 @@ impl MidiOutputConnection {
assert!(nbytes <= u32::MAX as usize);

if nbytes > self.coder.get_buffer_size() as usize
&& self.coder.resize_buffer(nbytes as u32).is_err() {
return Err(SendError::Other("could not resize ALSA encoding buffer"));
}
&& self.coder.resize_buffer(nbytes as u32).is_err()
{
return Err(SendError::Other("could not resize ALSA encoding buffer"));
}

let mut ev = match self.coder.get_wrapped().encode(message) {
Ok((_, Some(ev))) => ev,
Expand Down Expand Up @@ -834,7 +838,10 @@ fn handle_input<T>(mut data: HandlerData<T>, user_data: &mut T) -> HandlerData<T
continue;
}
Err(ref e) => {
error!("Error in handle_input: unknown ALSA MIDI input error ({})!", e);
error!(
"Error in handle_input: unknown ALSA MIDI input error ({})!",
e
);
continue;
}
};
Expand Down
7 changes: 3 additions & 4 deletions src/backend/jack/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,7 @@ extern "C" fn handle_input<T>(nframes: jack_nframes_t, arg: *mut c_void) -> i32
let event = unsafe { event.assume_init() };

for i in 0..event.size {
message
.bytes
.push(unsafe { *event.buffer.add(i) });
message.bytes.push(unsafe { *event.buffer.add(i) });
}

message.timestamp = Client::get_time(); // this is in microseconds
Expand Down Expand Up @@ -363,7 +361,8 @@ impl MidiOutput {
.client
.as_mut()
.unwrap()
.connect(source_port.get_name(), &port.name).is_err()
.connect(source_port.get_name(), &port.name)
.is_err()
{
return Err(ConnectError::new(ConnectErrorKind::InvalidPort, self));
}
Expand Down
9 changes: 3 additions & 6 deletions src/backend/jack/wrappers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ impl Client {
}

pub fn open(name: &str, options: JackOpenOptions) -> Result<Client, ()> {
let c_name = CString::new(name)
.expect("client name must not contain null bytes");
let c_name = CString::new(name).expect("client name must not contain null bytes");
let result = unsafe { jack_client_open(c_name.as_ptr(), options.bits(), ptr::null_mut()) };
if result.is_null() {
Err(())
Expand Down Expand Up @@ -89,8 +88,7 @@ impl Client {
}

pub fn register_midi_port(&mut self, name: &str, flags: PortFlags) -> Result<MidiPort, ()> {
let c_name = CString::new(name)
.expect("port name must not contain null bytes");
let c_name = CString::new(name).expect("port name must not contain null bytes");
let result = unsafe {
jack_port_register(
self.p,
Expand Down Expand Up @@ -169,8 +167,7 @@ impl<'a> Index<usize> for PortInfos<'a> {

fn index(&self, index: usize) -> &Self::Output {
let slice = self.get_c_name(index).to_bytes();
str::from_utf8(slice)
.expect("Error converting port name to UTF8")
str::from_utf8(slice).expect("Error converting port name to UTF8")
}
}

Expand Down
Loading