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

1617 Коммитов

Автор SHA1 Сообщение Дата
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
Paul Adenot df5fe422b7 Check various lengths before comparing the group id with the handsfree tag 2020-11-16 09:19:25 +00:00
Paul Adenot b887693072 Fix typo in bluetooth handsfree tag 2020-11-16 09:19:25 +00:00
Paul Adenot 4e851e9960 Null check input and output stream param before dereferencing 2020-11-03 16:36:58 +01:00
Paul Adenot 48e349ef99 Format src/cubeb_aaudio.cpp with clang-format 2020-11-02 16:08:27 +00:00
Paul Adenot c81283271f Add an initial clang-format file 2020-11-02 16:08:27 +00:00
Paul Adenot a851a3ea8d Cleanup comments, add misc. logs. 2020-11-02 15:37:29 +00:00
Paul Adenot a0469241db Port over the input and output policies for voice content from OpenSL to AAudio, unmodified. 2020-11-02 15:37:29 +00:00
Paul Adenot 97ef18c8e8 Implement cubeb_get_preferred_sample_rate for the new AAudio backend. 2020-11-02 15:37:29 +00:00
Paul Adenot 9d421b9935 Implement cubeb_get_min_latency for the new AAudio backend. 2020-11-02 15:37:29 +00:00
Paul Adenot 77956e5267 Implement cubeb_stream_get_input_latency for the new AAudio backend. 2020-11-02 15:37:29 +00:00
Paul Adenot 777d9082a0 Implement cubeb_stream_get_latency for the new AAudio backend. 2020-11-02 15:37:29 +00:00
Paul Adenot 81fbf06c9e Remove context and stream name related code, this is not used on Android. 2020-11-02 15:37:29 +00:00
Paul Adenot 3be35e9e61 Repair opensl output latency, integer division issue. 2020-11-02 15:37:29 +00:00
Paul Adenot e36697bb76 Use C++ style unused argument instead of C-style. 2020-11-02 15:37:29 +00:00
Paul Adenot de1a1f8439 Use sizeof instead of numeric litterals. 2020-11-02 15:37:29 +00:00
Paul Adenot 3fe4d25c04 Make the low-latency/powersave policy choice dynamic, based on latency.
This adds a new file that shares the value between the two non-obsolete
android backend.
2020-11-02 15:37:29 +00:00