Commit Graph

597 Commits

Author SHA1 Message Date
mitchmindtree d0cafd68bf
Merge pull request #276 from AustinJ235/master
Release 0.9.0
2019-06-07 15:39:52 +02:00
mitchmindtree 7f7e50c96a
Merge pull request #211 from mitchmindtree/feedback_example
Add an example that demonstrates feeding input directly to output with some latency
2019-06-06 18:09:09 +02:00
Austin Johnson 49b2c42443 add changelog entries for #248 #254 & #269; update version to 0.9.0 2019-06-06 10:29:52 -05:00
mitchmindtree 48e1a96e60
Merge pull request #244 from azyobuzin/WasapiBufferEmpty
Assertion failed in Windows
2019-06-06 15:24:24 +02:00
mitchmindtree ba4a29ae6c
Merge pull request #275 from desttinghim/invalid-params-fix
Don't panic when setting hardware params in alsa
2019-06-06 15:22:42 +02:00
Austin Johnson 78adc983f6 update hound & lazy_static; release 0.8.2 2019-06-06 00:49:49 -05:00
Louis Pearson e7c086d0af Return error from set_hw_params_from_format instead of crashing 2019-06-04 12:48:11 -06:00
mitchmindtree b82ca1e348
Merge pull request #235 from ArtemGr/master
Switching the headset on and off
2019-06-04 20:15:26 +02:00
mitchmindtree 72fd027f57
Merge pull request #269 from ishitatsuyuki/better-buffer
Better buffer handling
2019-06-04 19:51:45 +02:00
mitchmindtree 7861dd84da
Merge pull request #248 from RoflCopter24/master
Added error handling for unknown ALSA device errors
2019-05-30 23:56:43 +02:00
Tatsuyuki Ishi 4d3fe57fe3 Improved buffer management
- ALSA backend: reuse the buffers
- Make `InputBuffer` and `OutputBuffer` types just a wrapper of slice
  * Buffer is now submitted at the end of callback
2019-05-30 17:45:16 +09:00
mitchmindtree 0354548426
Merge pull request #267 from ishitatsuyuki/254-segfault
Fix #254, logic error in frame/sample size
2019-04-29 22:21:48 +10:00
Tatsuyuki Ishi af88cd87e2 Fix #254, logic error in frame/sample size 2019-04-29 20:33:03 +09:00
mitchmindtree 0b6df67085
Merge pull request #265 from simonrepp/master
Minor textual corrections in crate documentation intro
2019-04-23 03:09:10 +10:00
Simon Repp c2c7089d1a
Minor textual corrections in crate documentation intro 2019-04-22 13:55:42 +02:00
Chris Morgan 2679ea845f impl Debug for Device (#253)
The internal alsa, null and emscripten Device implementations already
implemented Debug; but the coreaudio and wasapi ones, and therefore
also the wrapper, did not.

I decided to eschew the `Device(…)` wrapping in the outer layer
(hence a custom implementation rather than `#[derive(Debug)]`),
because `Device(Device)`, `Device(Device { … })` and so forth all
look better without the extra `Device(…)` wrapping.

On the wasapi and coreaudio implementations I put both the pointer and
name. Name because it’s useful, pointer because on Windows at least
I believe duplicated names are possible. (e.g. two monitors that include
monitors, of the same type; I haven’t strictly confirmed this, because I
killed those off harshly on my machine and don’t want to reinstate
them.)

I do not have access to a macOS device to confirm that the coreaudio
implementation is sane, but I think it is.
2019-03-22 21:27:17 +01:00
Florian Vick 5cb45bfd7e
Added error handling for unknown ALSA device errors (#1)
Instead of taking the easy way out and killing the whole program by panicking, device enumeration and stream creation will now report the error variant 'Unknown'
2018-11-06 21:01:03 +01:00
azyobuzin 8a002b7077 Fix failing the assertion when HRESULT is AUDCLNT_S_BUFFER_EMPTY 2018-10-12 12:12:05 +09:00
Ben Boeckel c2d606176a readme: mention system dependencies (#240)
Fixes #229.
2018-09-17 15:57:51 +02:00
Andre-Philippe Paquet 1a3a8956e4 WASPI - Fix stream start after destroy (#241)
* waspi - Fix stream start after destroy

* Fix stream name
2018-09-12 13:13:13 +02:00
Artem 71a5a43e33 Come to think of it, changing comparison logic unexpectedly is a bad idea. 2018-07-14 16:22:56 +02:00
Artem e959c770e2 Compare the Windows devices by ID, allowing the user to detect if the default device has been changed. 2018-07-14 15:42:48 +02:00
Artem 513071b60a Don't panic when an audio device is disconnected. 2018-07-14 15:41:30 +02:00
Artem 95caa88cfa Fix the PauseStream handler to flip the `playing` bit. (#233)
* Fix the PauseStream handler to flip the `playing` bit.

* Changelog entry on the wasapi stream resuming fix.

* Moved the changelog entry to the Unreleased.
2018-07-10 16:43:52 +02:00
thiolliere 77a4ee6145 impl default output format for emscripten (#234) 2018-07-10 15:04:00 +02:00
Jacob Kiesel 568d4097e7 Upgrade lazy_static (#232) 2018-07-03 21:07:08 +02:00
Nitori 77ce5eba06 Implement Display and Error for DefaultFormatError (#230) 2018-06-30 11:51:24 +02:00
frazar 20fffb26fb Add missing braking changes introduced into 0.7 (#219) 2018-04-18 15:18:10 +02:00
mitchmindtree a2fe9386af [coreaudio] Fix handling of non-default sample rates for input streams (#214)
* [coreaudio] Fix handling of non-default sample rates for input streams

Currently when building an input stream the coreaudio backend only
specifies the sample rate for the audio unit, however coreaudio requires
that the audio unit sample rate matches the device sample rate.

This changes the `build_input_stream` behaviour to:

1. Check if the device sample rate differs from the desired one.
2. If so, check that there are no existing audio units using the device
at the current sample rate. If there are, panic with a message
explaining why.
3. Otherwise, change the device sample rate.
4. Continue building the input stream audio unit as normal.

Closes #213.

* Update CHANGELOG for coreaudio input stream sample rate fix

* Publish 0.8.1 for coreaudio input stream sample rate fix
2018-04-01 13:25:46 +02:00
mitchmindtree c20978fc01 Add an example that demonstrates feeding input directly to output with some latency 2018-02-17 15:33:00 +11:00
mitchmindtree 06a0f0a3ab Publish 0.8 for new Device and Stream API. Update CHANGELOG. (#209) 2018-02-15 08:47:43 +01:00
mitchmindtree c38bbb26e4 Update to a more general Device and Stream API. Add support for input streams (E.g. microphone). Add default format methods. (#201)
* Update to a more general Device and Stream API

This update prepares for adding input stream support by removing the
`Endpoint` type (which only supports output streams) in favour of a more
general `Device` type which may support any number of input or output
streams. Previously discussed at #117.

The name `Voice` has been replaced with the more ubiquitous name
`Stream`. See #118 for justification.

Also introduces a new `StreamData` which is now passed to the
`EventLoop::run` callback rather than the `UnknownTypeBuffer`.
`StreamData` allows for passing either `Input` data to be read, or
`Output` data to be written.

The `beep.rs` example has been updated for the API changes.

None of the backends have been updated for this API change yet. Backends
will be updated in the following commits.

Closes #117.
Closes #118.

* Update ALSA backend for new `Device` and `Stream` API.

* Update wasapi backend for new `Device` and `Stream` API.

* Update enumerate.rs example for new `Device` and `Stream` API.

* Update coreaudio backend for new `Device` and `Stream` API.

* Fix lib doc tests for Device and Stream API update

* Update emscripten backend for new `Device` and `Stream` API.

* Update null backend for new `Device` and `Stream` API.

* Merge match exprs in beep.rs example

* Add Input variant along with UnknownTypeInputBuffer and InputBuffer

UnknownTypeBuffer and Buffer have been renamed to
UnknownTypeOutputBuffer and OutputBuffer respectively.

No backends have yet been updated for this name change or the addition
of the InputBuffer.

* Update null backend for introduction of InputBuffer

* Update emscripten backend for introduction of InputBuffer

* Make InputBuffer inner field an option to call finish in drop

* Update alsa backend for introduction of InputBuffer

* Update wasapi backend for introduction of InputBuffer

* Update coreaudio backend for introduction of InputBuffer

* Update enumerate.rs example to provide more detail about devices

The enumerate.rs example now also displays:

- Supported input stream formats.
- Default input stream format.
- Default output stream format.

This should also be useful for testing the progress of #201.

* Add `record_wav.rs` example for demonstrating input streams

Records a ~3 second WAV file to `$CARGO_MANIFEST_DIR/recorded.wav` using
the default input device and default input format.

Uses hound 3.0 to create and write to the WAV file.

This should also be useful for testing the input stream implementations
for each different cpal backend.

* Implement input stream support for coreaudio backend

This implements the following for the coreaudio backend:

- Device::supported_input_formats
- Device::default_input_format
- Device::default_output_format
- EventLoop::build_input_stream

The `enumerate.rs` and `record_wav.rs` examples now work successfully on
macos.

* Add `SupportedFormat::cmp_default_heuristics` method

This adds a comparison function which compares two `SupportedFormat`s in
terms of their priority of use as a default stream format.

Some backends (such as ALSA) do not provide a default stream format for
their audio devices. In these cases, CPAL attempts to decide on a
reasonable default format for the user. To do this we use the "greatest"
of all supported stream formats when compared with this method.

* Implement input stream support for ALSA backend

This implements the following for the ALSA backend:

- Device::supported_input_formats
- Device::default_input_format
- Device::default_output_format
- EventLoop::build_input_stream

Note that ALSA itself does not give default stream formats for its
devices. Thus the newly added `SupportedFormat::cmp_default_heuristics`
method is used to determine the most suitable, supported stream format
to use as the default.

The `enumerate.rs` and `record_wav.rs` examples now work successfully on
my linux machine.

* Implement input stream support for wasapi backend

This implements the following for the wasapi backend:

- Device::supported_input_formats
- Device::default_input_format
- Device::default_output_format
- EventLoop::build_input_stream

Note that wasapi does not enumerate supported input/output stream
formats for its devices. Instead, we query the `IsFormatSupported`
method for supported formats ourselves.

* Fix some warnings in the alsa backend

* Update CHANGELOG for introduction of input streams and related items

* Update README to show latest features supported by CPAL

* Simplify beep example using Device::default_output_format

* Remove old commented code from wasapi/stream.rs
2018-02-12 14:10:24 +01:00
mitchmindtree b47e46a4ac Update winapi version from 0.2 to 0.3 (#202)
Adds only the necessary cargo features to reduce compile time and reduce
the chance of linking errors occurring for unused libraries (e.g.
d3d12.dll fails to link on my win10 VM).

I thought I'd try and land this before before working on the wasapi
backend implementation for #201.

Tested both beep.rs and enumerate.rs and they work fine with the update.
2018-02-07 17:36:59 +01:00
Pierre Krieger 3ff9e6fe65
Publish 0.7 (#200) 2018-02-04 13:03:03 +01:00
mitchmindtree fcc75f4566 Rename `SamplesRate` to `SampleRate` and `ChannelsCount` to `ChannelCount` (#199)
* Rename SamplesRate to SampleRate and samples_rate to sample_rate

* Rename ChannelsCount to ChannelCount

* Update CHANGELOG for SamplesRate and ChannelsCount renaming
2018-02-04 13:02:16 +01:00
mitchmindtree f2728f6bdf Remove unused `ChannelPosition` API (update all backends and examples accordingly) (#198)
* Remove ChannelPosition API

This removes the ChannelPosition API from the lib root and updates the
ALSA backend and examples accordingly. The other backends have not yet
been updated.

Related discussion at #187.

* Update windows backend to removal of ChannelPosition API

The windows backend now assumes the channel position order is equal to
the channel position mask order. E.g. channel 0 will always be front
left, channel 1 will always be front right, etc.

Compiled and ran both examples successfully.

* Update coreaudio backend to removal of ChannelPosition API

Compiled and ran both examples successfully.

* Update emscriptem backend for removal of ChannelPosition API

* Update CHANGELOG for ChannelPosition removal
2018-02-04 10:38:06 +01:00
mitchmindtree 6bf65f589d
Merge pull request #196 from mitchmindtree/device_enumeration
[coreaudio] Implement Endpoint and Format Enumeration
2018-02-04 15:10:39 +11:00
mitchmindtree d482d646a0 Link only to necessary coreaudio frameworks 2018-02-03 14:14:15 +11:00
mitchmindtree 3952c44c63 [macos] Implement Endpoint and Format Enumeration
Based on #195.

Also implements proper handling of the given `Endpoint` in the
macos implementation of the `build_voice` method.

Updates to the latest coreaudio-sys and coreaudio-rs which include the
additional necessary frameworks.

Also adds a line that prints the name of the default device in the
`enumeration.rs` example.

Updates the CHANGELOG for this PR.

Closes #194.
Related to #180.

Related external issues:

- RustAudio/coreaudio-sys#4
- RustAudio/coreaudio-rs#57
2018-01-28 12:40:25 +11:00
mitchmindtree 091798ac5a
Merge pull request #195 from mitchmindtree/macos_format
Implement format handling in `build_voice` macos backend
2018-01-28 00:36:33 +11:00
mitchmindtree 45f2f1b371 Update changelog 2018-01-24 21:34:18 +11:00
mitchmindtree dcb7dea028 Implement format handling in `build_voice` macos backend 2018-01-24 21:33:00 +11:00
thiolliere e8d3ffe277 remmove old doc (#191) 2017-12-14 21:20:07 +01:00
mitchmindtree d09532c36e Publish v0.6.0 (#190)
There does not seem to be any major API breakage, however the emscripten
and macos backends have been pretty heavily refactored so I thought it
best to bump to 0.6 (rather than 0.5.2) just in case there is any subtle
behavioural breakage. Happy to change this to 0.5.2 though if someone
can confirm there will be no downstream breakage.
2017-12-11 09:31:22 +01:00
Andriy Symonovych 37016e612c Fix macos build (#186)
* fix compile error

* fix missing function error

* fix undefined behavior issue

* require callback to be `Send`
2017-12-06 12:13:36 +01:00
Zachary Hamm 5105427529 Fix coreaudio build (#189)
The last commit to coreaudio/mod.rs added a call to convert_error, but
that function was removed earlier. Remove the call to fix the build.
2017-12-05 08:47:08 +01:00
Eidolon e9856c07ed [coreaudio] Remove intermediate buffer (#182)
* [coreaudio] Remove intermediate buffer

Fixes #181

* [coreaudio] Create voice id after setting format
2017-11-03 10:51:02 +01:00
Eidolon 77cd690b00 [coreaudio] Simplify error conversion (#183) 2017-11-03 10:50:02 +01:00
mitchmindtree 019b27350f Implement `pause` and `play` for ALSA backend (#176)
* Implement `pause` and `play` for ALSA backend

This commit also ensures that the Voice is initially paused when
returned to remain consistent with the rest of the CPAL backends.

Related to #175.

* Remove ineffective pause from end of build_voice method

* ALSA - Change `is_paused` flag from `AtomicBool` to `bool`

* Add pause and play ALSA addition to CHANGELOG
2017-11-02 10:30:15 +01:00
tomaka 743e4e3526
Fix #177 (#179) 2017-11-01 10:15:17 +01:00