Skip to content

Commit e2933e9

Browse files
committed
2.0.0
1 parent 704d0b6 commit e2933e9

File tree

4 files changed

+63
-35
lines changed

4 files changed

+63
-35
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: CI
2-
on: [push, pull_request]
2+
on: [ push, pull_request ]
33
env:
44
CARGO_TERM_COLOR: always
55
RUSTFLAGS: --deny warnings
@@ -11,8 +11,8 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
rust: [stable]
15-
os: [ubuntu-latest, windows-latest, macos-latest]
14+
rust: [ stable ]
15+
os: [ ubuntu-latest, windows-latest, macos-latest ]
1616
steps:
1717
- uses: actions/checkout@v2
1818
- uses: actions-rs/toolchain@v1
@@ -38,7 +38,7 @@ jobs:
3838
strategy:
3939
fail-fast: false
4040
matrix:
41-
rust: [stable]
41+
rust: [ stable ]
4242
steps:
4343
- uses: actions/checkout@v2
4444
- uses: actions-rs/toolchain@v1
@@ -83,21 +83,21 @@ jobs:
8383
name: iOS CI
8484
runs-on: macOS-latest
8585
steps:
86-
- uses: actions/checkout@v2
87-
- name: Install dependencies
88-
run: brew install llvm
89-
- name: Install stable
90-
uses: actions-rs/toolchain@v1
91-
with:
92-
profile: minimal
93-
toolchain: stable
94-
override: true
95-
- name: Add iOS targets
96-
run: rustup target add aarch64-apple-ios x86_64-apple-ios
97-
- name: Build aarch64
98-
run: cargo check --verbose --workspace --target=aarch64-apple-ios --all-features
99-
- name: Build x86_64
100-
run: cargo check --verbose --workspace --target=x86_64-apple-ios --all-features
86+
- uses: actions/checkout@v2
87+
- name: Install dependencies
88+
run: brew install llvm
89+
- name: Install stable
90+
uses: actions-rs/toolchain@v1
91+
with:
92+
profile: minimal
93+
toolchain: stable
94+
override: true
95+
- name: Add iOS targets
96+
run: rustup target add aarch64-apple-ios x86_64-apple-ios
97+
- name: Build aarch64
98+
run: cargo check --verbose --workspace --target=aarch64-apple-ios --all-features
99+
- name: Build x86_64
100+
run: cargo check --verbose --workspace --target=x86_64-apple-ios --all-features
101101

102102
format:
103103
name: Rustfmt CI
@@ -123,7 +123,7 @@ jobs:
123123
- name: Install Dependencies
124124
run: |
125125
sudo apt-get update # Run update first or install might start failing eventually
126-
sudo apt-get install --no-install-recommends -y libasound2-dev libudev-dev pkg-config
126+
sudo apt-get install --no-install-recommends -y libasound2-dev libpulse-dev libudev-dev pkg-config
127127
- run: cargo clippy --version
128128
- run: cargo clippy --workspace --all-targets --all-features -- --deny warnings
129129

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 2.0.0
2+
3+
- PulseAudio support for Linux. See `README.md` for detailed instructions of how to use it.
4+
15
# 1.1.0
26

37
- Migrated to `ndk` crate instead of `aaudio`, which is unmaintained and has build problems (see

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tinyaudio"
3-
version = "1.1.0"
3+
version = "2.0.0"
44
edition = "2021"
55
license = "MIT"
66
description = "TinyAudio is a cross-platform, easy-to-use, low-level, audio output library."

README.md

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# TinyAudio
22

3-
TinyAudio is a cross-platform audio output library. Its main goal to provide unified access to
3+
TinyAudio is a cross-platform audio output library. Its main goal is to provide unified access to
44
a default sound output device of your operating system as easy as possible, covering as many platforms
55
such as PC (Windows, Linux, macOS), Mobile Devices (Android, iOS), and WebAssembly.
66

77
## What this crate can do
88

99
The crate just takes the data you've prepared and sends it to a default operating system's sound output
1010
device. It uses floating-point audio samples and converts them to the closest supported platform-dependent
11-
format automatically. The crate guarantees, that the intermediate data buffer will always be of requested size.
11+
format automatically. The crate guarantees that the intermediate data buffer will always be of requested size.
1212
Use this crate, if you need to play your audio samples as easy as possible.
1313

1414
## What this crate cannot do
@@ -21,29 +21,53 @@ selection, querying of supported formats, input capturing (i.e. from microphone)
2121

2222
| Windows | Linux | macOS | WebAssembly | Android | iOS |
2323
|---------|-------|-------|-------------|---------|-----|
24-
|||||||
24+
||| ||| |
2525

2626
## How it works
2727

2828
The crate internally creates an audio output context and uses a user-defined callback to supply the device
2929
with samples to play. The callback will be called periodically to generate new data; it will be called util
30-
the device instance is "alive". In other words this crate performs the simplest audio streaming.
30+
the device instance is "alive". In other words, this crate performs the simplest audio streaming.
3131

3232
## Android details
3333

34-
This crate uses `AAudio` for audio output on Android platform. `AAudio` is quite new API, which was added in ~2017
34+
This crate uses `AAudio` for audio output on Android platform. `AAudio` is quite new API, which was added in ~2017
3535
(in Android 8.1 Oreo). This means that you have to use `API Level 26+` to get the crate up and running. Also, you must
36-
initialize an audio device only after your application has gained focus (`GainedFocus` event in `android-activity` crate),
37-
otherwise device creation will fail. See `android-examples`
38-
[directory](https://github.com/mrDIMAS/tinyaudio/tree/main/android-examples) for examples.
36+
initialize an audio device only after your application has gained focus (`GainedFocus` event in `android-activity`
37+
crate), otherwise device creation will fail. See `android-examples`
38+
[directory](https://github.com/mrDIMAS/tinyaudio/tree/main/android-examples) for examples.
3939

4040
## WebAssembly details
4141

42-
Most of the web browsers nowadays requires a "confirmation" action from a user (usually a button click or something similar) to
43-
allow a web page to play an audio. This means that you must initialize an audio device _only_ after some action on
44-
a web page that runs your WebAssembly package. In the simplest scenario it could be a simple button with a callback
45-
that initializes an audio device. See `wasm-examples` [directory](https://github.com/mrDIMAS/tinyaudio/tree/main/wasm-examples)
46-
for examples.
42+
Most of the web browsers nowadays require a "confirmation" action from a user (usually a button click or something
43+
similar) to allow a web page to play an audio. This means that you must initialize an audio device _only_ after some
44+
action on
45+
a web page that runs your WebAssembly package. In the simplest scenario, it could be a simple button with a callback
46+
that initializes an audio device. See `wasm-examples`
47+
[directory](https://github.com/mrDIMAS/tinyaudio/tree/main/wasm-examples) for examples.
48+
49+
## Linux details
50+
51+
Do not forget to install the required development libraries, otherwise the crate won't compile:
52+
53+
```shell
54+
sudo apt-get install libasound2-dev libudev-dev pkg-config
55+
```
56+
57+
### Backends
58+
59+
Linux supports two audio "backends" - `ALSA` and `PulseAudio`. By default, this crate uses `ALSA`, but this can be
60+
changed by specifying the `pulse` feature:
61+
62+
```toml
63+
tinyaudio = { version = "2", default-features = false, features = ["pulse"] }
64+
```
65+
66+
`PulseAudio` backend requires `libpulse-dev` to be installed:
67+
68+
```shell
69+
sudo apt-get install libpulse-dev
70+
```
4771

4872
## Examples
4973

@@ -110,7 +134,7 @@ from `cpal` with the example from the above code snippet. The next main differen
110134
that the size of the output buffer will be exactly the same as requested during the creation of audio stream, while
111135
`TinyAudio` strictly guarantees this. Having a buffer of fixed size could be mandatory for some algorithms (such as
112136
HRTF). That last main difference is fixed sample format - it is guaranteed to be `f32`. This simplifies a lot of
113-
algorithms and have almost the same performance as with integer samples on relatively modern hardware.
137+
algorithms and has almost the same performance as with integer samples on relatively modern hardware.
114138

115139
Feature-parity with `cpal` is not a goal for this library, its main goal is to do one particular task, but do it as well
116140
as possible.

0 commit comments

Comments
 (0)