Commit Graph

528 Commits

Author SHA1 Message Date
Chun-Min Chang
661d951af8 Bug 1530715 - P31: Merge render_input into audiounit_input_callback. r=padenot
1. If AudioUnitRender return kAudioUnitErr_CannotDoInCurrentContext
within a input-only stream, the input-only stream will keep feed silence
data into the buffer instead of reporting the error. With this change,
the error will be rendered as the returned value of the data callback to
the underlying CoreAudio framework.

2. By merging the render_input into audiounit_input_callback and adjust
the timing to call reinit_async, now the reinit_async is called at the
line that is out of the main logic for feeding buffer data. In the scope
of the main logic, there will be a critical section created by locking a
Rust mutex within AudioUnitStream in the later mutex replacement.
Without moving the reinit_async, which borrows AudioUnitStream as a
mutable, out of the critical section, there will be a borrowing-twice
issue.

Differential Revision: https://phabricator.services.mozilla.com/D34064

--HG--
extra : moz-landing-system : lando
2019-07-09 19:57:05 +00:00
Chun-Min Chang
7c005b7f90 Bug 1530715 - P30: Some clean-up in audiounit_output_callback. r=padenot
- Remove unnecessary mutabilities
- Remove duplicate API calls

Differential Revision: https://phabricator.services.mozilla.com/D34063

--HG--
extra : moz-landing-system : lando
2019-07-09 19:57:05 +00:00
Chun-Min Chang
c47370ecc1 Bug 1530715 - P29: Move mixer to a struct within a mutex. r=padenot
The mixer of the stream will be created, reinitialized, used or
destroyed on different threads, so its operations should be in the
critical sections. We do create critical sections by our custom mutex.
However, this custom mutex will be gradually replaced by the standard
Rust mutex in the following patches.

To replace the custom mutex, we put the mixer to the struct wrapped by a
Rust mutex and do all the mixer operations in the critical section
created by this struct. At the end when the custom mutex is removed,
those operations are still in critical sections.

Calling notify_state_changed needs to borrow AudioUnitStream as a
mutuable. To avoid the borrowing-twice issue, the notify_state_changed
calling is moved out the scope of the critical section created in the
output data callback.

Differential Revision: https://phabricator.services.mozilla.com/D34062

--HG--
extra : moz-landing-system : lando
2019-07-09 19:57:04 +00:00
Chun-Min Chang
c7c35b3626 Bug 1530715 - P28: Create a Mixer module. r=padenot
Using an Mixer struct to operate all the mixing APIs is a way to make
the code clearer. In addition, we can avoid calling mix function by
borrowing the AudioUnitStream as a mutable. It will help to avoid
potential borrowing-twice issues in the later mutex replacement.

Differential Revision: https://phabricator.services.mozilla.com/D34061

--HG--
extra : moz-landing-system : lando
2019-07-09 19:57:04 +00:00
Chun-Min Chang
aa39343ea4 Bug 1530715 - P27: Move resampler to a struct within a mutex. r=padenot
The resampler of the stream will be created, reinitialized, used or
destroyed on different threads, so its operations should be in the
critical sections. We do create critical sections by our custom mutex.
However, this custom mutex will be gradually replaced by the standard
mutex in the following patches. To replace the custom mutex, we put the
resampler to the struct wrapped by a Rust mutex and do all the resampler
operations in the critical section created by this struct. At the end
when the custom mutex is removed, those operations are still in critical
sections.

Differential Revision: https://phabricator.services.mozilla.com/D34060

--HG--
extra : moz-landing-system : lando
2019-07-09 19:57:04 +00:00
Chun-Min Chang
96aee8cca3 Bug 1530715 - P26: Create a Resampler module. r=padenot
Using a resample struct to operate all its related operations will make
the code clearer.

Differential Revision: https://phabricator.services.mozilla.com/D34059

--HG--
extra : moz-landing-system : lando
2019-07-09 19:57:04 +00:00
Chun-Min Chang
3481c83d49 Bug 1530715 - P25: Move aggregate_device to a struct within a mutex. r=padenot
The aggregate device of the stream may be created, reinitialized, or
destroyed on different threads, so its operations should be in the
critical sections. We do create critical sections by our custom mutex.
However, this custom mutex will be gradually replaced by the standard
Rust mutex in the following patches.

To replace the custom mutex, we create a struct wrapped by a Rust mutex
and create critical sections by this Rust mutex to do operations for
aggregate-device settings. At the end, not only aggregate-device
calls, but also other operations that needs to be locked will be
operated in the critical section created by this struct.

This is the beginning patch to replace the custom mutex in
AudioUnitStream.

Differential Revision: https://phabricator.services.mozilla.com/D34058

--HG--
extra : moz-landing-system : lando
2019-07-09 19:57:03 +00:00
Chun-Min Chang
7eed9af4a2 Bug 1530715 - P24: Create an AggregateDevice module. r=padenot
Using an aggregate-device struct to operate all the settings for the
aggregate device is a way to make the code clearer. In addition, we can
avoid calling some aggregate-device APIs by borrowing the
AudioUnitStream as a mutable. It will help to avoid potential
borrowing-twice issues in the later mutex replacement.

Differential Revision: https://phabricator.services.mozilla.com/D34057

--HG--
extra : moz-landing-system : lando
2019-07-09 19:57:03 +00:00
Chun-Min Chang
9cbaedd2cd Bug 1530715 - P23: Avoid poisoning the mutex for device_changed_callback. r=padenot
The mutex is considered poisoned whenever a thread panics while holding
the mutex. Registering a second device changed callback without unregistering
the original callback makes the thread panics while holding the mutex
for the device_changed_callback. This mutex will be used when device
property changed callback. If the mutex is poisoned then a device
property is changed, we will get another panic when firing the callback
because of using a poisoned mutex.

Differential Revision: https://phabricator.services.mozilla.com/D34056

--HG--
extra : moz-landing-system : lando
2019-07-09 19:57:03 +00:00
Chun-Min Chang
b7048aa82e Bug 1530715 - P22: Replace device_changed_callback_lock by standard Rust mutex. r=padenot
The registration, unregistration, and notification for the device
property changed is done in a critical section created by locking our
own custom mutex. To replace our own custom mutex by standard Rust
mutex, the critical section should be created by locking a standard Rust
mutex. This can be done by simply merging device_changed_callback and
device_changed_callback_lock into a Rust mutex variable.

Differential Revision: https://phabricator.services.mozilla.com/D34055

--HG--
extra : moz-landing-system : lando
2019-07-09 19:57:03 +00:00
Chun-Min Chang
b7dc2b7dae Bug 1530715 - P21: Replace set_buffer_size by set_buffer_size_sync and its friends. r=padenot
By moving out this API from the AudioUnitStream, we can avoid calling
it by borrowing the AudioUnitStream variable as a mutable. This will
help to avoid the potential borrowing-twice issues in the later mutex
replacement

In addition, the change applies an idiomatic way to wait for the system
callback event without consuming CPU time.

Differential Revision: https://phabricator.services.mozilla.com/D34054

--HG--
extra : moz-landing-system : lando
2019-07-09 19:57:02 +00:00
Chun-Min Chang
9b1165df4e Bug 1530715 - P20: Replace init_input_linear_buffer by create_auto_array. r=padenot
This change provides two benefits:

1. Setting variable by the Result value directly is rustier than setting
the variable by a mutual reference with a dummy Result that only
contains an error.

2. By moving out this API from the AudioUnitStream, we can avoid calling
it by borrowing the AudioUnitStream variable as a mutable. This will
help to avoid the potential borrowing-twice issues in the later mutex
replacement.

Differential Revision: https://phabricator.services.mozilla.com/D34053

--HG--
extra : moz-landing-system : lando
2019-07-09 19:57:02 +00:00
Chun-Min Chang
144d1b88b0 Bug 1530715 - P19: Replace audio_stream_desc_init by create_stream_description. r=padenot
Setting variable by the Result value directly is rustier than setting
the variable by a mutual reference with a dummy Result that only
contains an error.

Differential Revision: https://phabricator.services.mozilla.com/D34052

--HG--
extra : moz-landing-system : lando
2019-07-09 19:57:02 +00:00
Chun-Min Chang
0bcfbedb5a Bug 1530715 - P18: Replace audiounit_create_unit by create_audiounit and its friends. r=padenot
Setting variable by the Result value directly is rustier than setting
the variable by a mutual reference with a dummy Result that only
contains an error.

Differential Revision: https://phabricator.services.mozilla.com/D34051

--HG--
extra : moz-landing-system : lando
2019-07-09 19:57:02 +00:00
Chun-Min Chang
ef2cf3df24 Bug 1530715 - P17: Move get_volume out of AudioUnitStream. r=padenot
By moving get_volume out of AudioUnitStream, we can avoid unnecessary
borrowing from the AudioUnitStream variable. This change will make the
get_volume become symmetric to the set_volume.

Differential Revision: https://phabricator.services.mozilla.com/D34050

--HG--
extra : moz-landing-system : lando
2019-07-09 19:57:01 +00:00
Chun-Min Chang
64146dd614 Bug 1530715 - P16: Implement an internal set_volume API. r=padenot
By narrowing down the parameters that set_volume API needs, we can avoid
the unnecessary mutual borrowing from the AudioUnitStream variable. This
will help to avoid potential borrowing-twice issues in the later mutex
replacement.

Differential Revision: https://phabricator.services.mozilla.com/D34049

--HG--
extra : moz-landing-system : lando
2019-07-09 19:57:01 +00:00
Chun-Min Chang
2f4e0d4bf9 Bug 1530715 - P15: Replace set_device_info by create_device_info. r=padenot
Setting variable by the Result value directly is rustier than setting
the variable by a mutual reference with a dummy Result that only
contains the error.

Differential Revision: https://phabricator.services.mozilla.com/D34048

--HG--
extra : moz-landing-system : lando
2019-07-09 19:57:01 +00:00
Chun-Min Chang
9ec338122e Bug 1530715 - P14: Wrap state-callback code into a function. r=padenot
The code will be clearer if we can wrap the state-callback that notify
the state changed into a function. It will hide some details about
rendering the callback to C interface.

Differential Revision: https://phabricator.services.mozilla.com/D34047

--HG--
extra : moz-landing-system : lando
2019-07-09 19:57:01 +00:00
Chun-Min Chang
13a12b00be Bug 1530715 - P13: Remove unnecessary parameter in reinit. r=padenot
When the stream is re-initialized, the input unit and/or output unit
should be reset if they are currently used, no matter what scope (input
or output or in-output) the parameter requests.

Differential Revision: https://phabricator.services.mozilla.com/D34046

--HG--
extra : moz-landing-system : lando
2019-07-09 19:57:00 +00:00
Chun-Min Chang
81de625fb9 Bug 1530715 - P12: Remove the unused variable in AudioUnitStream. r=padenot
Removing expected_output_callbacks_in_a_row since it is not being used.

Differential Revision: https://phabricator.services.mozilla.com/D34045

--HG--
extra : moz-landing-system : lando
2019-07-10 03:56:44 +00:00
Chun-Min Chang
82addf1eae Bug 1530715 - P11: Remove OwnedCriticalSection in cubeb context. r=padenot
The OwnedCriticalSection is a custom mutex directly translated from the
C code of the Cubeb library. Replacing the custom mutex by standard Rust
mutex make the code fit in the Rust design better and make debugging the
code easier. The variables protected by the custom mutex in the cubeb
context is moved to the Rust standard mutex in previous patches. The
custom mutex in the cubeb context is able to be removed since we no
longer rely on it.

Differential Revision: https://phabricator.services.mozilla.com/D29983

--HG--
extra : moz-landing-system : lando
2019-07-10 03:56:44 +00:00
Chun-Min Chang
c77792bb27 Bug 1530715 - P10: Avoid poisoning the mutex for device-collection-changed. r=padenot
The mutex is considered poisoned whenever a thread panics while holding
the mutex. Registering a second device-collection-changed callback
without unregistering the original callback makes the thread panics while
holding the mutex for the device-collection-changed variables. This
mutex will be used when the cubeb context is dropped. If the mutex is
poisoned, we will get another panic when dropping the cubeb context
because of using a poisoned mutex.

Differential Revision: https://phabricator.services.mozilla.com/D29982

--HG--
extra : moz-landing-system : lando
2019-07-09 19:57:00 +00:00
Chun-Min Chang
77ce888b12 Bug 1530715 - P9: Move device-collection-changed variables to a struct within a mutex. r=padenot
The registration, unregistration, and notification for the device
collection changed is done in a critical section created by locking our
own custom mutex. To replace our own custom mutex by standard Rust
mutex, the critical section should be created by locking a standard Rust
mutex. This can be done by simply putting those varaibles for
device-collection-changed to a struct within a Rust mutex.

Differential Revision: https://phabricator.services.mozilla.com/D29981

--HG--
extra : moz-landing-system : lando
2019-07-09 19:56:59 +00:00
Chun-Min Chang
d454c7e9f3 Bug 1530715 - P8: Always use global latency frames to initialize the cubeb stream. r=padenot
The global latency frames in the cubeb context is the latency frames of
the first cubeb stream created in that cubeb context. The reason is
because latency frames cannot be changed when there is an active stream
operating in parallel. To make sure the latency won't be changed, the
latency frames of the streams after the first stream will be overwritten
by the global latency frames. Since we always use the global latency
frames, instead of overwritting latency frames of the later streams, we
could, we could simply initialize all the streams with the global
latency frames.

Differential Revision: https://phabricator.services.mozilla.com/D29980

--HG--
extra : moz-landing-system : lando
2019-07-09 19:56:59 +00:00
Chun-Min Chang
2a05858542 Bug 1530715 - P7: Move active_streams to a struct within a mutex. r=padenot
The counting of the active streams in a cubeb context is calculated in a
critical section created by locking our own custom mutex. To replace our
own mutex by standard Rust mutex, the critical section calculating the
active streams should be created by locking a standard Rust mutex. This
can be done by simply putting the active_streams to a struct with a Rust
mutex.

Differential Revision: https://phabricator.services.mozilla.com/D29979

--HG--
extra : moz-landing-system : lando
2019-07-09 19:56:59 +00:00
Chun-Min Chang
dca41b81af Bug 1530715 - P6: Fully initialize the aggregate device before using it. r=padenot
In the current implementation, we assume the aggregate device is created
immediately after calling the system API to create it, and we also
assume the sub-devices of the aggregate device are added immediately
upon we call the system API to set the sub-devices. Unfortunately, these
assumptions are not correct. Occasionally these settings are not
executed immediately, especially when they are not called on the main
thread (e.g., we may create an aggregate device off the main thread when
switching devices). Using the listeners monitoring the devices-changed
events can make sure those settings are done.

Differential Revision: https://phabricator.services.mozilla.com/D29978

--HG--
extra : moz-landing-system : lando
2019-07-10 03:53:57 +00:00
Chun-Min Chang
d6be3795fa Bug 1530715 - P5: Remove the unused code when clamping latency frames. r=padenot
The clamp_latency function is only called when the cubeb context has one
stream only. In that case, clamp_latency will clamp the stream latency
frames in a safe range and then return the clamped value directly. The
code in clamp_latency for more than one streams doesn't be executed
since clamp_latency isn't called when there are more than one streams
within cubeb context. It's easier to read the code if the unused code is
removed.

Differential Revision: https://phabricator.services.mozilla.com/D29011

--HG--
extra : moz-landing-system : lando
2019-07-10 03:55:38 +00:00
Chun-Min Chang
94a049f7b4 Bug 1530715 - P3: Build cubeb-coreaudio-rs in libcubeb. r=kinetik
Differential Revision: https://phabricator.services.mozilla.com/D23432

--HG--
extra : moz-landing-system : lando
2019-07-09 19:56:58 +00:00
Chun-Min Chang
e141b351c3 Bug 1530715 - P2: Import oxidized cubeb_audiounit.cpp. r=padenot
Differential Revision: https://phabricator.services.mozilla.com/D23431

--HG--
extra : moz-landing-system : lando
2019-07-09 19:56:58 +00:00
Chun-Min Chang
682720b94d Bug 1530715 - P1: Create an empty cubeb-coreaudio-rs crate in libcubeb. r=kinetik
To import cubeb-coreaudio-rs crate later, creating a dummy folder in
advance in libcubeb. It should be the mirrow of cubeb-coreaudio-rs crate
on github. The information of cubeb-coreaudio-rs is in README_MOZILLA.

Differential Revision: https://phabricator.services.mozilla.com/D23429

--HG--
extra : moz-landing-system : lando
2019-07-09 19:56:57 +00:00
Chun-Min Chang
c145f8316d Bug 1561945 - P2: Update cubeb from upstream to 98a1c8e. r=achronop
Pick commits:
98a1c8e - Enable Windows build on Travis. (#514)
02bcf9c -  cubeb_sun: Fixes to support high latency playback, and illumos build fix. (#513)
9f39687 - sunaudio (NetBSD/illumos) backend (#510)
03eb237 - Fix tests warnings (#512)
acbed7d - Add audiounit-rust backend (#511)
421010c - Update Travis builds: clang 3.6 -> 3.8, g++ 4.8 -> 5.x, XCode 6.4 -> 9.4. (#509)
3643750 - wasapi: return unique_ptr normally, without std::move (#443)
9ea8137 - Switch Travis builds to Ubuntu Xenial (16.04) to pick up a newer MinGW. (#508)

Differential Revision: https://phabricator.services.mozilla.com/D36212

--HG--
extra : moz-landing-system : lando
2019-06-30 23:36:38 +00:00
Chun-Min Chang
dc65a77a5b Bug 1561945 - P1: Copy sunaudio backend to cubeb. r=achronop
Differential Revision: https://phabricator.services.mozilla.com/D36215

--HG--
extra : moz-landing-system : lando
2019-06-27 16:59:00 +00:00
Matthew Gregan
49e90dfa54 Bug 1552342 - Update libcubeb to b9e2c50. r=padenot 2019-05-17 09:27:50 +12:00
Alex Chronopoulos
ec3b159539 Bug 1546872 - Update cubeb from upstream to 64aa80f. r=padenot
Pick commit:
64aa80f - wasapi: notify when a device is disabled. BMO 1546872
2019-04-25 20:14:32 +03:00
Alex Chronopoulos
f0d62457c5 Bug 1545279 - Update cubeb from upstream to 3570749. r=padenot
Pick commits:
3570749 - wasapi: tie monitor lifetime with notification client lifetime. BMO 1545279 (#505)
162625a - test: add option to get the posotion of a stream (#504)

Differential Revision: https://phabricator.services.mozilla.com/D28796

--HG--
extra : moz-landing-system : lando
2019-04-25 09:22:35 +00:00
Paul Adenot
c9069544bd Bug 1531833 - Update libcubeb to 241e3c (and rebase an in-tree patch). r=kinetik
This has been reviewed by snorp, kinetik, achronop, in bug 1531833, and the
rollup has been rubberstamped by achronop in
https://github.com/kinetiknz/cubeb/pull/501.

Differential Revision: https://phabricator.services.mozilla.com/D26937

--HG--
extra : moz-landing-system : lando
2019-04-16 15:44:47 +00:00
Oana Pop Rus
212a653d81 Backed out 6 changesets (bug 1531833) for geckoview failures on PermissionDelegateTest.media CLOSED TREE
Backed out changeset f90ad6bb8ebd (bug 1531833)
Backed out changeset 465570a54b46 (bug 1531833)
Backed out changeset e725253ee976 (bug 1531833)
Backed out changeset 74ad8e7a722b (bug 1531833)
Backed out changeset b1268e5f7023 (bug 1531833)
Backed out changeset e3ec78b2db1f (bug 1531833)

--HG--
extra : amend_source : 81aa19c352e72cac2369e014d19ec5a896538b21
2019-04-11 21:16:55 +03:00
Paul Adenot
b774a54cc4 Bug 1531833 - Update libcubeb to c0a717 (and rebase an in-tree patch). r=kinetik
This has been reviewed by snorp, kinetik, achronop, in bug 1531833, and the
rollup has been rubberstamped by achronop in
https://github.com/kinetiknz/cubeb/pull/501.

Differential Revision: https://phabricator.services.mozilla.com/D26937

--HG--
extra : moz-landing-system : lando
2019-04-11 09:19:39 +00:00
Geoff Brown
8d88b9a596 Bug 1318091 - Disable failing android gtests; r=bc
Disable gtests observed to fail on Android. Some of these are simple build
failures and failures due to file permissions or paths, while other failures
are more obscure.
Once Android gtests are running on mozilla-central, I will file follow-up
bugs inviting teams to investigate the failures and re-enable Android gtests
that are important to them.

Differential Revision: https://phabricator.services.mozilla.com/D26606

--HG--
extra : moz-landing-system : lando
2019-04-08 20:58:21 +00:00
Alex Chronopoulos
925ad97bb4 Bug 1541101 - Update cubeb from upstream to 66d9c48. r=kinetik 2019-04-03 12:50:40 +03:00
David Major
56ea434680 Bug 1528074 - Translate MSVC warning flags to clang spelling where supported r=froydnj
clang-cl only acts on five MSVC warning flags: 7219c7e9af/clang/include/clang/Driver/CLCompatOptions.td (L188-L197)

With MSVC now unsupported, most -wdNNNN have no effect and can be removed.

This patch converts the five supported warnings to their clang spellings, as preparation for a subsequent patch that will remove all remaining `[/-]w[edo][0-9]{4}`.

Differential Revision: https://phabricator.services.mozilla.com/D22582

--HG--
extra : moz-landing-system : lando
2019-03-11 01:39:42 +00:00
Mike Hommey
ef3ad686ee Bug 1512504 - Remove support for MSVC. r=froydnj
Consequently, this removes:
- MOZ_LIBPRIO, which is now always enabled.
- non_msvc_compiler, which is now always true.
- The cl.py wrapper, since it's not used anymore.
- CL_INCLUDES_PREFIX, which was only used for the cl.py wrapper.
- NONASCII, which was only there to ensure CL_INCLUDES_PREFIX still
  worked in non-ASCII cases.

This however keeps a large part of detecting and configuring for MSVC,
because we still do need it for at least headers, libraries, and midl.

Depends on D19614

Differential Revision: https://phabricator.services.mozilla.com/D19615

--HG--
extra : moz-landing-system : lando
2019-02-14 21:45:27 +00:00
Alex Chronopoulos
f26917afec Bug 1527659 - Update cubeb from upstream to 3afc335. r=kinetik
Differential Revision: https://phabricator.services.mozilla.com/D19676

--HG--
extra : moz-landing-system : lando
2019-02-13 21:50:03 +00:00
Alex Chronopoulos
2f27522cda Bug 1518106 - Update cubeb-pulse-rs from upstream to 17c1629. r=kinetik
Differential Revision: https://phabricator.services.mozilla.com/D17400

--HG--
extra : moz-landing-system : lando
2019-01-23 19:37:18 +00:00
Alex Chronopoulos
46289fa2a3 Bug 1518106 - Update cubeb from upstream to feec7e2. r=kinetik
Differential Revision: https://phabricator.services.mozilla.com/D17399

--HG--
extra : moz-landing-system : lando
2019-01-23 19:36:20 +00:00
Alex Chronopoulos
836d8e0a78 Bug 1521791 - Update cubeb from upstream to 67d37c1. r=padenot
Differential Revision: https://phabricator.services.mozilla.com/D17248

--HG--
extra : moz-landing-system : lando
2019-01-22 16:09:51 +00:00
Jean-Yves Avenard
836fc05ec7 Bug 1509875 - Update cubeb from upstream to e5c3a1d8a68c. r=padenot
Differential Revision: https://phabricator.services.mozilla.com/D13755

--HG--
extra : moz-landing-system : lando
2018-12-04 21:40:49 +00:00
byron jones
9bed7ee50d Bug 1504932 - Replace libcubeb's README_Mozilla file with moz.yaml r=kinetik
Differential Revision: https://phabricator.services.mozilla.com/D10995

--HG--
extra : moz-landing-system : lando
2018-11-06 17:11:40 +00:00
Alex Chronopoulos
b9087831d6 Bug 1503240 - Print the picked commits in update script. r=kinetik
Differential Revision: https://phabricator.services.mozilla.com/D10216

--HG--
extra : moz-landing-system : lando
2018-10-31 09:58:01 +00:00
Alex Chronopoulos
ae7ed1047a Bug 1502165 - Update cubeb from upstream to 9a7a551. r=kinetik 2018-10-30 12:37:06 +01:00