Граф коммитов

1683 Коммитов

Автор SHA1 Сообщение Дата
Matthew Gregan 2650b46c95 aaudio: Fix formatting. 2021-11-23 16:27:09 +13:00
Matthew Gregan 1995336d87 aaudio: Fix build after a4e701ff60.
Fixes #676.
2021-11-23 15:59:55 +13:00
Matthew Gregan df1f3e9d87 build: Bump minimum CMake to 3.14.
This is required since the install() cleanup in
e690fc21bb.
2021-11-23 12:35:11 +13:00
Ka Ho Ng 1099a30078 cubeb_oss: Fix warnings
There were some type mismatch and signed/unsigned comparison warnings
in the initialization path.

Sponsored by:	The FreeBSD Foundation
2021-11-10 19:00:28 +13:00
Ka Ho Ng 8da61ef32d cubeb_oss: clang-formatted 2021-11-10 10:00:47 +13:00
Ka Ho Ng b690782c19 cubeb_oss: changes to buffering logic
The change is to reduce the number of dropped frames when playing
YouTube videos.  The most significant part is to set trigger threshold
to be low enough, such that as long as the audio hardware's DMA engine
moves data the callback is triggered without waiting longer.  Besides
that, unify oss_wait_*fd_for_space() for both directions into a single
function.  Buffer size is also not required to match the other
direction.

Sponsored by:	The FreeBSD Foundation
2021-11-10 10:00:47 +13:00
Andrea Pappacoda e690fc21bb build: minor CMake cleanups
These are minor cleanups that do not affect the behaviour of the script.

In particular, I removed most `DESTINATION` arguments from `install()`,
since they are automatically deduced based on the type of file to be
installed.

In #662 I also added doxygen_add_docs and gtest_discover_tests, but they
require CMake version 3.9 and 3.10 respectively, and I think that the
advantages they provide are not worth dropping support for older versions
2021-11-10 08:53:06 +13:00
Matthew Gregan a4e701ff60 Tidy up `WRAP` definition for dlopen. 2021-11-10 08:49:30 +13:00
Andrea Pappacoda 07c352c65a build: use system speex when possible
Following
https://github.com/mozilla/cubeb/issues/658#issuecomment-955998734, the
speex library is now handled like a normal dependency: cubeb will link
against the system version if available, and fall back to the bundled
one if not.

I've also added a BUNDLE_SPEEX option, so that you can force the use of
the bundled library if needed (e.g. creating a standalone libcubeb on a
system where libspeex is available).

I also had to move the bundled library to a separate folder. As `src` is
always added as an include path, the headers in `src/speex` would
conflict with system headers. And it also clears the relationship
between cubeb and speex. I choose the "subprojects" name to follow the
Meson convention, since CMake does not have one. A bit OT, but if you're
curious you can see their rationale here:
https://mesonbuild.com/Subprojects.html#why-must-all-subprojects-be-inside-a-single-directory

Lastly, I added cubeb_log.cpp to the list of sources of test_resampler,
as I was getting linking errors when building with BUILD_SHARED_LIBS=true

Fixes #658
2021-11-09 09:38:18 +13:00
Andrea Pappacoda 5a64bc898c build: add USE_SANITIZERS option
This is useful to users who can't recursively clone the repo or that
simply want to build the project from the downloadable tarball (like
Linux distributions, for example)
2021-11-09 09:32:05 +13:00
Andrea Pappacoda 5d93d2dc0b build: add LAZY_LOAD_LIBS option and always link with threads
Users can now disable the lazy loading of libraries, and use classic
linkage instead.

Previously, cubeb would link with threads only if using some backends.
This caused linking issues when no backends were active, because cubeb
wasn't linked against pthread or similar, while the library is needed by
src/cubeb_log.cpp, as it uses std::thread.

 #cleanup
2021-11-06 10:07:58 +13:00
Andrea Pappacoda b9e1ddaa7f jack: possibility to disable lazy load of lib 2021-11-04 15:57:33 +13:00
Matthew Gregan 8d8f880366 CI: Update apt package index before install. 2021-11-02 09:27:33 +13:00
Andrea Pappacoda f132be2032 build(cmake): add version and soversion to the built library 2021-11-01 20:31:46 +13:00
Andrea Pappacoda 72f959807d build(cmake): use system GTest when available
This speeds up compilation times and makes downstream packaging easier.
2021-11-01 20:28:31 +13:00
pent0 d512bfa07a android: Fix build error 2021-10-15 14:13:57 +13:00
Matthew Gregan ef5a1ffde9 wasapi: Use stream rate when converting latency to hns.
The caller's requested latency in frames is based on the stream's
requested rate in `stream_params`.  In the default case (when not
overriding latency for BT headsets), use this rate when converting
frames to hns.
2021-10-12 08:09:34 +13:00
Matthew Gregan 6ce95962c8 winmm: clang-format fixes. 2021-08-02 10:43:27 +12:00
mixit e43ae6a884 winmm: fix broken audio when sample count is overflowed
Microsoft wave audio docs say "samples are the preferred time format in which
to represent the current position", but relying on this causes problems on
Windows XP, the only OS cubeb_winmm is used on.

While the wdmaud.sys driver internally tracks a 64-bit position and ensures no
backward movement, the WinMM API limits the position returned from
waveOutGetPosition() to a 32-bit DWORD (this applies equally to XP x64). The
higher 32 bits are chopped off, and to an API consumer the position can appear
to move backward.

In theory, even a 32-bit TIME_SAMPLES position should provide plenty of
playback time for typical use cases before this pseudo wrap-around, e.g:
    (2^32 - 1)/48000 = ~24:51:18 for 48.0 kHz stereo;
    (2^32 - 1)/44100 = ~27:03:12 for 44.1 kHz stereo.
In reality, wdmaud.sys doesn't provide a TIME_SAMPLES position at all, only a
32-bit TIME_BYTES position, from which wdmaud.drv derives TIME_SAMPLES:
    SamplePos = (BytePos * 8) / BitsPerFrame,
    where BitsPerFrame = Channels * BitsPerSample,
Per dom\media\AudioSampleFormat.h, desktop builds always use 32-bit FLOAT32
samples, so the maximum for TIME_SAMPLES should be:
    (2^29 - 1)/48000 = ~03:06:25;
    (2^29 - 1)/44100 = ~03:22:54.
This might still be OK for typical browser usage, but there's also a bug in the
formula above: BytePos * 8 (BytePos << 3) is done on a 32-bit BytePos, without
first casting it to 64 bits, so the highest 3 bits, if set, would get shifted
out, and the maximum possible TIME_SAMPLES drops unacceptably low:
    (2^26 - 1)/48000 = ~00:23:18;
    (2^26 - 1)/44100 = ~00:25:22.

To work around these limitations, we just get the position in TIME_BYTES,
recover the 64-bit value, and do our own conversion to samples.
2021-08-01 00:17:08 +08:00
Matthew Gregan f495dc9825 Add clang-format-check target to CMake and run on CI. 2021-07-28 11:43:17 +12:00
Paul Adenot e6c328cdee Increase delay to really test the pulse backend.
Turns out it was testing the preroll, and with the preroll gone from the
pulse-rust backend in https://github.com/mozilla/cubeb-pulse-rs/pull/69,
this fails on (at least) docker-on-AWS hosts.
2021-07-28 11:22:26 +12:00
Matthew Gregan f59f5ac476 winmm: Fix sorting of mm*.h headers. 2021-07-28 09:31:57 +12:00
Matthew Gregan 28f2d92c3d winmm: Undo some header reordering to fix build. 2021-07-28 09:29:48 +12:00
Chun-Min Chang f4ef497bbe Run .clang-format
Format all the code under `include` and `src` except those files under
`src/speex` with style setting in `.clang-format` file by the following
script:

```sh

FILE_LIST="$(find "include" "src" -not -path "src/speex/*" | grep -E ".*(\.cpp|\.c|\.h|\.hpp|\.hh)$")"

echo "Files found to format:\n---\n$FILE_LIST\n---"

clang-format --verbose -i $FILE_LIST
```
2021-07-28 09:29:48 +12:00
Matthew Gregan e1456788c4 wasapi: Avoid a few copies in `wasapi_find_matching_output_device`.
See BMO #1722073.
2021-07-27 16:11:10 +12:00
Chun-Min Chang f35db2358d
Add a multiple input devices test (#651)
Add a multiple input devices test

Add a test to check if we can open multiple input devices at the same
time. This is a simple check for BMO 1238038.
2021-07-25 10:15:36 +12:00
Matthew Gregan b608f59024 wasapi: Don't set AUDCLNT_STREAMFLAGS_NOPERSIST on IAudioClient (<3) streams. Closes #643. 2021-07-20 09:18:40 +12:00
Paul Adenot b2f60c983d Address review comments. 2021-07-13 13:51:30 +02:00
Paul Adenot 1437a53f8b Grab input frames on input available event and not on output available event 2021-07-13 13:51:30 +02:00
Paul Adenot b6a7dee491 Use long buffers for input 2021-07-13 13:51:30 +02:00
Paul Adenot 1749dc217b Always use default buffer size 2021-07-13 13:51:30 +02:00
Paul Adenot de7cf5ccce Log input and output frames 2021-07-13 13:51:30 +02:00
Ryan Hileman cf7636f17c don't run resampler unless we have enough frames
(fixes #647)
2021-07-06 17:32:01 +12:00
Alexandre Ratchov 275de804d1 sndio: default max_channels to 8 for OUTPUT and 2 for INPUT
cf https://bugzilla.mozilla.org/show_bug.cgi?id=1633769
2021-07-05 08:44:33 +02:00
Matthew Gregan 5ebe69cb3a wasapi: Adjust output stream volume internally rather than using IAudioStreamVolume. 2021-05-25 08:15:25 +12:00
Tomas Maly 701b73c5c8 memory_order_relaxed has changed in c++20 2021-05-06 11:00:45 +12:00
Hans Petter Selasky fa0645fed9 oss: Use the minimum space of both direction in full-duplex path
There is a bug in the OSS cubeb code which use the previous number of
frames as input for the next data-exchange, when full-duplex is
activated. This causes noticable jitter, because the wrong number of
audio frames is exchanged.

The solution is to check both input and output audio DSP buffers and
select the minimum number of audio frames which can be transferred when
full duplex is activated.
2021-04-29 16:07:28 +12:00
Matthew Gregan b729f5750b Point build badge to build action. 2021-03-10 19:24:33 +13:00
Matthew Gregan 03a6f108b0 Remove obsolete CI configs. 2021-03-10 19:14:54 +13:00
Matthew Gregan 48749d62b0 Add build action. 2021-03-10 00:41:02 +13:00
Matthew Gregan 8942382280 Remove cubeb_stream_reset_default_device API. 2021-02-17 22:05:37 +13:00
Matthew Gregan 9beb8ed0c9 wasapi: Don't clear `device_enumerator` in {un,}register_notification_client.
This is a follow up to 5d5fa34e13.
2021-02-17 10:22:19 +13:00
Nicola Orlando 8d53747d4a Fixed option to not automatically connect ports on jack. 2021-01-22 13:44:54 +13:00
Paul Adenot 4a83932cae Remove a static keyword to remove a warning. 2021-01-19 16:05:14 +01:00
Paul Adenot ed90311f10 Fix two warnings in cubeb_wasapi.cpp. 2021-01-19 16:05:14 +01:00
Ka Ho Ng da818aad24 oss: Fix CPU spinning 100% for playback-only stream 2021-01-19 13:28:14 +01:00
Albert Liu 860bf2b315 WASAPI: Fix potentially uninitialized pointer warning 2020-12-09 14:35:48 +13:00
Paul Adenot 85f1cf48df Fix clock reporting on the AAudio backend
On some device (namely, a Samsung Galaxy A30 running Android 10, see
https://bugzilla.mozilla.org/show_bug.cgi?id=1679932), the state is
"STARTED" for quite some time, so we don't go into the `if` statement.
It's best to fallback.

We then need to ensure the monotonicity of this clock (since now we use
two distinct ways of reporting the time, it can end up being
non-monotonic for some calls), using the same technique we use on other
backends.
2020-12-07 08:11:33 +00:00
Albert Liu 70fadbfb4e WASAPI: Adjust PCM format tag based on configured bits per sample 2020-12-07 16:37:42 +13:00
Ka Ho Ng 5c2cf26778 Rework the buffering logic
Reduce the code complexity of non-blocking IO all together. Besides, we
should let recording direction driving the playback direction if we are
working with duplex stream.

- Fix misuse of SNDCTL_DSP_GETOSPACE ioctl on record.fd as well

- Add more comments regarding buffer initialization

- Address comments about which direction driving another direction
2020-12-01 14:05:01 +00:00