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

1617 Коммитов

Автор SHA1 Сообщение Дата
Matthew Gregan 16c2a52152 Add test case for data_callback returning error. 2022-03-30 18:12:01 +13:00
Chun-Min Chang d97fea4c90
Switch device only when the users don't specifiy a particular device (#697)
* Don't change `output_device_id` once it's set

* Fallback to use default device only when not specifying a device

We should only fallback to use default device if the user doesn't
ask to use a particular device.

* Follow default device changes only when using default device explicitly

We should get the default device change notifications only when users
ask to follow the default devices.

* Don't reinit stream when user-selected device is unplugged

If the user specifies a device explicitly, don't switch device for
the stream when the selected device is gone. We should fire an error
callback instead.

* Rename `picked_output_device_id` to `selected_output_device_id`

* Rename fallbackable to allow_fallback

* Correct the comments

* Fix double free problem

unique_ptr can not be initialized from another unique_ptr's raw pointer,
otherwise we will free the pointee twice!

* Add an util to copy wide-char string

* Prefer move

This might be overkilled, but it expresses the intention clearly
2022-03-24 17:53:27 -07:00
Chun-Min Chang bdf2837ae5 Don't reset device if DISABLE_DEVICE_SWITCHING is set
We should not always reset the device when the current device is unplugged.
The device reset or not should follow the
CUBEB_STREAM_PREF_DISABLE_DEVICE_SWITCHING pref.
2022-03-24 10:27:52 +13:00
Chun-Min Chang 2f50db3669 Fire error callback when reinit fails 2022-03-24 10:27:52 +13:00
Chun-Min Chang 4bca265fdc Make sure input latency is larger than zero 2022-03-23 09:21:42 -07:00
Chun-Min Chang 2d64fff58e Return matched device from wasapi_find_bt_handsfree_output_device
Instead of changing `stm->output_device_id` in the `wasapi_find_bt_handsfree_output_device`,
setting it in `setup_wasapi_stream` makes all `stm->output_device_id` updates in the same place
2022-03-23 09:21:42 -07:00
Chun-Min Chang f9927c4de9 Rename function 2022-03-23 09:21:42 -07:00
Chun-Min Chang 8a3d20b61a highlight type cast 2022-03-23 09:21:42 -07:00
Chun-Min Chang 342ff3cd47 Avoid duplicate GetDevicePeriod call
The value returned from `GetDevicePeriod` is the same as `latency_hi` from `wasapi_create_device`
2022-03-23 09:21:42 -07:00
Chun-Min Chang d29291525e Call wasapi_create_device only when necessary
`wasapi_create_device` is called in `setup_wasapi_stream_one_side` to customize input settings. We should call it only when setting up input side.
2022-03-23 09:21:42 -07:00
Chun-Min Chang 016e72ea12 Don't reset input_bluetooth_handsfree when setting output
The duplex stream's `input_bluetooth_handsfree` shouldn't be reset during setting output side
2022-03-23 09:21:42 -07:00
Chun-Min Chang 86210a15ba Group related lines 2022-03-23 09:21:42 -07:00
Chun-Min Chang 1e13faa57b Get default_period only when we need it
`default_period` is used to calculate the input latency. We can avoid calling for output.
2022-03-23 09:21:42 -07:00
Chun-Min Chang 5a2a20c605 Add device selection to cubeb-test
It's a lot easier to develop/debug device-related features/issues if we
can select input or/and output device for the audio stream in cubeb-test
2022-03-22 14:15:59 +13:00
Chun-Min Chang 70d18726e4 Update INSTALL.md
The repo is moved from kinetiknz/cubeb.git to mozilla/cubeb.git
2022-03-22 14:08:13 +13:00
Matthew Gregan 6e5b9fe38c build: Return to building bundled speexdsp as object library. 2022-03-09 15:10:52 +13:00
Matthew Gregan a5eabe6a19 wasapi: Fix formatting. 2022-03-09 14:59:29 +13:00
Matthew Gregan 662ed79f60 jack: Fix formatting. 2022-03-09 14:18:29 +13:00
Matthew Gregan fd96dcc270 jack: Build fix for resampler API change. 2022-03-09 13:56:14 +13:00
Paul Adenot 5f12ba23fc Add a parameter to cubeb_resampler_create to enable reclocking 2022-03-08 14:49:50 +01:00
Matthew Gregan ad99eeb273 owned_critical_section: Replace CRITICAL_SECTION with SRWLOCK on Windows. 2022-03-03 09:55:59 +13:00
Matthew Gregan 11c0214f40 wasapi: Protect access to cubeb context members. 2022-03-03 09:55:24 +13:00
Matthew Gregan 3a04ed2946 wasapi: Avoid configuring output side of resampler when using dummy_output.
Possible fix for test_loopback assertion failure.
2022-02-28 23:38:46 +13:00
Matthew Gregan 2fb20f7b9c Assert device collection callbacks were unregistered before cubeb_destroy is called. 2022-02-28 23:38:46 +13:00
Andrea Pappacoda f79e0cf9f0 build: use libbsd when using OSS and glibc
Some systems offer OSS v4 but do not have BSD-only functions like
strlcpy, used in cubeb_oss.c. An example is Debian GNU/kFreeBSD, that
uses a FreeBSD kernel with GNU userspace utilities, like glibc.

With this patch cubeb will be able to build on these systems thanks to
the help of libbsd, that privides most libc functions that you would
expect on BSD.
2022-02-02 12:40:57 +13:00
Hans Petter Selasky 7d62476a5a cubeb_oss: Force at maximum 32ms service intervals.
Also when the latency is specified to be very big.
This might be a bug in some upper layer, although I see
other cubeb audio drivers doing the same.

This "fixes" audio sync with youtube videos.
2022-02-02 08:22:23 +13:00
Matthew Gregan 9edd150d9d waspi: Simplify default devices query and avoid nullptr deref. 2022-01-11 08:31:50 +13:00
Matthew Gregan 9e29d728b0 Build fixes for MinGW - follow up to 3d598eff57. 2022-01-08 10:44:20 +13:00
Matthew Gregan 3d598eff57 wasapi: Speed up enumerate_devices by caching default device IDs for each flow/role instead of requerying for every wasapi_create_device.
Locally (on a machine with ~120 devices), this reduces a single
enumerate_devices call from ~1100ms to ~250ms.
2022-01-07 14:34:59 +13:00
Hans Petter Selasky 773f16b7ea cubeb_oss: Fix recording buffer size computation.
When computing the maximum buffer size the "fragstotal" field should be
used instead of "fragments" field. For recording the "fragments" field
usually returns zero, so then no recorded audio may be received.

While at it remove the not used "nfr" and "nfrags" fields from the
oss_stream structure and use "bufframes" instead.
2021-12-08 11:09:25 +13:00
Paul Adenot 9937d0bb57 Fix build on MinGW
Original downstream patch by Tom Ritter <tom@mozilla.com>.
2021-12-08 08:47:42 +13:00
Matthew Gregan 75d9d125ee mixer: Replace std::result_of with decltype.
Fixes issue #677.
2021-12-04 09:45:14 +13:00
Hans Petter Selasky 5b0b7f6bf7 cubeb_oss: Fix for buffer overrun.
The hardware buffer is typically bigger than the software buffer.
Make sure to properly limit the available buffer size values
obtained from the DSP device.

While at it ensure to retry-polling in case either recording or
playback cannot move any data.
2021-11-29 12:36:19 +13:00
Matthew Gregan dcc5cb5c15 CI: Add Android (API level 26) builds. 2021-11-23 16:54:12 +13:00
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