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

226 Коммитов

Автор SHA1 Сообщение Дата
Paul Adenot 1ba9237364 Skip a couple more tests when a backend can't use audio input 2023-04-26 14:28:46 +02:00
Paul Adenot 88900545d4 Only run test_overload.cpp when using the WASAPI backend 2023-04-26 14:28:46 +02:00
Paul Adenot 0e7f41d6ef Don't run test_loopback and test_duplex on backends that can't open audio input 2023-04-26 14:28:46 +02:00
Paul Adenot 2e0fe89106 Prevent running test that make use of audio input streams on backends that don't implement it 2023-04-26 14:28:46 +02:00
Paul Adenot 3ecf0c8f83 Sync back BMO#1825328
https://bugzilla.mozilla.org/show_bug.cgi?id=1825328 landed in Firefox
without going through upstream. It's necessary to build in an
environment where gtests are all compiled in the same executable.

Original patch by serge-sans-paille <sguelton@mozilla.com>.
2023-04-20 14:07:44 +02:00
Paul Adenot 304ef97245 Add a triple_buffer class that allows publishing data in a wait-free manner from a real-time thread to another thread.
It's largely inspired from the crate cubeb-coreaudio-rs uses, but ported to
C++.
2022-12-14 18:33:27 +01:00
Paul Adenot 6a6113b6ff Add a test to stress test the asynchronous logging system 2022-12-12 12:03:47 +01:00
Paul Adenot cfc5692bf7 Account for the fact that some OSes have longer callback duration and async logging is batched 2022-12-05 17:27:36 +01:00
Paul Adenot b8765e132d Inline values for stream params in test_logging.cpp, undef defines in test to avoid breaking unified builds when building tests in Firefox. 2022-12-02 15:40:20 +01:00
Paul Adenot 7f5589a431 Allow dynamic enabling and disabling of the log, add tests for the logging system.
Also clear out the memory used by the async logger when it's shut down.

This relies on the fact that enabling and disabling logging is performed
on the same thread, but I think this is a reasonnable thing to do. We
could assert it though.
2022-12-02 14:17:18 +01:00
Matthew Gregan 16c2a52152 Add test case for data_callback returning error. 2022-03-30 18:12:01 +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 2fb20f7b9c Assert device collection callbacks were unregistered before cubeb_destroy is called. 2022-02-28 23:38:46 +13: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
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 8942382280 Remove cubeb_stream_reset_default_device API. 2021-02-17 22:05:37 +13:00
Brendan Early 2e842a01f7 Add method to change stream name 2020-10-07 11:27:54 +13:00
Paul Adenot 660864ede5 Address review comments 2020-09-21 19:36:43 +02:00
Paul Adenot 9820ea03bf Add a test case for WASAPI reconfigure event 2020-09-21 19:36:43 +02:00
Alex Chronopoulos 575bd44389 resampler: avoid overflow on uint arithmetics 2020-06-30 22:57:45 +12:00
Cameron Cawley 616d773441 tests: Fix crash when device enumeration is not supported 2020-04-26 13:50:49 +12:00
Chun-Min Chang 4dbacaefb0 Remove test for registering device changed callback twice
audiounit-rust backend will return an error instead of hitting an
assertion when registering a callback by calling
`cubeb_stream_register_device_changed_callback` without unregistering
the registered callback. It's not possible to run a death test in gtest
for the Rust API[1]

[1] https://users.rust-lang.org/t/how-to-write-a-death-test-in-gtest-for-rust-apis/23575
2020-03-31 19:49:47 +13:00
Alex Chronopoulos d4b23d1e9b fix a few warnings (#571) 2020-01-22 12:00:49 +01:00
Alex Chronopoulos 0adc5ea965 resampler: avoid integer signed comparison mismatch (#570) 2020-01-22 12:00:23 +01:00
Alex Chronopoulos 6cdf2fd22b
resampler: handle explicitly the case that input frames are less than output frames (#565)
* resampler: handle explicitly the case that input frames are less than output frames

* Review comments

* resampler: stop expecting input number of frames equal to output

* resampler: report correctly the input frames used

* resampler: add unit tests for passthrough_resampler::fill
2020-01-21 16:08:09 +02:00
Matthew Gregan be3005530f test_ring_buffer: Use `yield` instead of `sleep_for(10us)`. (#569)
See issue #567 for details.
2020-01-21 11:38:06 +01:00
Jan Beich f33f05a139 test: unbreak on non-GTEST_HAS_DEATH_TEST platforms
test/test_device_changed_callback.cpp:79:3: error: use of undeclared identifier 'ASSERT_DEATH'
  ASSERT_DEATH(
  ^
2019-09-06 08:56:54 +12:00
Paul Adenot 8c3e32bd24 Remove panning API from cubeb
This is best done by the host application, and had very little
implementation anyways.
2019-08-22 10:11:25 +12:00
Chun-Min Chang 03eb237c3b Fix tests warnings (#512)
* Using unsigned long-long modifier in fprintf

* Remove unnecessary lambda captures

* Align naming conventions among the functions

* Replace llu by PRIu64

* Define __STDC_FORMAT_MACROS

* Using default capture
2019-06-11 12:22:33 +12:00
Chun-Min Chang f8a6768684 Make sure data_callback and state_callback are not null (#496)
* Make sure data_callback and state_callback are not null

* Check callbacks are valid in cubeb.c

* Initialize stream with non-null callbacks
2019-03-30 10:17:03 +13:00
Chun-Min Chang 8c3a32e9f4 Make sure no active device changed callback when registering a new one 2019-01-06 16:52:29 -05:00
Chun-Min Chang 42e931de37 Add tests for cubeb_stream_register_device_changed_callback 2019-01-06 16:52:29 -05:00
Chun-Min Chang 008732ef72 trivial test to check if cubeb_stream_get_latency is callable (for Rust implementation) 2018-12-17 15:25:45 -05:00
Chun-Min Chang 5f025918a8 Remove misleading comments 2018-12-17 15:25:45 -05:00
Alex Chronopoulos 5066cfcf42
tests: check correctly the audio buffer values range (BMO 1484541). (#461)
* tests: check correctly the audio buffer values range (BMO 1484541).

* tests: create a comfortable way to enable logs in tests

* duplex test: check audio range correctly and change the input channel to stereo to avoid AD mixer (BMO 1484541).

* test_duplex: Revert back input channel to mono
2018-10-18 16:57:01 +02:00
Chun-Min Chang 4b7442ee48 audiounit: Reduce duplicate code in audiounit_stream_get_current_device (#453)
* Add a test for cubeb_stream_get_current_device() and cubeb_stream_device_destroy()

* Reduce duplicates in audiounit_stream_get_current_device()

The audiounit_stream_get_current_device() will set the default device's name for input and output by the following steps:
1. Get default device's data, whose type is uint32
2. Convert the uint32 data into a string
3. Set the string into cubeb_device's name

Hence we can split it into functions to do the above steps:
i. audiounit_get_default_device_data(...)
  Do the step 1
ii. allocate_and_convert_uint32_into_string(...)
  Do the step 2 and 3. It will allocate memory for a string and put the converted string right there. (If we don't allocate and then set the values into the memory at the same time, we need to find a way to check the memory's boundary.)

They are called by a function named audiounit_get_default_device_name(...), with cubeb_device_type parameter to set the device name of input or output. And audiounit_get_default_device_name(...) will be used in audiounit_stream_get_current_device().

* Replace allocate_and_convert_uint32_into_string(...) by convert_uint32_into_string(...)

1. Rename allocate_and_convert_uint32_into_string(...) to convert_uint32_into_string(...)
2. Return a unique_ptr<char[]> from convert_uint32_into_string(...) pointing to an allocated memory

* Hard-coding the convertion from uint32 into string

This change is to make sure the conversion only ever needs to handle 4 bytes.

* Add more information to log when calling audiounit_stream_get_current_device(...)

We add a log with error message when we cannot get datasource data from the devices. However, we don't return an error code in this case since it's quite common when we try getting that data from USB devices. We will convert the datasource data into a string. If there is no data, the string is empty. Instead of logging when we cannot get the datasource data, it's better to log that the converted name is empty. It'll give more meaning (Users are more likely confused about what the empty datasource means.).

* Rename audiounit_get_default_device_data() to audiounit_get_default_device_datasource()

We should use an explicit name for this function since the same device will return different datasources. For example, the default input device on macbook pro will return "imic" if it uses the default internal microphone or "emic" when it uses an external microphone plugged in audio jack.

TODO: it's better to rename audiounit_stream_get_current_device to audiounit_stream_get_current_device_source. The reason is same as above.
2018-07-19 09:36:53 +12:00
Matthew Gregan 57b4d6b454 Initialize cubeb_stream_params.prefs field in more tests to avoid random failures. 2018-03-27 17:48:59 +13:00
Matthew Gregan 13d9e2874c wasapi: Remove COM initialization and require caller to complete.
This addresses the thread local COM initialization lifetime problem
discussed in issue #416 by moving the responsibility for COM
initialization from within cubeb to the caller.
2018-03-21 09:29:30 +13:00
Jean-Yves Avenard 789eaaa3b0 Multi-channels support for windows/mac/linux (#426)
* Add QUAD and QUAD_LFE layouts.

* Remove dual mono layout.

It makes no sense to have a case for those as the data structure
used (a bitmask) do not allow to represent this channel layout (a
channel can only be present once). As such it was a non-functional
layout

* Fix up cubeb_pulse compilation using C++ keyword.

* Remove the concept of preferred layout.

Channel layout is derived by the content being played. The concept of
preferred layout is meaningless. Either we have a layout defined, or
we don't. There's no in-between.

So we remove it.

* Remove CHANNEL_MONO concept.

* Add cubeb_sample_size convenience method.

* Rework cubeb_mixer.

This completely replace the existing remixer which had serious limitations:
1- Had no memory bound checks
2- Could only downmix 5.1 and 7.1 to stereo.

This mixer allows to convert from any sane layout to any other and work directly on interleaved samples.

This cubeb_mixer doesn't have an API compatible with the previous one.

This commit is non-fonctional, and was split for ease of review.

* Fix remixing on mac, windows and pulse backend.

* Make cubeb_mixer creation infallible.

Rather than ignore nonsensical layouts, we attempt to play it according to the stream channels count instead. The audio data will be played as-is, dropping the extra channels or inserting silence where needed.

* User proper sample size when calculating offsets.

Should the user data be of a different type to what the AudioUnit output is set to, we would have written outside the end of our allocated buffer.

* Fix input mixing and clarify frames vs samples terminology

* If a layout is unknown or invalid, always treat it as plain stereo or mono.
2018-03-19 14:57:07 +01:00
Bryce Van Dyk c88a484e1a Relax some of the checks in the loopback test to avoid false positives.
- For the silent loopback test we check that we don't get any sound above an
epsilon. The value of this epsilon has been increased to accommodate a wider
range of systems.
- The delay on all tests has been increased to allow for more time to capture
looped samples. The original 150ms delay was sufficient on the machine I tested
with, however, I've seen the tests fail due to not having enough looped input.
2018-03-13 08:59:20 +13:00
Bryce Van Dyk b64824fb5d Add test to verify the behaviour a different return values for data callbacks. 2018-03-01 13:32:24 +01:00
Paul Adenot 1f4b4d33b1
Fix deadlock and device collection changed callback issue on OSX (#401)
* Add an automated test to ensure creating a duplex stream with a device collection changed callback works.

* Fix a deadlock

When creating an aggregate device, and a device collection change callback was
installed, a deadlock occured, because the device collection change listener was
being called synchronously.

Use GCD to send a task to a serial queue, and carefuly unlock the mutex in
audiounit_stream_destroy to not deadlock on the queue.

* Don't call the device collection change callback when creating cubeb's own aggregate device.

* Remove std:: prefix, there is a using namespace std; now.

* Address review comments

* Address even more comments.
2018-01-26 14:15:41 +01:00
Bryce Van Dyk 4c18a84a45 Explicitly init stream_params.prefs in tests.
Also update the example code comment in cubbeb.h to reflect new param usage.
2018-01-23 08:50:28 +13:00
Bryce Van Dyk 09863992b9 Update loopback test to check that output is not passed in data callback 2018-01-23 08:50:28 +13:00
Bryce Van Dyk 9e28c42670 Respond to review comments.
- Fix indentation in header
- Adjust spacing for casts and pointer + ref declarations
- Adjust comments in test about locking after stop
- Simplify default device selection when loopback is involved
2018-01-23 08:50:28 +13:00
Bryce Van Dyk 41221a275c Add loopback test where devices are explicitly selected via device id. 2018-01-23 08:50:28 +13:00
Bryce Van Dyk 701178cf16 Add test for loopback when playback is silent 2018-01-23 08:50:28 +13:00
Bryce Van Dyk 2bb275d31f Add further test for separate loopback and playback streams.
Add a test to verify loopback works when loopback and playback streams are
created separately.
2018-01-23 08:50:28 +13:00
Bryce Van Dyk 3f5966cdcc Add loopback test file and test for duplex stream with loopback.
Add a test file for loopback tests and add to build script. This file is
currently configured to be Windows only in build scripts, as the WASAPI backend
is currently the only backend supporting the new loopback interface.

Add a test for duplex streams using the default output device and a loopback
from the same device.
2018-01-23 08:50:28 +13:00
Paul Adenot ed3ded8db6
Don't enumerate private aggregate devices in cubeb_audiounit.cpp (#400) 2018-01-18 13:22:23 +01:00