0332b07abeca7c976e862fea743b535b90c7532d: Bug 1530715 - P40: Move stream setup and close into a struct within a mutex. r=padenot
Chun-Min Chang <chun.m.chang@gmail.com> - Wed, 10 Jul 2019 08:07:00 +0000 - rev 483240
Push 36307 by aciure@mozilla.com at Thu, 18 Jul 2019 03:45:56 +0000
Bug 1530715 - P40: Move stream setup and close into a struct within a mutex. r=padenot The core stream data that will be touched on the different threads when the stream is created, reinitialized, destoryed should be used in the critical section. Those core data are initialized in stream-setup and destroyed in stream-close. The stream-setup and stream-close is run in the critical section so they won't be executed at the same time. Currently, the critical section is created by our custom mutex. However, this custom mutex will be removed in the later mutex replacement. Instead of running these two operations in the critical sections created by the custom mutex, they should be moved into a struct wrapped by a standard Rust mutex. As a result, at the end when the custom mutex is removed, these two operations are still in the critical sections that are created by the Rust mutex. Differential Revision: https://phabricator.services.mozilla.com/D34073
083df83e6977bf2c32373d29a65b692333285185: Bug 1530715 - P39: Move listeners (un)registrations into a strcut within a mutex. r=padenot
Chun-Min Chang <chun.m.chang@gmail.com> - Wed, 10 Jul 2019 08:07:02 +0000 - rev 483239
Push 36307 by aciure@mozilla.com at Thu, 18 Jul 2019 03:45:56 +0000
Bug 1530715 - P39: Move listeners (un)registrations into a strcut within a mutex. r=padenot The listeners will be registered and unregistered on the different threads, so the listeners should be used in the critical sections. We do create critical sections by our own 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 listeners to the struct wrapped by a Rust mutex and register or unregister the listeners in the critical section created by this struct. At the end when the custom mutex is removed, those operations are still in the critical sections. Differential Revision: https://phabricator.services.mozilla.com/D34072
c18d984cb31891a0aa56340729152f8224c8e91f: Bug 1530715 - P38: Merge configure_input into setup. r=padenot
Chun-Min Chang <chun.m.chang@gmail.com> - Wed, 10 Jul 2019 08:07:04 +0000 - rev 483238
Push 36307 by aciure@mozilla.com at Thu, 18 Jul 2019 03:45:56 +0000
Bug 1530715 - P38: Merge configure_input into setup. r=padenot Calling configure_input requires borrowing AudioUnitStream as a mutable. Merging configure_input into setup will help to avoid a potential borrowing-twice issue in the later mutex replacement. There will be a critical section created by a Rust mutex in the setup, which will borrow the AudioUnitStream as an immutable. Differential Revision: https://phabricator.services.mozilla.com/D34071
b4f102752e7d4ab0d844f47d4ce59879512dc79d: Bug 1530715 - P37: Merge configure_output into setup. r=padenot
Chun-Min Chang <chun.m.chang@gmail.com> - Wed, 10 Jul 2019 08:07:06 +0000 - rev 483237
Push 36307 by aciure@mozilla.com at Thu, 18 Jul 2019 03:45:56 +0000
Bug 1530715 - P37: Merge configure_output into setup. r=padenot Calling configure_output requires borrowing AudioUnitStream as a mutable. Merging configure_output into setup will help to avoid a potential borrowing-twice issue in the later mutex replacement. There will be a critical section created by a Rust mutex in the setup, which will borrow the AudioUnitStream as an immutable. Differential Revision: https://phabricator.services.mozilla.com/D34070
69804f288c2971f29c441cc49878e3ad620e5657: Bug 1530715 - P36: Move out minimum_resampling_input_frames of output callback. r=padenot
Chun-Min Chang <chun.m.chang@gmail.com> - Wed, 10 Jul 2019 08:07:08 +0000 - rev 483236
Push 36307 by aciure@mozilla.com at Thu, 18 Jul 2019 03:45:56 +0000
Bug 1530715 - P36: Move out minimum_resampling_input_frames of output callback. r=padenot Avoid calling minimum_resampling_input_frames by a borrowing from AudioUnitStream Differential Revision: https://phabricator.services.mozilla.com/D34069
774c895c293d85ef128842515a729d07fcbe9f0c: Bug 1530715 - P35: Store layout in the stream instead of context. r=padenot
Chun-Min Chang <chun.m.chang@gmail.com> - Wed, 10 Jul 2019 08:07:10 +0000 - rev 483235
Push 36307 by aciure@mozilla.com at Thu, 18 Jul 2019 03:45:56 +0000
Bug 1530715 - P35: Store layout in the stream instead of context. r=padenot We store global layout info and channels info in the cubeb context. However, the streams might output to different devices. We should store the layout info of the output device in the stream directly instead of in the context. On the other hand, the `channels` value is a duplicate of `output_desc.mChannelsPerFrame` or `mixer.out_channels` so we don't need to store this value. Differential Revision: https://phabricator.services.mozilla.com/D34068
eaec698bcf3ac3a26d19820b851c322207e75506: Bug 1530715 - P34: Merge layout_init into configure_output. r=padenot
Chun-Min Chang <chun.m.chang@gmail.com> - Wed, 10 Jul 2019 08:06:35 +0000 - rev 483234
Push 36307 by aciure@mozilla.com at Thu, 18 Jul 2019 03:45:56 +0000
Bug 1530715 - P34: Merge layout_init into configure_output. r=padenot 1. Avoid calling layout_init by wrong AudioUnit value 2. Avoid calling layout getting/setting APIs by borrowing the AudioUnitStream as a mutable. It will help to avoid the potential borrowing-twice issues in the later mutex replacement. Differential Revision: https://phabricator.services.mozilla.com/D34067
11432ad63378562100a8190523e56d3333e024eb: Bug 1530715 - P33: Register and unregister the device-changed callbacks when stream setup and close. r=padenot
Chun-Min Chang <chun.m.chang@gmail.com> - Wed, 10 Jul 2019 08:06:37 +0000 - rev 483233
Push 36307 by aciure@mozilla.com at Thu, 18 Jul 2019 03:45:56 +0000
Bug 1530715 - P33: Register and unregister the device-changed callbacks when stream setup and close. r=padenot 1. The code readability is slightly better if we can register and unregister the callbacks in the same places. The device-chaned callbacks are registered when stream setup and unregistered when stream close. 2. In the later mutex replacement, the core stream variables that may be touched by different threads when reinitializing or destroying the stream, including {in, out}_unit, will be wrapped in a Rust mutex. Moving these callbacks (un)registration into the same places makes it easier to find where the critical sections are. Differential Revision: https://phabricator.services.mozilla.com/D34066
9919e152f9bb429679dc3196664a8c0c08cbd8ff: Bug 1530715 - P32: Close the stream if failing in stream reinitialization. r=padenot
Chun-Min Chang <chun.m.chang@gmail.com> - Wed, 10 Jul 2019 08:06:39 +0000 - rev 483232
Push 36307 by aciure@mozilla.com at Thu, 18 Jul 2019 03:45:56 +0000
Bug 1530715 - P32: Close the stream if failing in stream reinitialization. r=padenot Before reporting the error by the state callback, closing the stream to make sure the data callback and device-changed callback are unregistered. Differential Revision: https://phabricator.services.mozilla.com/D34065
9bb78d3625b973d7864af3b241a2de2dcacf677f: Bug 1530715 - P31: Merge render_input into audiounit_input_callback. r=padenot
Chun-Min Chang <chun.m.chang@gmail.com> - Wed, 10 Jul 2019 08:06:41 +0000 - rev 483231
Push 36307 by aciure@mozilla.com at Thu, 18 Jul 2019 03:45:56 +0000
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
39adde36627b62d073fd045a3e4dbacd00000fcb: Bug 1530715 - P30: Some clean-up in audiounit_output_callback. r=padenot
Chun-Min Chang <chun.m.chang@gmail.com> - Wed, 10 Jul 2019 08:06:43 +0000 - rev 483230
Push 36307 by aciure@mozilla.com at Thu, 18 Jul 2019 03:45:56 +0000
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
cc39becdbbf9ca5b64e8b8d9817aad4623dc20ee: Bug 1530715 - P29: Move mixer to a struct within a mutex. r=padenot
Chun-Min Chang <chun.m.chang@gmail.com> - Wed, 10 Jul 2019 08:06:45 +0000 - rev 483229
Push 36307 by aciure@mozilla.com at Thu, 18 Jul 2019 03:45:56 +0000
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
bacfef6665e72cfdbcb94e74f3d10f7d0329cb3b: Bug 1530715 - P28: Create a Mixer module. r=padenot
Chun-Min Chang <chun.m.chang@gmail.com> - Wed, 10 Jul 2019 08:06:47 +0000 - rev 483228
Push 36307 by aciure@mozilla.com at Thu, 18 Jul 2019 03:45:56 +0000
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
7fa4c29b3ec1874f7e939d578d7c7178624cf765: Bug 1530715 - P27: Move resampler to a struct within a mutex. r=padenot
Chun-Min Chang <chun.m.chang@gmail.com> - Wed, 10 Jul 2019 08:06:48 +0000 - rev 483227
Push 36307 by aciure@mozilla.com at Thu, 18 Jul 2019 03:45:56 +0000
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
970f3217c5a186412617c6fb5a46b12bfc0cb4ed: Bug 1530715 - P26: Create a Resampler module. r=padenot
Chun-Min Chang <chun.m.chang@gmail.com> - Wed, 10 Jul 2019 08:06:50 +0000 - rev 483226
Push 36307 by aciure@mozilla.com at Thu, 18 Jul 2019 03:45:56 +0000
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
93348af70403373f89686389d17a042045a50cd8: Bug 1530715 - P25: Move aggregate_device to a struct within a mutex. r=padenot
Chun-Min Chang <chun.m.chang@gmail.com> - Wed, 10 Jul 2019 08:06:52 +0000 - rev 483225
Push 36307 by aciure@mozilla.com at Thu, 18 Jul 2019 03:45:56 +0000
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
976263f4ead5bf88b8fe1702ddf90e191330b64c: Bug 1530715 - P24: Create an AggregateDevice module. r=padenot
Chun-Min Chang <chun.m.chang@gmail.com> - Wed, 10 Jul 2019 08:06:54 +0000 - rev 483224
Push 36307 by aciure@mozilla.com at Thu, 18 Jul 2019 03:45:56 +0000
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
c842af1a5ca734233770a256b306a7640a1e6c47: Bug 1530715 - P23: Avoid poisoning the mutex for device_changed_callback. r=padenot
Chun-Min Chang <chun.m.chang@gmail.com> - Wed, 10 Jul 2019 08:06:14 +0000 - rev 483223
Push 36307 by aciure@mozilla.com at Thu, 18 Jul 2019 03:45:56 +0000
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
9fe7e1c2da2733669af669172642c84d0cc19b01: Bug 1530715 - P22: Replace device_changed_callback_lock by standard Rust mutex. r=padenot
Chun-Min Chang <chun.m.chang@gmail.com> - Wed, 10 Jul 2019 08:06:16 +0000 - rev 483222
Push 36307 by aciure@mozilla.com at Thu, 18 Jul 2019 03:45:56 +0000
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
a80d27c3114d11ae35be2f10a9574ae2734d825f: Bug 1530715 - P21: Replace set_buffer_size by set_buffer_size_sync and its friends. r=padenot
Chun-Min Chang <chun.m.chang@gmail.com> - Wed, 10 Jul 2019 08:06:18 +0000 - rev 483221
Push 36307 by aciure@mozilla.com at Thu, 18 Jul 2019 03:45:56 +0000
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
(0) -300000 -100000 -30000 -10000 -3000 -1000 -300 -100 -50 -20 +20 +50 +100 +300 +1000 +3000 +10000 +30000 tip