58 Commits

Author SHA1 Message Date
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
tomaka
91adc3e380 Docs and style improvements (#174)
* Improve the crate root documentation

* Add entry in CHANGELOG

* Run rustfmt on the code

* More improvements to documentation
2017-10-23 16:41:38 +02:00
tomaka
87949d859b Add SupportedFormat (#168) 2017-10-20 21:18:40 +02:00
tomaka
c28407b26d Fix warnings and reduce scope of libc (#166) 2017-10-19 12:44:14 +02:00
tomaka
6ae01f437c RFC: Rework the API [WIP] (#165)
* Rework the API to not use futures anymore

* Add some comments

* Update the MacOS backend

* Restore the null implementation

* Add an emscripten backend

* Remove erroneously added feature

* Fix to_f32 formula

* [WIP] Alsa backend

* Alsa backend compiling

* Working ALSA backend

* Fix tests

* Move WASAPI endpoint to endpoint module

* Fix WASAPI warnings

* Rework the WASAPI backend

* Check overflows for voice ID

* Add comments and minor fixes to WASAPI backend

* Add a changelog
2017-10-18 20:24:05 +02:00
tomaka
4b019243c2 Rename the methods of the backend as well (#164) 2017-10-12 11:54:09 +02:00
tomaka
2028d5907f Run rustfmt on the code (#162) 2017-10-11 13:24:49 +02:00
Johannes Lundberg
e86ffce712 Fixes for *BSDs
Replace linux-only eventfd() with pipe() to enable use on *BSDs for alsa.
Add FreeBSD to supported OSes.
2017-07-13 15:59:40 +02:00
Nikita Chashchinskii
0f8babe8bd Pass period instead of buffer to snd_pcm_sw_params_set_avail_min
* Also bump version from 0.4.2 to 0.4.3
2017-02-04 08:20:21 +03:00
jwestfall
7c03219451 alsa: set sw_params_set_avail_min based on get_params buffer size
snd_pcm_sw_params_set_avail_min was being hardcoded to 4096, which
seems to be problematic for lower sample rates.  This update sets
the value to the buffer size as supplied by snd_pcm_get_params(),
which is what alsa own sample code does.

This should fix https://github.com/tomaka/cpal/issues/142
2017-01-23 16:10:44 -08:00
thiolliere
25bb025a9a arc not necessary 2016-10-02 14:24:30 +02:00
thiolliere
5c86eec4f3 line not necessary 2016-10-02 14:21:33 +02:00
thiolliere
1b0c9f2c54 syntax: space after comma 2016-10-02 14:19:58 +02:00
thiolliere
f822631bc4 impl play and pause for ALSA
snd_pcm_pause could have been used but not all hardware implement it, so
I propose not to use it.

In this implementation:

there are two kind of scheduling: wait for resume signal and wait for
pcm to be available

if the stream is paused then it return notready and wait for resume

the event loop is different as it manages descriptors corresponding to
voices according to the nature of the scheduling.

there is still a FIXME: in voice.play the is signal is send even if
the event loop wasn't waiting for resume.
It doesn't seem to create any issue. But it happens when you write
voice.pause();voice.play();
2016-10-02 13:29:01 +02:00
thiolliere
e031025abe update to futures 0.1.1: alsa wasapi 2016-10-01 00:44:22 +02:00
Pierre Krieger
0c915cac8f Use a max buffer size in order to avoid problems 2016-08-03 10:31:02 +02:00
Pierre Krieger
7c587853ad Make it work on Linux 2016-08-03 10:17:23 +02:00
Pierre Krieger
752676c818 Be more relaxed with c_void 2016-04-25 13:33:12 +02:00
Mathijs van de Nes
f3f194293a Fix underflow detection for alsa
The old method always returned _RUNNING on some machines.
This new method seems to produce the expected behaviour.

Note: -32 is probably -EPIPE, but the appropriate constant was not
available at this time.
2016-02-28 17:01:13 +01:00
Nicolas Koch
606bcf9fa6 Fix underflow bug on linux 2016-01-28 21:27:09 +01:00
psych0d0g
7c3aab71a2 Add some sane error messages 2016-01-15 21:16:34 +01:00
tomaka
b049e80ca3 Merge pull request #84 from tomaka/alsa-channels
Use correct ALSA channels
2015-12-15 17:49:42 +01:00
Mathijs van de Nes
951b7f5e65 Catch another 'device not found' error code 2015-10-13 12:22:07 +02:00
Pierre Krieger
55dbfa881e Use correct ALSA channels 2015-09-27 13:27:00 +02:00
Pierre Krieger
c93ffcff6c Add Voice::get_period() 2015-09-27 13:00:17 +02:00
Pierre Krieger
6bd28231ec Make sure that all writes succeed 2015-09-22 21:01:26 +02:00
Pierre Krieger
5fc346b34b Make the ALSA implementation more robust by recovering from underruns 2015-09-22 20:20:17 +02:00
Pierre Krieger
44e9dce43f Add Voice::get_pending_samples 2015-09-22 17:59:36 +02:00
Pierre Krieger
5fa41538a6 Various ALSA fixes 2015-09-22 15:46:56 +02:00
tomaka
0a13991f86 Merge pull request #75 from tomaka/alsa-format
Use the correct format in ALSA
2015-09-22 15:23:28 +02:00
Pierre Krieger
46151e09cc Use the correct format in ALSA 2015-09-22 15:20:11 +02:00
Pierre Krieger
a2b8b4f4a7 Use the correct device name when enumerating formats 2015-09-22 15:12:41 +02:00
Pierre Krieger
73906885f9 Fix bug and filter out devices that are not "Output" 2015-09-22 15:04:32 +02:00
tomaka
debb6c957c Merge pull request #73 from tomaka/example-enumerate
Example enumerate
2015-09-22 14:49:31 +02:00
Pierre Krieger
ec48453b6f Add endpoint::get_name() and an enumerate example 2015-09-22 14:46:27 +02:00
tomaka
d4c7d91fd7 Merge pull request #63 from tomaka/alsa-formats
Correctly enumerate supported formats on ALSA
2015-09-22 13:56:22 +02:00
Pierre Krieger
8d21f5ff25 Store the format in the public Voice struct 2015-09-22 13:34:06 +02:00
tomaka
d3e610a614 Merge pull request #64 from tomaka/underflowed
Add an underflow() method to Voice
2015-09-22 10:02:41 +02:00
Pierre Krieger
75f828b04f Add #[inline] attributes 2015-09-11 10:55:29 +02:00
Pierre Krieger
3dd7a8abe7 Add UnknownBufferType::len() 2015-09-10 21:24:41 +02:00
Pierre Krieger
c5e2cdd3c5 Add an underflow() method to Voice 2015-09-10 21:03:40 +02:00
Pierre Krieger
c5f51183f4 Correctly enumerate supported formats on ALSA 2015-09-10 19:48:39 +02:00
Pierre Krieger
541af2f7f2 Fix compilation on ALSA 2015-09-10 12:43:37 +02:00
Pierre Krieger
3db17889a4 Make ALSA compile again 2015-09-01 17:15:49 +02:00
Pierre Krieger
c71d9d74b3 Merge branch 'sample-format' of https://github.com/kmcallister/cpal into fix-signed 2015-07-22 14:28:13 +02:00
Pierre Krieger
b813aa168a Calls to a single ALSA channel are not thread safe 2015-06-24 15:17:52 +02:00
Pierre Krieger
07b2009dae Update for Rustc 1.0.0 beta 2015-04-04 09:22:23 +02:00
Pierre Krieger
93073f1ff7 Update for change in rustc and winapi 2015-03-30 11:19:03 +02:00
Pierre Krieger
a6c1b14d66 Rustup 2015-03-26 10:03:40 +01:00