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

1565 Коммитов

Автор SHA1 Сообщение Дата
Paul Adenot 0d2c470c24 Prefer the AAudio backend over the OpenSL ES backend
The last issues have been fixed, and it's now better (and also uses an
API that isn't deprecated).
2023-01-05 16:27:56 +01:00
Matthew Gregan 1736e4aed3 wasapi: Drop context lock before deleting context. 2023-01-05 14:21:58 +01:00
Paul Adenot dbc60333f5 Fix warnings 2022-12-14 18:33:27 +01:00
Paul Adenot ffa3a43ef6 Generalize latency reporting to make it work in input-only and duplex modes 2022-12-14 18:33:27 +01:00
Paul Adenot 36ac2a31d8 Rewrite aaudio_stream_get_position with the accurate timing info provided by AAudio
A/V sync is now perfect regardless of the output device (bluetooth,
wired, speaker), and client side interpolation provides high accuracy
regardless of the buffer-size that the users decides on.
2022-12-14 18:33:27 +01:00
Paul Adenot ab242f6935 Compute and publish timing info, including position and latency, from the real-time audio callback (output-only)
This is essentially the same technique we're using on macOS in
cubeb-coreaudio-rs, ported for AAudio, and extended to input.
2022-12-14 18:33:27 +01:00
Paul Adenot 052e2a8001 Store the sample-rate on the stream struct 2022-12-14 18:33:27 +01:00
Paul Adenot cfcd4f3c42 Allow directly logging from cubeb_aaudio.cpp to logcat 2022-12-14 18:33:27 +01: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 e4da2d47c3 Don't include timeapi.h because it doesn't exist in MinGW, include mmsystem.h that declares timeGetTime instead. 2022-12-13 15:10:22 +01:00
Paul Adenot 274d8b56bc Fix warnings in cubeb_wasapi.cpp.
This fixes #733.
2022-12-13 15:09:21 +01:00
Paul Adenot f4b583c045 Include timeapi.h in cubeb_wasapi.cpp manually to unbreak the build when WIN32_LEAN_AND_MEAN is defined. 2022-12-12 16:45:21 +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 8eedc12369 Allow the asynchronous logging system to safely delete its storage. 2022-12-12 12:03:47 +01:00
Matthew Gregan 51728e55cd wasapi: Avoid reconfiguring default output stream spuriously. 2022-12-08 09:24:26 +13:00
Matthew Gregan eb8c4ff060 wasapi: Fix default device change filtering logic. 2022-12-08 09:24:26 +13:00
Matthew Gregan 784f4d7e3f wasapi: Typo fix. 2022-12-08 09:24:26 +13:00
Matthew Gregan 93d0b1247f cubeb-test: Add a newline after each log message. 2022-12-08 09:24:26 +13:00
Matthew Gregan 8d7365a9d5 wasapi: Release WASAPI resources in inverse order to acquisition.
This shouldn't have any behavioural effect as the WASAPI resources are
reference counted internally.
2022-12-08 09:24:26 +13: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
Ty Lamontagne 27d2a102b0 Properly compare against current log level 2022-10-19 09:53:31 +13:00
Matthew Gregan 6b474ee404 Clarify `cubeb_log_get_{log,callback}()` declaration. 2022-09-29 17:06:04 -10:00
Paul Adenot 93d1fa3fcc Register threads explicitely created by cubeb
This covers some callbacks, but not all of them: the APIs that don't
require explicitely creating the thread will see their thread registered
separately.
2022-09-22 23:52:54 +02:00
Paul Adenot e9abb07824 Make the log callback and level atomic
It's useful to be able to enable logging dynamically while the program
is running, and this can now be done on any thread.

Various threads are logging (directly or asynchronously via the ring
buffer), it's better to have those atomic.

Both values are always checked before logging, and both must be non-null
to log.
2022-09-22 23:36:04 +02:00
Paul Adenot bc0450628e Simplify initialization of opensl backend 2022-09-22 08:32:32 +12:00
Matthew Gregan 28c8aa4a9c
Null check `context` in cubeb_enumerate_devices. 2022-09-21 19:27:36 +12:00
Alexandre Bouvier 06aa271e5b cmake: fix install rules
* don't install cmake test binaries
* fix variable names in Doxyfile.in
* install doc files
2022-09-21 18:47:36 +12:00
ivan-matveev 4783607ecc Remove comments after #endif to fix clang-format errors. 2022-09-06 14:38:56 +02:00
ivan-matveev d93c82fdd2 Add #ifndef around dlclose() to allow build with "LAZY_LOAD_LIBS=OFF" cmake argument. 2022-09-06 14:38:56 +02:00
Paul Adenot dc511c6b35 Add logging statement when input audio dropping happens 2022-07-21 18:34:39 +02:00
Paul Adenot 015f3c632a Add a header to be able to use a frame profiler in cubeb
The purpose of this header is to be swapped by cubeb users to use any
number of frame profiler (tracy/Gecko Profiler/trace_event.h, etc.).
2022-07-21 16:53:19 +02:00
Paul Adenot 190652b71f
Don't print the file name and \n twice when logging asynchronously (#715)
Not the prettiest but it does the job. Thanks to @ashleyz we don't really care about checking the log level here, it's checked ahead of time, which is nice because we don't want to carry it in the async log payload.
2022-07-19 08:53:29 -07:00
az c2243e891b
Check log level in asynchronous logging macros before printing (#714)
Added `ALOG` macro and updated `ALOGV` for use with asynchronous logging. Both macros should now verify log level.
2022-07-18 09:45:39 -07:00
japm48 c644de9681 Update build instructions 2022-07-11 18:14:51 +12:00
Ashley 6f79fd7c0d
Merge pull request #712 from kinetiknz/fix_decl
Clarify `cubeb_async_log_reset_threads` declaration.
2022-06-29 16:56:34 -07:00
Matthew Gregan c4f7e5604c Clarify `cubeb_async_log_reset_threads` declaration. 2022-06-30 11:50:51 +12:00
- 744d638ba7 fix threading errors
rearrange the cross-thread load to be the second load; being a little late may cause it to be lucky! (this probably doesn't matter)
2022-06-23 14:21:36 +12:00
aeiouaeiouaeiouaeiouaeiouaeiou 3dd0c44a39 CI: update actions to v3, use macos-11 environment and bump Android API target 2022-06-21 11:16:17 +12:00
Kevin Yin 3f1e82c255 Update INSTALL.md
correct typo
2022-05-31 11:41:42 +02:00
Matthew Gregan 708f52cccf wasapi: Fail stream setup instead of asserting if device latency unavailable.
Follow up to https://github.com/mozilla/cubeb/pull/695.  Before that PR,
we would fail setup when GetDevicePeriod failed.  This restores that
behaviour.
2022-04-13 17:02:09 +02:00
Matthew Gregan 62d4926af1 wasapi: Stop audio clients when render thread exits. 2022-04-13 16:57:00 +02:00
Matthew Gregan e91fa6b3f2 wasapi: Enumerate only active devices when matching BT output device.
Potentially significantly shrinks the list of devices to search when
matching BT output device with specified BT input device.  On my local
machine, this shrinks the list from 25 to 7, and reduces the initial
enumerate time from ~67ms to ~32ms (and a subsequent call from ~14ms to
~12ms).
2022-04-11 20:35:16 +12:00
Matthew Gregan 1079b1f926 wasapi: Avoid enumerating DEVICE_STATE_NOTPRESENT devices.
Devices in this state are not visible in the Sound Control Panel or
other typical places in the OS audio UI, so there's little point in
including them in cubeb's device list.

On my test machine, this reduces the number of devices enumerated from
118 to 25 - reducing the cost of an initial cubeb_enumerate_devices from
~215ms to ~67ms (and a subsequent call from ~22ms to ~14ms).
2022-04-11 20:35:16 +12:00
Matthew Gregan 7864397ce1 wasapi: Rework emergency_bailout mechanism.
- Rather than "leak" an atomic bool to the stuck render thread, we
  instead "leak" the entire stream and leave the render thread to clean
  up.
- render thread now checks `handle_emergency_bailout()`, which frees the
  stream and exits the render thread in bailout condititions.
- Removed `thread_ready_event`, since it's no longer needed.
2022-04-11 19:28:11 +12:00
Matthew Gregan 2d84b222ef
Update README.md
Fix wiki link.
2022-04-06 11:37:38 +12:00
Matthew Gregan b62d61bc66 audiounit,pulse,wasapi: Handle data_callback errors and signal to user via state_callback. 2022-03-30 18:12:01 +13:00
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