Skip to content

Commit

Permalink
Merge pull request #221 from HEnquist/alsamutex
Browse files Browse the repository at this point in the history
Alsamutex
  • Loading branch information
HEnquist authored Jul 21, 2022
2 parents 6d5a6e0 + 21b1ffc commit 093efe9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.1
Bugfixes:
- Alsa: Avoid opening capture and playback devices at the same time since this causes trouble with some devices.

## 1.0.0
New features:
- New improved CoreAudio backend.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "camilladsp"
version = "1.0.0"
version = "1.0.1"
authors = ["Henrik Enquist <[email protected]>"]
edition = "2021"
description = "A flexible tool for processing audio"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CamillaDSP v1.0.0
# CamillaDSP v1.0.1
![CI test and lint](https://github.com/HEnquist/camilladsp/workflows/CI%20test%20and%20lint/badge.svg)

A tool to create audio processing pipelines for applications such as active crossovers or room correction. It is written in Rust to benefit from the safety and elegant handling of threading that this language provides.
Expand Down
8 changes: 7 additions & 1 deletion src/alsadevice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use rubato::VecResampler;
use std::ffi::CString;
use std::fmt::Debug;
use std::sync::mpsc;
use std::sync::{Arc, Barrier, RwLock};
use std::sync::{Arc, Barrier, Mutex, RwLock};
use std::thread;
use std::time::{Duration, Instant};

Expand All @@ -26,6 +26,10 @@ use crate::Res;
use crate::StatusMessage;
use crate::{CaptureStatus, PlaybackStatus};

lazy_static! {
static ref ALSA_MUTEX: Mutex<()> = Mutex::new(());
}

const STANDARD_RATES: [u32; 17] = [
5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000, 88200, 96000, 176400, 192000,
352800, 384000, 705600, 768000,
Expand Down Expand Up @@ -391,6 +395,8 @@ fn open_pcm(
sample_format: &SampleFormat,
capture: bool,
) -> Res<alsa::PCM> {
// Acquire the lock
let _lock = ALSA_MUTEX.lock().unwrap();
// Open the device
let pcmdev = if capture {
alsa::PCM::new(&devname, Direction::Capture, true)?
Expand Down

0 comments on commit 093efe9

Please sign in to comment.